[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-30 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 updated this revision to Diff 341784.
DNS320 added a comment.

Renamed the IsInsideMatchedForStmt() function according to a comment from the 
build system.
Changed a data type to "auto" according to a comment from Eugene.Zelenko.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100092

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-declare-loop-variable-in-the-initializer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-declare-loop-variable-in-the-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-declare-loop-variable-in-the-initializer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-declare-loop-variable-in-the-initializer.cpp
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-declare-loop-variable-in-the-initializer %t
+
+const int Limit{10};
+
+void func1() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'A' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :11:5: note: Variable gets modified here
+  int A{0};
+
+  for (int I{0}; I < Limit; I++) {
+A = 3;
+  }
+}
+
+void func2() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'A' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :21:5: note: Variable gets modified here
+  int A{0};
+
+  for (int I{0}; I < Limit; I++) {
+A += 3;
+  }
+}
+
+void func3() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'I' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :30:8: note: Variable gets modified here
+  int I{0};
+
+  for (I = 1; I < Limit; I++) {
+  }
+}
+
+void func4() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'I' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :39:21: note: Variable gets modified here
+  int I{0};
+
+  for (; I < Limit; I++) {
+  }
+}
+
+void func5() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'I' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :48:34: note: Variable gets modified here
+  int I{0};
+
+  for (int Unused{0}; I < Limit; I++) {
+  }
+}
+
+void func6() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'I' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :58:8: note: Variable gets modified here
+  int I{0};
+  int Z{0};
+
+  for (I = 3; I < Limit; I++) {
+  }
+  Z = 3;
+}
+
+void func7() {
+  // OK
+  int A{0};
+
+  for (int I{0}; I < Limit; I++) {
+const int B{A};
+  }
+}
+
+void func8() {
+  // OK
+  int I{0};
+
+  for (I = 0; I < Limit; I++) {
+  }
+  const int A{I};
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -143,6 +143,7 @@
`concurrency-thread-canceltype-asynchronous `_,
`cppcoreguidelines-avoid-goto `_,
`cppcoreguidelines-avoid-non-const-global-variables `_,
+   `cppcoreguidelines-declare-loop-variable-in-the-initializer `_,
`cppcoreguidelines-init-variables `_, "Yes"
`cppcoreguidelines-interfaces-global-init `_,
`cppcoreguidelines-macro-usage `_,
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-declare-loop-variable-in-the-initializer.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-declare-loop-variable-in-the-initializer.rst
@@ -0,0 +1,50 @@
+.. title:: clang-tidy - cppcoreguidelines-declare-loop-variable-in-the-initializer
+
+cppcoreguidelines-declare-loop-variable-in-the-initial

[clang] c81ec19 - Fix -fdebug-pass-structure test case

2021-04-30 Thread Evgeny Leviant via cfe-commits

Author: Evgeny Leviant
Date: 2021-04-30T10:18:23+03:00
New Revision: c81ec19fba27ec308607aac2e44234eee8e190d1

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

LOG: Fix -fdebug-pass-structure test case

Pass structure can change when -O0 is given and extensions are used.

Added: 


Modified: 
clang/test/Driver/debug-pass-structure.c

Removed: 




diff  --git a/clang/test/Driver/debug-pass-structure.c 
b/clang/test/Driver/debug-pass-structure.c
index 30283249f4126..04ddce8cc5599 100644
--- a/clang/test/Driver/debug-pass-structure.c
+++ b/clang/test/Driver/debug-pass-structure.c
@@ -38,26 +38,5 @@
 // NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
 // NEWPM-NEXT: PrintModulePass on [module]
 
-// LEGACYPM:  Pass Arguments:  -tti -targetlibinfo -verify
-// LEGACYPM-NEXT: Target Transform Information
-// LEGACYPM-NEXT: Target Library Information
-// LEGACYPM-NEXT:   FunctionPass Manager
-// LEGACYPM-NEXT: Module Verifier
-// LEGACYPM-NEXT: Pass Arguments:  -tti -targetlibinfo 
-assumption-cache-tracker -profile-summary-info -annotation2metadata 
-forceattrs -basiccg -always-inline -annotation-remarks
-// LEGACYPM-NEXT: Target Transform Information
-// LEGACYPM-NEXT: Target Library Information
-// LEGACYPM-NEXT: Assumption Cache Tracker
-// LEGACYPM-NEXT: Profile summary info
-// LEGACYPM-NEXT:   ModulePass Manager
-// LEGACYPM-NEXT: Annotation2Metadata
-// LEGACYPM-NEXT: Force set function attributes
-// LEGACYPM-NEXT: CallGraph Construction
-// LEGACYPM-NEXT: Call Graph SCC Pass Manager
-// LEGACYPM-NEXT:   Inliner for always_inline functions
-// LEGACYPM-NEXT:   FunctionPass Manager
-// LEGACYPM-NEXT: Annotation Remarks
-// LEGACYPM-NEXT: Print Module IR
-// LEGACYPM-NEXT: Pass Arguments:  -tti
-// LEGACYPM-NEXT: Target Transform Information
-// LEGACYPM-NEXT:   ModulePass Manager
+// LEGACYPM:  Pass Arguments:
 



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


[PATCH] D99599: [NewPM] Add an option to dump pass structure

2021-04-30 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added a comment.

Should be fixed with `c81ec19fba27ec`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99599

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


[PATCH] D101515: clang-format: [JS] handle "off" in imports

2021-04-30 Thread Hana Joo via Phabricator via cfe-commits
h-joo requested changes to this revision.
h-joo added a comment.
This revision now requires changes to proceed.

In D101515#2726889 , @krasimir wrote:

> @h-joo , seems we had a comment race :D cheers!

:D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101515

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


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

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

Nice. Thanks for including the references.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101595

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


[PATCH] D99599: [NewPM] Add an option to dump pass structure

2021-04-30 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D99599#2728092 , @evgeny777 wrote:

> Should be fixed with `c81ec19fba27ec`

Thank you, our builders went green after that change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99599

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


[PATCH] D101601: [SelectionDAG] Make fast and linearize visible by clang -pre-RA-sched

2021-04-30 Thread TaoPan via Phabricator via cfe-commits
TaoPan created this revision.
Herald added subscribers: ecnelises, hiraditya.
TaoPan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Scheduler can be registered through static RegisterScheduler if the host
cpp file is linked, the schedulers of SchedulerDAGRRList.cpp and
SchedulerDAGVLIW.cpp are visible as functions createXxx of these two cpp
files are called by SelectionDAGISel.cpp, add calling to createXxx of
ScheduleDAGFast.cpp to make scheduler fast and linearize visible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101601

Files:
  clang/test/CodeGen/pre-ra-sched.c
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -270,6 +270,10 @@
   return createHybridListDAGScheduler(IS, OptLevel);
 if (TLI->getSchedulingPreference() == Sched::VLIW)
   return createVLIWDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Fast)
+  return createFastDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Linearize)
+  return createDAGLinearizer(IS, OptLevel);
 assert(TLI->getSchedulingPreference() == Sched::ILP &&
"Unknown sched type!");
 return createILPListDAGScheduler(IS, OptLevel);
Index: llvm/include/llvm/CodeGen/TargetLowering.h
===
--- llvm/include/llvm/CodeGen/TargetLowering.h
+++ llvm/include/llvm/CodeGen/TargetLowering.h
@@ -94,14 +94,16 @@
 
 namespace Sched {
 
-  enum Preference {
-None, // No preference
-Source,   // Follow source order.
-RegPressure,  // Scheduling for lowest register pressure.
-Hybrid,   // Scheduling for both latency and register pressure.
-ILP,  // Scheduling for ILP in low register pressure mode.
-VLIW  // Scheduling for VLIW targets.
-  };
+enum Preference {
+  None,// No preference
+  Source,  // Follow source order.
+  RegPressure, // Scheduling for lowest register pressure.
+  Hybrid,  // Scheduling for both latency and register pressure.
+  ILP, // Scheduling for ILP in low register pressure mode.
+  VLIW,// Scheduling for VLIW targets.
+  Fast,// Fast suboptimal list scheduling
+  Linearize,   // Linearize DAG, no scheduling
+};
 
 } // end namespace Sched
 
Index: clang/test/CodeGen/pre-ra-sched.c
===
--- /dev/null
+++ clang/test/CodeGen/pre-ra-sched.c
@@ -0,0 +1,8 @@
+// RUN: %clang %s -mllvm -pre-RA-sched=fast -c -o - | FileCheck %s
+// RUN: %clang %s -mllvm -pre-RA-sched=linearize -c -o - | FileCheck %s
+
+// CHECK-NOT: clang (LLVM option parsing): for the --pre-RA-sched option: 
Cannot find option named
+
+int main() {
+  return 0;
+}


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -270,6 +270,10 @@
   return createHybridListDAGScheduler(IS, OptLevel);
 if (TLI->getSchedulingPreference() == Sched::VLIW)
   return createVLIWDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Fast)
+  return createFastDAGScheduler(IS, OptLevel);
+if (TLI->getSchedulingPreference() == Sched::Linearize)
+  return createDAGLinearizer(IS, OptLevel);
 assert(TLI->getSchedulingPreference() == Sched::ILP &&
"Unknown sched type!");
 return createILPListDAGScheduler(IS, OptLevel);
Index: llvm/include/llvm/CodeGen/TargetLowering.h
===
--- llvm/include/llvm/CodeGen/TargetLowering.h
+++ llvm/include/llvm/CodeGen/TargetLowering.h
@@ -94,14 +94,16 @@
 
 namespace Sched {
 
-  enum Preference {
-None, // No preference
-Source,   // Follow source order.
-RegPressure,  // Scheduling for lowest register pressure.
-Hybrid,   // Scheduling for both latency and register pressure.
-ILP,  // Scheduling for ILP in low register pressure mode.
-VLIW  // Scheduling for VLIW targets.
-  };
+enum Preference {
+  None,// No preference
+  Source,  // Follow source order.
+  RegPressure, // Scheduling for lowest register pressure.
+  Hybrid,  // Scheduling for both latency and register pressure.
+  ILP, // Scheduling for ILP in low register pressure mode.
+  VLIW,// Scheduling for VLIW targets.
+  Fast,// Fast suboptimal list scheduling
+  Linearize,   // Linearize DAG, no sc

[PATCH] D101606: [ARM] vcreateq lane ordering for big endian

2021-04-30 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson created this revision.
Herald added subscribers: danielkiss, dmgreen, kristof.beyls.
tmatheson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Use of bitcast resulted in lanes being swapped for vcreateq with big
endian. Fix this by using vreinterpret. No code change for little
endian. Adds IR lit test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101606

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/admin.c

Index: clang/test/CodeGen/arm-mve-intrinsics/admin.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/admin.c
+++ clang/test/CodeGen/arm-mve-intrinsics/admin.c
@@ -1,6 +1,9 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LE
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BE
+
 
 #include 
 
@@ -8,7 +11,8 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <8 x half> @llvm.arm.mve.vreinterpretq.v8f16.v2i64(<2 x i64> [[TMP1]])
 // CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vcreateq_f16(uint64_t a, uint64_t b)
@@ -20,7 +24,8 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <4 x float> @llvm.arm.mve.vreinterpretq.v4f32.v2i64(<2 x i64> [[TMP1]])
 // CHECK-NEXT:ret <4 x float> [[TMP2]]
 //
 float32x4_t test_vcreateq_f32(uint64_t a, uint64_t b)
@@ -32,7 +37,8 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x i16>
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x i16>
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <8 x i16> @llvm.arm.mve.vreinterpretq.v8i16.v2i64(<2 x i64> [[TMP1]])
 // CHECK-NEXT:ret <8 x i16> [[TMP2]]
 //
 int16x8_t test_vcreateq_s16(uint64_t a, uint64_t b)
@@ -44,7 +50,8 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x i32>
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x i32>
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <4 x i32> @llvm.arm.mve.vreinterpretq.v4i32.v2i64(<2 x i64> [[TMP1]])
 // CHECK-NEXT:ret <4 x i32> [[TMP2]]
 //
 int32x4_t test_vcreateq_s32(uint64_t a, uint64_t b)
@@ -67,7 +74,8 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x

[PATCH] D101606: [ARM] vcreateq lane ordering for big endian

2021-04-30 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM added a comment.

Not sure yet.




Comment at: clang/test/CodeGen/arm-mve-intrinsics/admin.c:66
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 
[[B:%.*]], i64 1
 // CHECK-NEXT:ret <2 x i64> [[TMP1]]
 //

Surely there is a problem here also?



Comment at: clang/test/CodeGen/arm-mve-intrinsics/admin.c:116
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 
[[B:%.*]], i64 1
 // CHECK-NEXT:ret <2 x i64> [[TMP1]]
 //

And a problem here also (with BE)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

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


[PATCH] D101554: [clangd] Add support for the `defaultLibrary` semantic token modifier

2021-04-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:413
+  /// different heuristics may be used in the future (e.g. sysroot paths).
+  bool inDefaultLibrary(SourceLocation Loc) const {
+if (!Loc.isValid())

you can make this a free function by accepting a decl instead. as sourcemanager 
is accessible via `D->getASTContext().getSourceManager()`. this way you don't 
need to modify signatures for `scopeModifier` overloads (and get rid of the 
duplicate in `CollectExtraHighlightings`).



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:433
+scopeModifier(const NamedDecl *D, const HighlightingsBuilder &HB) {
+  if (!D)
+return llvm::None;

why the null check now?



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:436
+  if (HB.inDefaultLibrary(D->getLocation()))
+return HighlightingModifier::DefaultLibrary;
   const DeclContext *DC = D->getDeclContext();

I don't use semantic highlighting enough to judge whether it is more useful to 
say `DefaultLibrary` than `{Class,Function}Scope`. (i.e. having the check here 
vs at the end of the function as a fallback). Can you provide some rationale 
about the decision (probably as comments in code)?

By looking at the testcase, I suppose you are trying to indicate 
"overriden"/"extended" attribute of a symbol, which makes sense but would be 
nice to know if there's more. I am just worried that this is very obj-c 
specific and won't really generalize to c/c++. As most of the system headers 
only provide platform specific structs (e.g. posix) and they are almost never 
extended. So it might be confusing for user to see different colors on some 
memberexprs.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:474
+return scopeModifier(TD, HB);
+  if (auto *OT = dyn_cast(T))
+return scopeModifier(OT->getInterface(), HB);

should this be put in a separate patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101554

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


[PATCH] D101606: [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Sounds good to me.

Whilst we are here, are any of the other uses of bitcast in arm_mve.td 
potentially a problem? I took a quick look and because they both converting the 
inputs and the outputs, I believe they will be OK. (Two wrongs make a right, if 
you will).




Comment at: clang/test/CodeGen/arm-mve-intrinsics/admin.c:1
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | 
FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LE

Is this updated with update_cc_test_checks?

It may make the output more verbose, but it will be more standard.



Comment at: clang/test/CodeGen/arm-mve-intrinsics/admin.c:66
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 
[[B:%.*]], i64 1
 // CHECK-NEXT:ret <2 x i64> [[TMP1]]
 //

MarkMurrayARM wrote:
> Surely there is a problem here also?
I don't see why these would be a problem. Can you elaborate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

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


[PATCH] D101516: Introduce clangd-server-monitor tool

2021-04-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

thanks for doing this! can we also have a lit test? we already have some tests 
spinning up an index-server, i suppose we can make an extra rpc to those and 
ensure we get a success response?




Comment at: clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt:4
+  )
+add_clang_executable(clangd-server-monitor
+  Monitor.cpp

s/server/index-server/

being more specific would be nice, just in case we have more servers (i.e. 
review) in the future.



Comment at: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp:54
+  if (!Status.ok()) {
+llvm::errs() << llvm::formatv(
+"Can not request monitoring information ({0}): {1}\n",

nit: elog



Comment at: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp:59
+  }
+  llvm::outs() << Response.DebugString();
+}

rather than dumping protobuf, can we dump in json ? see 
https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.util.json_util


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101516

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


[PATCH] D101606: [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM added inline comments.



Comment at: clang/test/CodeGen/arm-mve-intrinsics/admin.c:66
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 
[[B:%.*]], i64 1
 // CHECK-NEXT:ret <2 x i64> [[TMP1]]
 //

dmgreen wrote:
> MarkMurrayARM wrote:
> > Surely there is a problem here also?
> I don't see why these would be a problem. Can you elaborate?
I'm wondering if they need to be swapped in the BE case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

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


[PATCH] D101554: [clangd] Add support for the `defaultLibrary` semantic token modifier

2021-04-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:436
+  if (HB.inDefaultLibrary(D->getLocation()))
+return HighlightingModifier::DefaultLibrary;
   const DeclContext *DC = D->getDeclContext();

kadircet wrote:
> I don't use semantic highlighting enough to judge whether it is more useful 
> to say `DefaultLibrary` than `{Class,Function}Scope`. (i.e. having the check 
> here vs at the end of the function as a fallback). Can you provide some 
> rationale about the decision (probably as comments in code)?
> 
> By looking at the testcase, I suppose you are trying to indicate 
> "overriden"/"extended" attribute of a symbol, which makes sense but would be 
> nice to know if there's more. I am just worried that this is very obj-c 
> specific and won't really generalize to c/c++. As most of the system headers 
> only provide platform specific structs (e.g. posix) and they are almost never 
> extended. So it might be confusing for user to see different colors on some 
> memberexprs.
I think default-library isn't a scope modifier at all, it should be independent.

e.g. std::string is defaultlLibrary | globalScope, while 
std::string::push_back() is defaultLibrary | classScope.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:465
+llvm::Optional
+scopeModifier(const Type *T, const HighlightingsBuilder &HB) {
   if (!T)

I'm confused about the interface change - looks like the new parameter never 
actually used, just passed around



Comment at: clang-tools-extra/clangd/SemanticHighlighting.h:75
   GlobalScope,
+  DefaultLibrary,
 

This isn't a scope modifier so shouldn't be grouped with them


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101554

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


[PATCH] D97915: [Coroutines] Handle overaligned frame allocation

2021-04-30 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

This code snippets confused me before:

  coro.alloc.align: ; preds = %coro.check.align
%mask = sub i64 %11, 1
%intptr = ptrtoint i8* %call to i64
%over_boundary = add i64 %intptr, %mask
%inverted_mask = xor i64 %mask, -1
%aligned_intptr = and i64 %over_boundary, %inverted_mask
%diff = sub i64 %aligned_intptr, %intptr
%aligned_result = getelementptr inbounds i8, i8* %call, i64 %diff

This code implies that `%diff > 0`. Formally, given `Align = 2^m, m > 4` and 
`Address=16n`, we need to prove that:

  (Address + Align -16)&(~(Align-1)) >= Address

`&(~Align-1)` would make the lowest `m` bit to 0. And `Align-16` equals to `2^m 
- 16`, which is `16*(2^(m-4)-1)`. Then `Address + Align -16` could be 
`16*(n+2^(m-4)-1)`.
Then we call `X` for the value of the lowest `m` bit of  `Address + Align -16`. 
Because `X` has `m` bit, so `X <= 2^m - 1`. Noticed that `X` should be 16 
aligned, so the lowest 4 bit should be zero.
Now,

  X <= 2^m - 1 -1 - 2 - 4 - 8 = 2^m - 16

So the inequality we need prove now should be:

  16*(n+2^(m-4)-1) - X >= 16n

Given X has the largest value wouldn't affect the inequality, so:

  16*(n+2^(m-4)-1) - 2^m + 16 >= 16n

which is very easy now.

The overall prove looks non-travel to me. I spent some time to figure it out. I 
guess there must be some other people who can't get it immediately. I strongly 
recommend to add comment and corresponding prove for this code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97915

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


[PATCH] D101515: clang-format: [JS] handle "off" in imports

2021-04-30 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked 9 inline comments as done.
mprobst added a comment.

PTAL, addressed review comments.




Comment at: clang/lib/Format/SortJavaScriptImports.cpp:191
+!(FirstNonImportLine->First->is(tok::comment) &&
+  FirstNonImportLine->First->TokenText.trim() == "// clang-format on"))
   ReferencesText += "\n";

krasimir wrote:
> note that we generally also support `/* clang-format off/on */`: 
> https://github.com/llvm/llvm-project/blob/aaf026d9da3885a951dcdc5edd64c8e7d23b6285/clang/lib/Format/Format.cpp#L2390
We don't in the C++ import sorter. Sigh.

I think the Real Fix (tm) would be folding the clang-format off thing in import 
sorting with affected lines, wouldn't it? I don't quite know how to untangle 
this, but it seems suboptimal that each sorter here re-implements the same 
logic.



Comment at: clang/lib/Format/SortJavaScriptImports.cpp:251
+  // references that have formatting enabled in individual chunks.
+  SmallVector
+  sortModuleReferences(SmallVector &References) {

krasimir wrote:
> We should pass in and return `llvm::SmallVectorImpl` (the 
> size version is mainly for local vars). Also, take the arg by `const` 
> reference.
That gives me:

`error: no viable conversion from 'SmallVector<[...], 16>' to 'const 
SmallVector<[...], (default) 
CalculateSmallVectorDefaultInlinedElements::value aka 1>'`



Comment at: clang/lib/Format/SortJavaScriptImports.cpp:288
+  // longer needed references).
+  void mergeModuleReferences(SmallVector &References) {
+if (References.empty())

krasimir wrote:
> use `llvm::SmallVectorImpl`
As above, this seems not possible.



Comment at: clang/lib/Format/SortJavaScriptImports.cpp:377
+  }
   skipComments();
   if (Start.isInvalid() || References.empty())

h-joo wrote:
> I think this has a potential bug that if the user makes
> ```
> // clang-format off
> // clang-format on
> ```
> Every subsequent import will fail to be sorted. 
> 
> or maybe something like below
> ```
> //clang-format off
> import {A, B} from "./a"
> //clang-format on
> //clang-format off
> ```
> will make the 'should not be sorted' part of the code be sorted.
> 
> Even if this is not the case, could you write a test for this one?
Nice, good catch! Done.



Comment at: clang/unittests/Format/SortImportsTestJS.cpp:362
+ "\n"
+ "export {B} from 'foo';\n",
  "import {A} from 'foo';\n"

krasimir wrote:
> Was this change intended? It doesn't seem related to this patch.
the empty line is intended. Previously this wouldn't end up formatting because 
the code was trying to be too clever in detecting changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101515

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


[PATCH] D101515: clang-format: [JS] handle "off" in imports

2021-04-30 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 341814.
mprobst marked 4 inline comments as done.
mprobst added a comment.

- review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101515

Files:
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/SortImportsTestJS.cpp

Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -358,7 +358,8 @@
 
   // do not merge imports and exports
   verifySort("import {A} from 'foo';\n"
- "export {B} from 'foo';",
+ "\n"
+ "export {B} from 'foo';\n",
  "import {A} from 'foo';\n"
  "export   {B} from 'foo';");
   // do merge exports
@@ -373,6 +374,63 @@
  "import './a';\n");
 }
 
+TEST_F(SortImportsTestJS, RespectsClangFormatOff) {
+  verifySort("// clang-format off\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format on\n",
+ "// clang-format off\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format on\n");
+
+  verifySort("import {A} from './sorted1_a';\n"
+ "import {B} from './sorted1_b';\n"
+ "// clang-format off\n"
+ "import {B} from './unsorted_b';\n"
+ "import {A} from './unsorted_a';\n"
+ "// clang-format on\n"
+ "import {A} from './sorted2_a';\n"
+ "import {B} from './sorted2_b';\n",
+ "import {B} from './sorted1_b';\n"
+ "import {A} from './sorted1_a';\n"
+ "// clang-format off\n"
+ "import {B} from './unsorted_b';\n"
+ "import {A} from './unsorted_a';\n"
+ "// clang-format on\n"
+ "import {B} from './sorted2_b';\n"
+ "import {A} from './sorted2_a';\n");
+
+  // Boundary cases
+  verifySort("// clang-format on\n", "// clang-format on\n");
+  verifySort("// clang-format off\n", "// clang-format off\n");
+  verifySort("// clang-format on\n"
+ "// clang-format off\n",
+ "// clang-format on\n"
+ "// clang-format off\n");
+  verifySort("// clang-format off\n"
+ "// clang-format on\n"
+ "import {A} from './a';\n"
+ "import {B} from './b';\n",
+ "// clang-format off\n"
+ "// clang-format on\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n");
+  // section ends with comment
+  verifySort("// clang-format on\n"
+ "import {A} from './a';\n"
+ "import {B} from './b';\n"
+ "import {C} from './c';\n"
+ "\n" // inserted empty line is working as intended: splits imports
+  // section from main code body
+ "// clang-format off\n",
+ "// clang-format on\n"
+ "import {C} from './c';\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format off\n");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -19,6 +19,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
@@ -69,6 +70,7 @@
 // This struct represents both exports and imports to build up the information
 // required for sorting module references.
 struct JsModuleReference {
+  bool FormattingOff = false;
   bool IsExport = false;
   // Module references are sorted into these categories, in order.
   enum ReferenceCategory {
@@ -146,39 +148,31 @@
 if (References.empty())
   return {Result, 0};
 
-SmallVector Indices;
-for (unsigned i = 0, e = References.size(); i != e; ++i)
-  Indices.push_back(i);
-llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  return References[LHSI] < References[RHSI];
-});
-bool ReferencesInOrder = llvm::is_sorted(Indices);
+// The text range of all parsed imports, to be replaced later.
+SourceRange InsertionPoint = References[0].Range;
+InsertionPoint.setEnd(References[References.size() - 1].Range.getEnd());
 
-mergeModuleReferences(References, Indices);
+References = sortModuleReferences(References);
 
 std::string ReferencesText;
-bool SymbolsInOrder = true;
-for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
-  JsModuleReference Reference = Refe

[PATCH] D101515: clang-format: [JS] handle "off" in imports

2021-04-30 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 341815.
mprobst added a comment.

- test for avoiding merges


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101515

Files:
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/SortImportsTestJS.cpp

Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -358,7 +358,8 @@
 
   // do not merge imports and exports
   verifySort("import {A} from 'foo';\n"
- "export {B} from 'foo';",
+ "\n"
+ "export {B} from 'foo';\n",
  "import {A} from 'foo';\n"
  "export   {B} from 'foo';");
   // do merge exports
@@ -373,6 +374,63 @@
  "import './a';\n");
 }
 
+TEST_F(SortImportsTestJS, RespectsClangFormatOff) {
+  verifySort("// clang-format off\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format on\n",
+ "// clang-format off\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format on\n");
+
+  verifySort("import {A} from './sorted1_a';\n"
+ "import {B} from './sorted1_b';\n"
+ "// clang-format off\n"
+ "import {B} from './unsorted_b';\n"
+ "import {A} from './unsorted_a';\n"
+ "// clang-format on\n"
+ "import {A} from './sorted2_a';\n"
+ "import {B} from './sorted2_b';\n",
+ "import {B} from './sorted1_b';\n"
+ "import {A} from './sorted1_a';\n"
+ "// clang-format off\n"
+ "import {B} from './unsorted_b';\n"
+ "import {A} from './unsorted_a';\n"
+ "// clang-format on\n"
+ "import {B} from './sorted2_b';\n"
+ "import {A} from './sorted2_a';\n");
+
+  // Boundary cases
+  verifySort("// clang-format on\n", "// clang-format on\n");
+  verifySort("// clang-format off\n", "// clang-format off\n");
+  verifySort("// clang-format on\n"
+ "// clang-format off\n",
+ "// clang-format on\n"
+ "// clang-format off\n");
+  verifySort("// clang-format off\n"
+ "// clang-format on\n"
+ "import {A} from './a';\n"
+ "import {B} from './b';\n",
+ "// clang-format off\n"
+ "// clang-format on\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n");
+  // section ends with comment
+  verifySort("// clang-format on\n"
+ "import {A} from './a';\n"
+ "import {B} from './b';\n"
+ "import {C} from './c';\n"
+ "\n" // inserted empty line is working as intended: splits imports
+  // section from main code body
+ "// clang-format off\n",
+ "// clang-format on\n"
+ "import {C} from './c';\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format off\n");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -19,6 +19,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
@@ -69,6 +70,7 @@
 // This struct represents both exports and imports to build up the information
 // required for sorting module references.
 struct JsModuleReference {
+  bool FormattingOff = false;
   bool IsExport = false;
   // Module references are sorted into these categories, in order.
   enum ReferenceCategory {
@@ -146,39 +148,31 @@
 if (References.empty())
   return {Result, 0};
 
-SmallVector Indices;
-for (unsigned i = 0, e = References.size(); i != e; ++i)
-  Indices.push_back(i);
-llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  return References[LHSI] < References[RHSI];
-});
-bool ReferencesInOrder = llvm::is_sorted(Indices);
+// The text range of all parsed imports, to be replaced later.
+SourceRange InsertionPoint = References[0].Range;
+InsertionPoint.setEnd(References[References.size() - 1].Range.getEnd());
 
-mergeModuleReferences(References, Indices);
+References = sortModuleReferences(References);
 
 std::string ReferencesText;
-bool SymbolsInOrder = true;
-for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
-  JsModuleReference Reference = References[Indices[i]];
-  if (ap

[PATCH] D101515: clang-format: [JS] handle "off" in imports

2021-04-30 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked an inline comment as done.
mprobst added a comment.

added test for merging


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101515

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


[PATCH] D101606: [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added inline comments.



Comment at: clang/test/CodeGen/arm-mve-intrinsics/admin.c:66
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 
[[B:%.*]], i64 1
 // CHECK-NEXT:ret <2 x i64> [[TMP1]]
 //

MarkMurrayARM wrote:
> dmgreen wrote:
> > MarkMurrayARM wrote:
> > > Surely there is a problem here also?
> > I don't see why these would be a problem. Can you elaborate?
> I'm wondering if they need to be swapped in the BE case.
vcreateq is not endianness aware, it just inserts the two given 64 bit values 
`a` and `b` into the low and high lanes respectively. The bit representation of 
each 64 bit int will be different but that is not shown here. Therefore the IR 
is the same for big and little endian.

I have also confirmed locally with runtime output:
```
uint64x2_t w = vcreateq_u64(0x0001, 0x0002);
printf("%d:%llu\n", 0, vgetq_lane_u64(w, 0));
printf("%d:%llu\n", 1, vgetq_lane_u64(w, 1));
```
which gives for both little and bit endian (with this patch):
```
0:1
1:2
```



Comment at: clang/test/CodeGen/arm-mve-intrinsics/admin.c:116
 // CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 
[[B:%.*]], i64 1
 // CHECK-NEXT:ret <2 x i64> [[TMP1]]
 //

MarkMurrayARM wrote:
> And a problem here also (with BE)?
See above


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

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


[PATCH] D80932: [SYCL] Make default address space a superset of OpenCL address spaces.

2021-04-30 Thread Alexey Bader via Phabricator via cfe-commits
bader abandoned this revision.
bader added a comment.
Herald added a subscriber: ldrumm.

Committed alternative version - https://reviews.llvm.org/D89909.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80932

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


[PATCH] D101606: [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 341818.
tmatheson edited the summary of this revision.
tmatheson added a comment.

Use update_cc_test_checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/admin.c

Index: clang/test/CodeGen/arm-mve-intrinsics/admin.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/admin.c
+++ clang/test/CodeGen/arm-mve-intrinsics/admin.c
@@ -1,51 +1,82 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK-LE
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK-LE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK-BE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK-BE
+
 
 #include 
 
-// CHECK-LABEL: @test_vcreateq_f16(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
-// CHECK-NEXT:ret <8 x half> [[TMP2]]
+// CHECK-LE-LABEL: @test_vcreateq_f16(
+// CHECK-LE-NEXT:  entry:
+// CHECK-LE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-LE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
+// CHECK-LE-NEXT:ret <8 x half> [[TMP2]]
+//
+// CHECK-BE-LABEL: @test_vcreateq_f16(
+// CHECK-BE-NEXT:  entry:
+// CHECK-BE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-BE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <8 x half> @llvm.arm.mve.vreinterpretq.v8f16.v2i64(<2 x i64> [[TMP1]])
+// CHECK-BE-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vcreateq_f16(uint64_t a, uint64_t b)
 {
 return vcreateq_f16(a, b);
 }
 
-// CHECK-LABEL: @test_vcreateq_f32(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
-// CHECK-NEXT:ret <4 x float> [[TMP2]]
+// CHECK-LE-LABEL: @test_vcreateq_f32(
+// CHECK-LE-NEXT:  entry:
+// CHECK-LE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-LE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
+// CHECK-LE-NEXT:ret <4 x float> [[TMP2]]
+//
+// CHECK-BE-LABEL: @test_vcreateq_f32(
+// CHECK-BE-NEXT:  entry:
+// CHECK-BE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-BE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <4 x float> @llvm.arm.mve.vreinterpretq.v4f32.v2i64(<2 x i64> [[TMP1]])
+// CHECK-BE-NEXT:ret <4 x float> [[TMP2]]
 //
 float32x4_t test_vcreateq_f32(uint64_t a, uint64_t b)
 {
 return vcreateq_f32(a, b);
 }
 
-// CHECK-LABEL: @test_vcreateq_s16(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bi

[PATCH] D101606: [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: clang/test/CodeGen/arm-mve-intrinsics/admin.c:86
 
 // CHECK-LABEL: @test_vcreateq_s64(
 // CHECK-NEXT:  entry:

You have to remove the old checks - the script isn't very good at that.

What would probably be even better would be if it used 
--check-prefixes=CHECK,CHECK-LE. That way it should be able to common the 
snippets that don't change between LE and BE.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

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


[PATCH] D101526: [analyzer][StdLibraryFunctionsChecker] Add NoteTags for applied arg constraints

2021-04-30 Thread Gabor Marton via Phabricator via cfe-commits
martong planned changes to this revision.
martong marked 4 inline comments as done.
martong added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:836-837
+  NewState, NewNode,
+  C.getNoteTag([Msg](PathSensitiveBugReport &BR,
+ llvm::raw_ostream &OS) { OS << Msg; }));
 }

steakhal wrote:
> This way each and every applied constraint will be displayed even if the 
> given argument does not constitute to the bug condition.
> I recommend you branching within the lambda, on the interestingness of the 
> given argument constraint.
Okay, good point, thanks for the feedback! I am planning to change to this 
direction.



Comment at: 
clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp:16
+int test_note(int x, int y) {
+__single_val_1(x);  // expected-note{{Applied constraint: The 1st arg 
should be within the range [1, 1]}}
+return y / (1 - x); // expected-warning{{Division by zero}} \

NoQ wrote:
> This has to be a user-friendly message.
> * "Constraints" is compiler jargon.
> * We cannot afford shortening "argument" to "arg".
> * Generally, the less machine-generated it looks the better (":" is 
> definitely robotic).
Okay, thanks for your comment. I can make it to be more similar to the other 
notes we already have. What about this?
```
Assuming the 1st argument is within the range [1, 1]
```

> We cannot afford shortening "argument" to "arg".
I'd like to address this in another following patch if you don't mind.



Comment at: clang/test/Analysis/std-c-library-functions-arg-constraints.c:42
   int ret = isalnum(x);
+  // bugpath-note@-1{{Applied constraint: The 1st arg should be within the 
range [[-1, -1], [0, 255]]}}
   (void)ret;

NoQ wrote:
> This isn't part of this patch but what do you think about `{-1} U [0, 255]`? 
> Or, you know, `[-1, 255]`.
Yeah, good idea, `{-1} U [0, 255]` would be indeed nicer and shorter. However, 
`[-1, 255]` is hard(er) so I am going to start with the former in a follow up 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101526

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


[PATCH] D101606: [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 341819.
tmatheson added a comment.

remove old check lines that were not automatically removed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/admin.c

Index: clang/test/CodeGen/arm-mve-intrinsics/admin.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/admin.c
+++ clang/test/CodeGen/arm-mve-intrinsics/admin.c
@@ -1,301 +1,452 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK-LE
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK-LE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK-BE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefix=CHECK-BE
+
 
 #include 
 
-// CHECK-LABEL: @test_vcreateq_f16(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
-// CHECK-NEXT:ret <8 x half> [[TMP2]]
+// CHECK-LE-LABEL: @test_vcreateq_f16(
+// CHECK-LE-NEXT:  entry:
+// CHECK-LE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-LE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
+// CHECK-LE-NEXT:ret <8 x half> [[TMP2]]
+//
+// CHECK-BE-LABEL: @test_vcreateq_f16(
+// CHECK-BE-NEXT:  entry:
+// CHECK-BE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-BE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <8 x half> @llvm.arm.mve.vreinterpretq.v8f16.v2i64(<2 x i64> [[TMP1]])
+// CHECK-BE-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vcreateq_f16(uint64_t a, uint64_t b)
 {
 return vcreateq_f16(a, b);
 }
 
-// CHECK-LABEL: @test_vcreateq_f32(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
-// CHECK-NEXT:ret <4 x float> [[TMP2]]
+// CHECK-LE-LABEL: @test_vcreateq_f32(
+// CHECK-LE-NEXT:  entry:
+// CHECK-LE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-LE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
+// CHECK-LE-NEXT:ret <4 x float> [[TMP2]]
+//
+// CHECK-BE-LABEL: @test_vcreateq_f32(
+// CHECK-BE-NEXT:  entry:
+// CHECK-BE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-BE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <4 x float> @llvm.arm.mve.vreinterpretq.v4f32.v2i64(<2 x i64> [[TMP1]])
+// CHECK-BE-NEXT:ret <4 x float> [[TMP2]]
 //
 float32x4_t test_vcreateq_f32(uint64_t a, uint64_t b)
 {
 return vcreateq_f32(a, b);
 }
 
-// CHECK-LABEL: @test_vcreateq_s16(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i

[PATCH] D101611: [clangd][NFC] Remove unnecessary string captures in lambdas.

2021-04-30 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Due to a somewhat annoying, but necessary, shortfall in 
-Wunused-lambda-capture, These unused captures aren't warned about.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101611

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp


Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -575,8 +575,7 @@
   // Tracks number of times a tweak has been offered.
   static constexpr trace::Metric TweakAvailable(
   "tweak_available", trace::Metric::Counter, "tweak_id");
-  auto Action = [File = File.str(), Sel, CB = std::move(CB),
- Filter = std::move(Filter),
+  auto Action = [Sel, CB = std::move(CB), Filter = std::move(Filter),
  FeatureModules(this->FeatureModules)](
 Expected InpAST) mutable {
 if (!InpAST)
@@ -756,8 +755,7 @@
 
 void ClangdServer::inlayHints(PathRef File,
   Callback> CB) {
-  auto Action = [File = File.str(),
- CB = std::move(CB)](Expected InpAST) mutable {
+  auto Action = [CB = std::move(CB)](Expected InpAST) mutable {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::inlayHints(InpAST->AST));
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -725,8 +725,8 @@
 
 void ClangdLSPServer::onCommandApplyTweak(const TweakArgs &Args,
   Callback Reply) {
-  auto Action = [this, Reply = std::move(Reply),
- File = Args.file](llvm::Expected R) mutable {
+  auto Action = [this, Reply = std::move(Reply)](
+llvm::Expected R) mutable {
 if (!R)
   return Reply(R.takeError());
 


Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -575,8 +575,7 @@
   // Tracks number of times a tweak has been offered.
   static constexpr trace::Metric TweakAvailable(
   "tweak_available", trace::Metric::Counter, "tweak_id");
-  auto Action = [File = File.str(), Sel, CB = std::move(CB),
- Filter = std::move(Filter),
+  auto Action = [Sel, CB = std::move(CB), Filter = std::move(Filter),
  FeatureModules(this->FeatureModules)](
 Expected InpAST) mutable {
 if (!InpAST)
@@ -756,8 +755,7 @@
 
 void ClangdServer::inlayHints(PathRef File,
   Callback> CB) {
-  auto Action = [File = File.str(),
- CB = std::move(CB)](Expected InpAST) mutable {
+  auto Action = [CB = std::move(CB)](Expected InpAST) mutable {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::inlayHints(InpAST->AST));
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -725,8 +725,8 @@
 
 void ClangdLSPServer::onCommandApplyTweak(const TweakArgs &Args,
   Callback Reply) {
-  auto Action = [this, Reply = std::move(Reply),
- File = Args.file](llvm::Expected R) mutable {
+  auto Action = [this, Reply = std::move(Reply)](
+llvm::Expected R) mutable {
 if (!R)
   return Reply(R.takeError());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101515: clang-format: [JS] handle "off" in imports

2021-04-30 Thread Hana Joo via Phabricator via cfe-commits
h-joo accepted this revision.
h-joo 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/D101515/new/

https://reviews.llvm.org/D101515

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


[PATCH] D101606: [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 341823.
tmatheson added a comment.

Use --check-prefixes=CHECK,CHECK-BE etc to combine common blocks.
Sorry for the churn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/admin.c

Index: clang/test/CodeGen/arm-mve-intrinsics/admin.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/admin.c
+++ clang/test/CodeGen/arm-mve-intrinsics/admin.c
@@ -1,51 +1,82 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+
 
 #include 
 
-// CHECK-LABEL: @test_vcreateq_f16(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
-// CHECK-NEXT:ret <8 x half> [[TMP2]]
+// CHECK-LE-LABEL: @test_vcreateq_f16(
+// CHECK-LE-NEXT:  entry:
+// CHECK-LE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-LE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
+// CHECK-LE-NEXT:ret <8 x half> [[TMP2]]
+//
+// CHECK-BE-LABEL: @test_vcreateq_f16(
+// CHECK-BE-NEXT:  entry:
+// CHECK-BE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-BE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <8 x half> @llvm.arm.mve.vreinterpretq.v8f16.v2i64(<2 x i64> [[TMP1]])
+// CHECK-BE-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vcreateq_f16(uint64_t a, uint64_t b)
 {
 return vcreateq_f16(a, b);
 }
 
-// CHECK-LABEL: @test_vcreateq_f32(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
-// CHECK-NEXT:ret <4 x float> [[TMP2]]
+// CHECK-LE-LABEL: @test_vcreateq_f32(
+// CHECK-LE-NEXT:  entry:
+// CHECK-LE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-LE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
+// CHECK-LE-NEXT:ret <4 x float> [[TMP2]]
+//
+// CHECK-BE-LABEL: @test_vcreateq_f32(
+// CHECK-BE-NEXT:  entry:
+// CHECK-BE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-BE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <4 x float> @llvm.arm.mve.vreinterpretq.v4f32.v2i64(<2 x i64> [[TMP1]])
+// CHECK-BE-NEXT:ret <4 x float> [[TMP2]]
 //
 float32x4_t test_vcreateq_f32(uint64_t a, uint64_t b)
 {
 return vcreateq_f32(a, b);
 }
 
-// CHECK-LABEL: @test_vcreateq_s16(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*

[PATCH] D101606: [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

Thanks for the updates. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

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


[PATCH] D101606: [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson marked 2 inline comments as done.
tmatheson added a comment.

In D101606#2728320 , @dmgreen wrote:

> Sounds good to me.
>
> Whilst we are here, are any of the other uses of bitcast in arm_mve.td 
> potentially a problem? I took a quick look and because they both converting 
> the inputs and the outputs, I believe they will be OK. (Two wrongs make a 
> right, if you will).

I had a look and came to the same conclusion, I couldn't find any way to make 
them break. Worth noting that they are all converting between vectors with the 
same number of lanes, e.g. typically between the signed and unsigned versions 
of NxM vectors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

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


[clang] 109bf25 - [AArch64] Change __ARM_FEATURE_FP16FML macro name to __ARM_FEATURE_FP16_FML

2021-04-30 Thread Keith Walker via cfe-commits

Author: Keith Walker
Date: 2021-04-30T11:03:15+01:00
New Revision: 109bf25e2c425ea5dd20836f25176cf9d9479016

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

LOG: [AArch64] Change __ARM_FEATURE_FP16FML macro name to  
__ARM_FEATURE_FP16_FML

The "Arm C Language extensions" document (the current version can be
found at https://developer.arm.com/documentation/101028/0012/?lang=en)
states that the name of the feature test macro for the FP16 FML extension
is __ARM_FEATURE_FP16_FML.

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

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/Basic/Targets/AArch64.cpp
clang/test/Preprocessor/aarch64-target-features.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index fdd82692223c3..173003d171eea 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -1889,7 +1889,7 @@ let ArchGuard = "defined(__ARM_FEATURE_DOTPROD) && 
defined(__aarch64__)" in {
 }
 
 // v8.2-A FP16 fused multiply-add long instructions.
-let ArchGuard = "defined(__ARM_FEATURE_FP16FML) && defined(__aarch64__)" in {
+let ArchGuard = "defined(__ARM_FEATURE_FP16_FML) && defined(__aarch64__)" in {
   def VFMLAL_LOW  : SInst<"vfmlal_low",  ">>..", "hQh">;
   def VFMLSL_LOW  : SInst<"vfmlsl_low",  ">>..", "hQh">;
   def VFMLAL_HIGH : SInst<"vfmlal_high", ">>..", "hQh">;

diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 270b03a218fc2..d26ae943b2e8a 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -352,7 +352,7 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Builder.defineMacro("__ARM_FEATURE_SVE_MATMUL_INT8", "1");
 
   if ((FPU & NeonMode) && HasFP16FML)
-Builder.defineMacro("__ARM_FEATURE_FP16FML", "1");
+Builder.defineMacro("__ARM_FEATURE_FP16_FML", "1");
 
   if (Opts.hasSignReturnAddress()) {
 // Bitmask:

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 0e27b91349084..fa9b80b7de4ab 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -207,8 +207,8 @@
 // RUN: %clang -target aarch64-none-linux-gnueabi 
-march=armv8.4-a+fp16+nofp16fml -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=CHECK-FULLFP16-NOFML 
--check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16fml -x 
c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16 -x c 
-E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML 
--check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
-// CHECK-FULLFP16-FML:   #define __ARM_FEATURE_FP16FML 1
-// CHECK-FULLFP16-NOFML-NOT: #define __ARM_FEATURE_FP16FML 1
+// CHECK-FULLFP16-FML:   #define __ARM_FEATURE_FP16_FML 1
+// CHECK-FULLFP16-NOFML-NOT: #define __ARM_FEATURE_FP16_FML 1
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FP 0xE
@@ -220,7 +220,7 @@
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8-a+fp16+nosimd 
-x c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi 
-march=armv8.4-a+fp16fml+nosimd -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=CHECK-FULLFP16-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16+nosimd 
-x c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-SCALAR %s
-// CHECK-FULLFP16-SCALAR-NOT:   #define __ARM_FEATURE_FP16FML 1
+// CHECK-FULLFP16-SCALAR-NOT:   #define __ARM_FEATURE_FP16_FML 1
 // CHECK-FULLFP16-SCALAR:   #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
 // CHECK-FULLFP16-SCALAR-NOT:   #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
 // CHECK-FULLFP16-SCALAR:   #define __ARM_FP 0xE
@@ -234,7 +234,7 @@
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+nofp16 -x c 
-E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+nofp16fml 
-x c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi 
-march=armv8.4-a+fp16fml+nofp16 -x c 

[PATCH] D101532: [AArch64] Change __ARM_FEATURE_FP16FML macro name to __ARM_FEATURE_FP16_FML

2021-04-30 Thread Keith Walker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG109bf25e2c42: [AArch64] Change __ARM_FEATURE_FP16FML macro 
name to  __ARM_FEATURE_FP16_FML (authored by keith.walker.arm).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101532

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/Preprocessor/aarch64-target-features.c


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -207,8 +207,8 @@
 // RUN: %clang -target aarch64-none-linux-gnueabi 
-march=armv8.4-a+fp16+nofp16fml -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=CHECK-FULLFP16-NOFML 
--check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16fml -x 
c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16 -x c 
-E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML 
--check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
-// CHECK-FULLFP16-FML:   #define __ARM_FEATURE_FP16FML 1
-// CHECK-FULLFP16-NOFML-NOT: #define __ARM_FEATURE_FP16FML 1
+// CHECK-FULLFP16-FML:   #define __ARM_FEATURE_FP16_FML 1
+// CHECK-FULLFP16-NOFML-NOT: #define __ARM_FEATURE_FP16_FML 1
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FP 0xE
@@ -220,7 +220,7 @@
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8-a+fp16+nosimd 
-x c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi 
-march=armv8.4-a+fp16fml+nosimd -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=CHECK-FULLFP16-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16+nosimd 
-x c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-SCALAR %s
-// CHECK-FULLFP16-SCALAR-NOT:   #define __ARM_FEATURE_FP16FML 1
+// CHECK-FULLFP16-SCALAR-NOT:   #define __ARM_FEATURE_FP16_FML 1
 // CHECK-FULLFP16-SCALAR:   #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
 // CHECK-FULLFP16-SCALAR-NOT:   #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
 // CHECK-FULLFP16-SCALAR:   #define __ARM_FP 0xE
@@ -234,7 +234,7 @@
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+nofp16 -x c 
-E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+nofp16fml 
-x c -E -dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s
 // RUN: %clang -target aarch64-none-linux-gnueabi 
-march=armv8.4-a+fp16fml+nofp16 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=CHECK-FULLFP16-NOFML-VECTOR-SCALAR %s
-// CHECK-FULLFP16-NOFML-VECTOR-SCALAR-NOT: #define __ARM_FEATURE_FP16FML 1
+// CHECK-FULLFP16-NOFML-VECTOR-SCALAR-NOT: #define __ARM_FEATURE_FP16_FML 1
 // CHECK-FULLFP16-NOFML-VECTOR-SCALAR-NOT: #define 
__ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
 // CHECK-FULLFP16-NOFML-VECTOR-SCALAR-NOT: #define 
__ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
 // CHECK-FULLFP16-NOFML-VECTOR-SCALAR: #define __ARM_FP 0xE
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -352,7 +352,7 @@
 Builder.defineMacro("__ARM_FEATURE_SVE_MATMUL_INT8", "1");
 
   if ((FPU & NeonMode) && HasFP16FML)
-Builder.defineMacro("__ARM_FEATURE_FP16FML", "1");
+Builder.defineMacro("__ARM_FEATURE_FP16_FML", "1");
 
   if (Opts.hasSignReturnAddress()) {
 // Bitmask:
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -1889,7 +1889,7 @@
 }
 
 // v8.2-A FP16 fused multiply-add long instructions.
-let ArchGuard = "defined(__ARM_FEATURE_FP16FML) && defined(__aarch64__)" in {
+let ArchGuard = "defined(__ARM_FEATURE_FP16_FML) && defined(__aarch64__)" in {
   def VFMLAL_LOW  : SInst<"vfmlal_low",  ">>..", "hQh">;
   def VFMLSL_LOW  : SInst<"vfmlsl_low",  ">>..", "hQh">;
   def VFMLAL_HIGH : SInst<"vfmlal_high", ">>..", "hQh">;


Index: clang/test/Preprocessor/aarch64-target-features.c
==

[PATCH] D101611: [clangd][NFC] Remove unnecessary string captures in lambdas.

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

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101611

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


[PATCH] D101168: [C++4OpenCL] Add clang extension for non-portable kernel parameters

2021-04-30 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 341831.
olestrohm added a comment.

Fixed merge error


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

https://reviews.llvm.org/D101168

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Misc/amdgcn.languageOptsOpenCL.cl
  clang/test/Misc/nvptx.languageOptsOpenCL.cl
  clang/test/Misc/r600.languageOptsOpenCL.cl
  clang/test/SemaOpenCLCXX/invalid-kernel.clcpp

Index: clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
===
--- clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
+++ clang/test/SemaOpenCLCXX/invalid-kernel.clcpp
@@ -1,4 +1,9 @@
-// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only -triple spir-unknown-unknown -DUNSAFEKERNELPARAMETER
+
+#ifdef UNSAFEKERNELPARAMETER
+#pragma OPENCL EXTENSION __cl_clang_non_portable_kernel_parameters : enable
+#endif
 
 struct C {
   kernel void m(); //expected-error{{kernel functions cannot be class members}}
@@ -24,8 +29,10 @@
 kernel void int_p_r(__global int *__global &in);
 kernel void int_p_p_r(__global int *__global *__global &in);
 
-// expected-error@+1{{'__private atomic_int' (aka '__private _Atomic(int)') cannot be used as the type of a kernel parameter}}
 kernel void k_atomic_v(atomic_int in);
+#ifndef UNSAFEKERNELPARAMETER
+// expected-error@-2{{'__private atomic_int' (aka '__private _Atomic(int)') cannot be used as the type of a kernel parameter}}
+#endif
 kernel void k_atomic_p(__global atomic_int *in);
 kernel void k_atomic_r(__global atomic_int &in);
 
@@ -56,7 +63,10 @@
   StandardLayout(int a, int b) : a(a), b(b) {}
 };
 
-kernel void standard_v(StandardLayout in) {} //expected-error{{'__private StandardLayout' cannot be used as the type of a kernel parameter}}
+kernel void standard_v(StandardLayout in) {}
+#ifndef UNSAFEKERNELPARAMETER
+//expected-error@-2{{'__private StandardLayout' cannot be used as the type of a kernel parameter}}
+#endif
 kernel void standard_p(__global StandardLayout *in) {}
 kernel void standard_p_p(__global StandardLayout *__global *in) {}
 kernel void standard_r(__global StandardLayout &in) {}
@@ -67,7 +77,19 @@
   int b;
 };
 
-kernel void trivial_v(Trivial in) {} //expected-error{{'__private Trivial' cannot be used as the type of a kernel parameter}}
-kernel void trivial_p(__global Trivial *in) {} //expected-error{{'__global Trivial *__private' cannot be used as the type of a kernel parameter}}
-kernel void trivial_p_p(__global Trivial *__global *in) {} //expected-error{{'__global Trivial *__global *__private' cannot be used as the type of a kernel parameter}}
-kernel void trivial_r(__global Trivial &in) {} //expected-error{{'__global Trivial &__private' cannot be used as the type of a kernel parameter}}
+kernel void trivial_v(Trivial in) {}
+#ifndef UNSAFEKERNELPARAMETER
+//expected-error@-2{{'__private Trivial' cannot be used as the type of a kernel parameter}}
+#endif
+kernel void trivial_p(__global Trivial *in) {}
+#ifndef UNSAFEKERNELPARAMETER
+//expected-error@-2{{'__global Trivial *__private' cannot be used as the type of a kernel parameter}}
+#endif
+kernel void trivial_p_p(__global Trivial *__global *in) {}
+#ifndef UNSAFEKERNELPARAMETER
+//expected-error@-2{{'__global Trivial *__global *__private' cannot be used as the type of a kernel parameter}}
+#endif
+kernel void trivial_r(__global Trivial &in) {}
+#ifndef UNSAFEKERNELPARAMETER
+//expected-error@-2{{'__global Trivial &__private' cannot be used as the type of a kernel parameter}}
+#endif
Index: clang/test/Misc/r600.languageOptsOpenCL.cl
===
--- clang/test/Misc/r600.languageOptsOpenCL.cl
+++ clang/test/Misc/r600.languageOptsOpenCL.cl
@@ -34,6 +34,11 @@
 #endif
 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
 
+#ifndef __cl_clang_non_portable_kernel_parameters
+#error "Missing __cl_clang_non_portable_kernel_parameters define"
+#endif
+#pragma OPENCL EXTENSION __cl_clang_non_portable_kernel_parameters : enable
+
 #ifdef cl_khr_fp16
 #error "Incorrect cl_khr_fp16 define"
 #endif
Index: clang/test/Misc/nvptx.languageOptsOpenCL.cl
===
--- clang/test/Misc/nvptx.languageOptsOpenCL.cl
+++ clang/test/Misc/nvptx.languageOptsOpenCL.cl
@@ -28,6 +28,11 @@
 #endif
 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
 
+#ifndef __cl_clang_non_portable_kernel_parameters
+#error "Missing __cl_clang_non_portable_kernel_parameters define"
+#endif
+#pragma OPENCL EXTENSION __cl_clang_non_portable_kernel_parameters : enable
+
 #ifdef cl_khr_fp16
 #error "Incorrect cl_khr_fp16 define"
 #endif
Index: clang/test/Misc/amdgcn.la

[PATCH] D101462: Make it possible for targets to define their own MCObjectFileInfo

2021-04-30 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

> The refactoring adding `Triple` to `MCContext::MCContext` [...] should be 
> separate.

In order to make the `MCContext` construction independent from the 
`MCObjectFileInfo`, passing the `Triple` to the `MCContext` is necessary 
anyway. Moving it completely to the `MCContext` was just the logical next step 
for me. It also simplifies calls across the code base since it removes an 
indirection over `MOFI` when accessing the triple.

I'll update this on Monday 👍


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

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


[PATCH] D69498: IR: Invert convergent attribute handling

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

I wonder if it is necessary for the exec mask to be implicit state, managed by 
a convergent/divergent abstraction.

We could reify it as an argument passed to kernels (where all bits are set), 
and adjusted by phi nodes at entry to basic blocks. Various intrinsics take and 
return that reified value. __ballot, a comparison op, possibly load/store.

At that point all the awkward control flow constraints are raised to data flow, 
and I think (but haven't really chased this into the dark corners) that solves 
the problems I know about. Notably, a uniform branch would be one where the 
exec mask value was unchanged, so the associated phi is constant folded.

Makes a mess of the human readable IR, but possibly at a lower overall 
complexity than continuing to handle divergence as control flow.


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

https://reviews.llvm.org/D69498

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


[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

2021-04-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 341833.
Anastasia added a comment.

- Added a pedantic warning about use of double even if the extension is in 
disabled state wrt pragma.


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

https://reviews.llvm.org/D100980

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Misc/warning-flags.c
  clang/test/SemaOpenCL/extensions.cl

Index: clang/test/SemaOpenCL/extensions.cl
===
--- clang/test/SemaOpenCL/extensions.cl
+++ clang/test/SemaOpenCL/extensions.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL1.1 -DNOPEDANTIC
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64
 
 // Test with a target not supporting fp64.
@@ -43,8 +44,20 @@
 #endif
 
 #if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120)
-void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 support}}
-  double d; // expected-error {{type 'double' requires cl_khr_fp64 support}}
+void f1(double da) {
+#ifdef NOFP64
+// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}}
+#elif !defined(NOPEDANTIC)
+// expected-warning@-4{{Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is supported}}
+#endif
+  double d;
+#ifdef NOFP64
+// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}}
+#elif !defined(NOPEDANTIC)
+// expected-warning@-4{{Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is supported}}
+#endif
+  // FIXME: this diagnostic depends on the extension pragma in the earlier versions.
+  // There is no indication that this behavior is expected. 
   (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
 }
 #endif
@@ -79,13 +92,11 @@
   double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f};
 #ifdef NOFP64
 // expected-error@-3 {{use of type 'double' requires cl_khr_fp64 support}}
-// expected-error@-3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 support}}
 #endif
 
   (void) 1.0;
-
 #ifdef NOFP64
-// expected-warning@-3{{double precision constant requires cl_khr_fp64, casting to single precision}}
+// expected-warning@-2{{double precision constant requires cl_khr_fp64, casting to single precision}}
 #endif
 }
 
@@ -96,6 +107,11 @@
 
 #if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120)
 void f3(void) {
-  double d; // expected-error {{type 'double' requires cl_khr_fp64 support}}
+  double d;
+#ifdef NOFP64
+// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}}
+#elif !defined(NOPEDANTIC)
+// expected-warning@-4 {{Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is supported}}
+#endif
 }
 #endif
Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -91,4 +91,4 @@
 
 The list of warnings in -Wpedantic should NEVER grow.
 
-CHECK: Number in -Wpedantic (not covered by other -W flags): 26
+CHECK: Number in -Wpedantic (not covered by other -W flags): 27
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1524,6 +1524,13 @@
 break;
   case DeclSpec::TST_float:   Result = Context.FloatTy; break;
   case DeclSpec::TST_double:
+if (S.getLangOpts().OpenCL) {
+  if (!S.getOpenCLOptions().isSupported("cl_khr_fp64", S.getLangOpts()))
+S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
+  << 0 << Context.DoubleTy << "cl_khr_fp64";
+  else if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp64", S.getLangOpts()))
+S.Diag(DS.getTypeSpecTypeLoc(), diag::ext_opencl_double_without_pragma);
+}
 if (DS.getTypeSpecWidth() == TypeSpecifierWidth::Long)
   Result = Context.LongDoubleTy;
 else
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -365,7 +365,6 @@
   }
 }
 
-setOpenCLExtensionForType(Context.DoubleTy, "cl_khr_fp64");
 
 #define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) \
 setOpenCLExtensionForType(Context.Id, Ext);
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10003,6 +10003,8 @@
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
 def err_opencl_requires_extensi

[PATCH] D101515: clang-format: [JS] handle "off" in imports

2021-04-30 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added inline comments.



Comment at: clang/lib/Format/SortJavaScriptImports.cpp:257
+// references per group.
+auto *Start = References.begin();
+SmallVector ReferencesSorted;

please fix lint warning on line 257


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101515

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


[PATCH] D100983: [OpenCL] Fix optional image types

2021-04-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 341835.
Anastasia added a comment.

Test all image types as identifiers


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

https://reviews.llvm.org/D100983

Files:
  clang/include/clang/Basic/OpenCLImageTypes.def
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/access-qualifier.cl
  clang/test/SemaOpenCL/invalid-image.cl

Index: clang/test/SemaOpenCL/invalid-image.cl
===
--- clang/test/SemaOpenCL/invalid-image.cl
+++ clang/test/SemaOpenCL/invalid-image.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -verify -cl-std=clc++ %s
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -cl-ext=+cl_khr_gl_msaa_sharing
+// RUN: %clang_cc1 -verify %s -cl-ext=-cl_khr_gl_msaa_sharing
 // RUN: %clang_cc1 -verify -D=ATTR_TEST -fms-compatibility %s
 
 void test1(image1d_t *i) {} // expected-error-re{{pointer to type '{{__generic __read_only|__read_only}} image1d_t' is invalid in OpenCL}}
@@ -19,3 +20,20 @@
 // Test case for an infinite loop bug.
 kernel void foob(read_only __ptr32  image2d_t i) { } // expected-error{{'__ptr32' attribute only applies to pointer arguments}}
 #endif
+
+typedef int image1d_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image2d_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image3d_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image1d_array_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image2d_array_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image2d_depth_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image1d_buffer_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+
+#ifndef cl_khr_gl_msaa_sharing
+// Image types from 'cl_khr_gl_msaa_sharing' are not reserved identifiers.
+typedef int image2d_msaa_t;
+typedef int image2d_array_msaa_t;
+typedef int image2d_msaa_depth_t;
+typedef int image2d_array_msaa_depth_t;
+#endif
+void foo(image2d_msaa_t i);
Index: clang/test/SemaOpenCL/access-qualifier.cl
===
--- clang/test/SemaOpenCL/access-qualifier.cl
+++ clang/test/SemaOpenCL/access-qualifier.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL1.2 %s
+// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL1.2 %s -cl-ext=-cl_khr_3d_image_writes
 // RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
 
 typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read_only' here}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1714,12 +1714,20 @@
 break;
   }
 
+
   // FIXME: we want resulting declarations to be marked invalid, but claiming
   // the type is invalid is too strong - e.g. it causes ActOnTypeName to return
   // a null type.
   if (Result->containsErrors())
 declarator.setInvalidType();
 
+  if (S.getLangOpts().OpenCL && Result->isOCLImage3dWOType() &&
+  !S.getOpenCLOptions().isSupported("cl_khr_3d_image_writes", S.getLangOpts())) {
+S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
+<< 0 << Result << "cl_khr_3d_image_writes";
+declarator.setInvalidType();
+  }
+
   if (S.getLangOpts().OpenCL &&
   S.checkOpenCLDisabledTypeDeclSpec(DS, Result))
 declarator.setInvalidType(true);
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -366,9 +366,6 @@
 }
 
 
-#define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) \
-setOpenCLExtensionForType(Context.Id, Ext);
-#include "clang/Basic/OpenCLImageTypes.def"
 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext)  \
   if (getOpenCLOptions().isSupported(#Ext, getLangOpts())) {   \
 addImplicitTypedef(#ExtType, Context.Id##Ty);  \
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3071,6 +3071,19 @@
 
 SourceLocation Loc = Tok.getLocation();
 
+// Helper for image types in OpenCL.
+auto handleOpenCLImageKW = [&] (StringRef Ext, TypeSpecifi

[PATCH] D101614: [clang-tidy][NFC] Simplify a lot of bugprone-sizeof-expression matchers

2021-04-30 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: steveire, aaron.ballman.
Herald added a subscriber: xazax.hun.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

There should be a follow up to this for changing the traversal mode, but some 
of the tests don't like that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101614

Files:
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp

Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -84,19 +84,16 @@
   // positives if sizeof is applied on template argument.
 
   const auto IntegerExpr = ignoringParenImpCasts(integerLiteral());
-  const auto ConstantExpr = expr(ignoringParenImpCasts(
+  const auto ConstantExpr = ignoringParenImpCasts(
   anyOf(integerLiteral(), unaryOperator(hasUnaryOperand(IntegerExpr)),
-binaryOperator(hasLHS(IntegerExpr), hasRHS(IntegerExpr);
-  const auto IntegerCallExpr = expr(ignoringParenImpCasts(
+binaryOperator(hasLHS(IntegerExpr), hasRHS(IntegerExpr;
+  const auto IntegerCallExpr = ignoringParenImpCasts(
   callExpr(anyOf(hasType(isInteger()), hasType(enumType())),
-   unless(isInTemplateInstantiation();
-  const auto SizeOfExpr = expr(anyOf(
-  sizeOfExpr(
-  has(hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type",
-  sizeOfExpr(has(expr(hasType(
-  hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type";
-  const auto SizeOfZero = expr(
-  sizeOfExpr(has(ignoringParenImpCasts(expr(integerLiteral(equals(0)));
+   unless(isInTemplateInstantiation(;
+  const auto SizeOfExpr = sizeOfExpr(hasArgumentOfType(
+  hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type";
+  const auto SizeOfZero =
+  sizeOfExpr(has(ignoringParenImpCasts(integerLiteral(equals(0);
 
   // Detect expression like: sizeof(ARRAYLEN);
   // Note: The expression 'sizeof(sizeof(0))' is a portable trick used to know
@@ -111,74 +108,69 @@
 
   // Detect sizeof(f())
   if (WarnOnSizeOfIntegerExpression) {
-Finder->addMatcher(
-expr(sizeOfExpr(ignoringParenImpCasts(has(IntegerCallExpr
-.bind("sizeof-integer-call"),
-this);
+Finder->addMatcher(sizeOfExpr(ignoringParenImpCasts(has(IntegerCallExpr)))
+   .bind("sizeof-integer-call"),
+   this);
   }
 
   // Detect expression like: sizeof(this);
   if (WarnOnSizeOfThis) {
-Finder->addMatcher(
-expr(sizeOfExpr(has(ignoringParenImpCasts(expr(cxxThisExpr())
-.bind("sizeof-this"),
-this);
+Finder->addMatcher(sizeOfExpr(has(ignoringParenImpCasts(cxxThisExpr(
+   .bind("sizeof-this"),
+   this);
   }
 
   // Detect sizeof(kPtr) where kPtr is 'const char* kPtr = "abc"';
   const auto CharPtrType = pointerType(pointee(isAnyCharacter()));
   const auto ConstStrLiteralDecl =
-  varDecl(isDefinition(), hasType(qualType(hasCanonicalType(CharPtrType))),
+  varDecl(isDefinition(), hasType(hasCanonicalType(CharPtrType)),
   hasInitializer(ignoringParenImpCasts(stringLiteral(;
-  Finder->addMatcher(expr(sizeOfExpr(has(ignoringParenImpCasts(expr(
-  hasType(qualType(hasCanonicalType(CharPtrType))),
-  ignoringParenImpCasts(declRefExpr(
-  hasDeclaration(ConstStrLiteralDecl
- .bind("sizeof-charp"),
- this);
+  Finder->addMatcher(
+  sizeOfExpr(has(ignoringParenImpCasts(
+ expr(hasType(hasCanonicalType(CharPtrType)),
+  ignoringParenImpCasts(declRefExpr(
+  hasDeclaration(ConstStrLiteralDecl)))
+  .bind("sizeof-charp"),
+  this);
 
   // Detect sizeof(ptr) where ptr points to an aggregate (i.e. sizeof(&S)).
   // Do not find it if RHS of a 'sizeof(arr) / sizeof(arr[0])' expression.
-  const auto ArrayExpr = expr(ignoringParenImpCasts(
-  expr(hasType(qualType(hasCanonicalType(arrayType()));
+  const auto ArrayExpr =
+  ignoringParenImpCasts(hasType(hasCanonicalType(arrayType(;
   const auto ArrayCastExpr = expr(anyOf(
   unaryOperator(hasUnaryOperand(ArrayExpr), unless(hasOperatorName("*"))),
   binaryOperator(hasEitherOperand(ArrayExpr)),
   castExpr(hasSourceExpression(ArrayExpr;
-  const auto PointerToArrayExpr = expr(ignoringParenImpCasts(expr(
-  hasType(qualType(hasCanonicalType(pointerType(pointee(arrayType();
-
-  const auto StructAddrOfExpr =
-  unaryOperator(hasOperatorName("&"),
-  

[PATCH] D100983: [OpenCL] Fix optional image types

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



Comment at: clang/include/clang/Basic/OpenCLImageTypes.def:68
 IMAGE_WRITE_TYPE(image2d_array_msaa_depth, OCLImage2dArrayMSAADepth, 
"cl_khr_gl_msaa_sharing")
-IMAGE_WRITE_TYPE(image3d, OCLImage3d, "cl_khr_3d_image_writes")
+IMAGE_WRITE_TYPE(image3d, OCLImage3d, "")
 

azabaznov wrote:
> Anastasia wrote:
> > azabaznov wrote:
> > > Maybe we should add a test to check that` image3d_t`  is reserved?
> > Do you mean something like:
> > 
> > ```typedef int image3d_t;```
> > 
> > And then check that this gives an error?
> Yes, exactly. But currently there is already an expected behaviour: 
> https://godbolt.org/z/4afjf5brn. I don't think that your patch changes that, 
> but still, it's good to add a test since you are removing 
> `cl_khr_3d_image_writes` from image descriptions.
Improving testing is always desirable. I have added testing for all image types 
that are implemented in clang now.

>  I don't think that your patch changes that, but still, it's good to add a 
> test since you are removing cl_khr_3d_image_writes from image descriptions.

Technically I am moving it elsewhere so it is no longer needed here. :)


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

https://reviews.llvm.org/D100983

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


[PATCH] D100983: [OpenCL] Fix optional image types

2021-04-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 341842.
Anastasia added a comment.

Improved negative testing for `cl_khr_gl_msaa_sharing`


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

https://reviews.llvm.org/D100983

Files:
  clang/include/clang/Basic/OpenCLImageTypes.def
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/access-qualifier.cl
  clang/test/SemaOpenCL/invalid-image.cl

Index: clang/test/SemaOpenCL/invalid-image.cl
===
--- clang/test/SemaOpenCL/invalid-image.cl
+++ clang/test/SemaOpenCL/invalid-image.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -verify -cl-std=clc++ %s
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -cl-ext=+cl_khr_gl_msaa_sharing
+// RUN: %clang_cc1 -verify %s -cl-ext=-cl_khr_gl_msaa_sharing
 // RUN: %clang_cc1 -verify -D=ATTR_TEST -fms-compatibility %s
 
 void test1(image1d_t *i) {} // expected-error-re{{pointer to type '{{__generic __read_only|__read_only}} image1d_t' is invalid in OpenCL}}
@@ -19,3 +20,24 @@
 // Test case for an infinite loop bug.
 kernel void foob(read_only __ptr32  image2d_t i) { } // expected-error{{'__ptr32' attribute only applies to pointer arguments}}
 #endif
+
+typedef int image1d_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image2d_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image3d_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image1d_array_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image2d_array_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image2d_depth_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+typedef int image1d_buffer_t; // expected-error{{cannot combine with previous 'int' declaration specifier}} expected-warning{{typedef requires a name}}
+
+// Image types from 'cl_khr_gl_msaa_sharing' are not reserved identifiers.
+typedef int image2d_msaa_t;
+typedef int image2d_array_msaa_t;
+typedef int image2d_msaa_depth_t;
+typedef int image2d_array_msaa_depth_t;
+#ifdef cl_khr_gl_msaa_sharing
+// expected-error@-5{{cannot combine with previous 'int' declaration specifier}} expected-warning@-5{{typedef requires a name}}
+// expected-error@-5{{cannot combine with previous 'int' declaration specifier}} expected-warning@-5{{typedef requires a name}}
+// expected-error@-5{{cannot combine with previous 'int' declaration specifier}} expected-warning@-5{{typedef requires a name}}
+// expected-error@-5{{cannot combine with previous 'int' declaration specifier}} expected-warning@-5{{typedef requires a name}}
+#endif
+void foo(image2d_msaa_t i);
Index: clang/test/SemaOpenCL/access-qualifier.cl
===
--- clang/test/SemaOpenCL/access-qualifier.cl
+++ clang/test/SemaOpenCL/access-qualifier.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL1.2 %s
+// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL1.2 %s -cl-ext=-cl_khr_3d_image_writes
 // RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s
 
 typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read_only' here}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1720,6 +1720,13 @@
   if (Result->containsErrors())
 declarator.setInvalidType();
 
+  if (S.getLangOpts().OpenCL && Result->isOCLImage3dWOType() &&
+  !S.getOpenCLOptions().isSupported("cl_khr_3d_image_writes", S.getLangOpts())) {
+S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
+<< 0 << Result << "cl_khr_3d_image_writes";
+declarator.setInvalidType();
+  }
+
   if (S.getLangOpts().OpenCL &&
   S.checkOpenCLDisabledTypeDeclSpec(DS, Result))
 declarator.setInvalidType(true);
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -366,9 +366,6 @@
 }
 
 
-#define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) \
-setOpenCLExtensionForType(Context.Id, Ext);
-#include "clang/Basic/OpenCLImageTypes.def"
 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext)  \
   if (getOpenCLOptions().isSupported(#Ext, getLangOpts())) {   \
 addImplicitTypedef(#ExtType, Context.Id##Ty);  \
Index: clang/lib/

[PATCH] D101549: [Doc] Fix sphynx warnings about wrong code-block format

2021-04-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia 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/D101549/new/

https://reviews.llvm.org/D101549

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


[PATCH] D101519: [C++4OpenCL] Fix reinterpret_cast of vectors and types with address spaces

2021-04-30 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 341844.
olestrohm added a comment.

Fixed formatting.


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

https://reviews.llvm.org/D101519

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenOpenCLCXX/reinterpret_cast.clcpp
  clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp

Index: clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+
+typedef int int2 __attribute__((ext_vector_type(2)));
+
+kernel void foo() {
+  long x;
+  auto x2 = reinterpret_cast(x);
+  int2 y;
+  auto y2 = reinterpret_cast(y);
+  auto y3 = reinterpret_cast(y); // expected-error{{reinterpret_cast from vector 'int2' (vector of 2 'int' values) to scalar 'int' of different size}}
+
+  __private int i;
+  auto i2 = reinterpret_cast<__private int>(i);
+  auto i3 = reinterpret_cast(i);
+
+  reserve_id_t z;
+  auto z2 = reinterpret_cast(z); // expected-error{{reinterpret_cast from 'reserve_id_t' to 'reserve_id_t' is not allowed}}
+}
Index: clang/test/CodeGenOpenCLCXX/reinterpret_cast.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/reinterpret_cast.clcpp
@@ -0,0 +1,15 @@
+//RUN: %clang_cc1 %s -triple spir -emit-llvm -O0 -o - | FileCheck %s
+
+typedef int int2 __attribute__((ext_vector_type(2)));
+
+//CHECK-LABEL: define{{.*}} spir_func void @_Z3barPU3AS1Dv2_i
+void bar(global int2 *vec) {
+  //CHECK: load i32, i32* %x, align 4
+  //CHECK: store i32 %{{[0-9]+}}, i32* %y, align 4
+  int x;
+  auto y = reinterpret_cast<__private int>(x);
+  //CHECK: bitcast <2 x i32> %{{[0-9]+}} to i64
+  auto lv = reinterpret_cast(vec[0]);
+  //CHECK: bitcast i64 %{{[0-9]+}} to <2 x i32>
+  auto vec0 = reinterpret_cast(lv);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7344,6 +7344,25 @@
  matSrcType->getNumColumns() == matDestType->getNumColumns();
 }
 
+bool Sema::areVectorTypesSameSize(QualType srcTy, QualType destTy) {
+  assert(destTy->isVectorType() || srcTy->isVectorType());
+
+  uint64_t srcLen, destLen;
+  QualType srcEltTy, destEltTy;
+  if (!breakDownVectorType(srcTy, srcLen, srcEltTy))
+return false;
+  if (!breakDownVectorType(destTy, destLen, destEltTy))
+return false;
+
+  // ASTContext::getTypeSize will return the size rounded up to a
+  // power of 2, so instead of using that, we need to use the raw
+  // element size multiplied by the element count.
+  uint64_t srcEltSize = Context.getTypeSize(srcEltTy);
+  uint64_t destEltSize = Context.getTypeSize(destEltTy);
+
+  return (srcLen * srcEltSize == destLen * destEltSize);
+}
+
 /// Are the two types lax-compatible vector types?  That is, given
 /// that one of them is a vector, do they have equal storage sizes,
 /// where the storage size is the number of elements times the element
@@ -7362,18 +7381,7 @@
   if (srcTy->isScalarType() && destTy->isExtVectorType()) return false;
   if (destTy->isScalarType() && srcTy->isExtVectorType()) return false;
 
-  uint64_t srcLen, destLen;
-  QualType srcEltTy, destEltTy;
-  if (!breakDownVectorType(srcTy, srcLen, srcEltTy)) return false;
-  if (!breakDownVectorType(destTy, destLen, destEltTy)) return false;
-
-  // ASTContext::getTypeSize will return the size rounded up to a
-  // power of 2, so instead of using that, we need to use the raw
-  // element size multiplied by the element count.
-  uint64_t srcEltSize = Context.getTypeSize(srcEltTy);
-  uint64_t destEltSize = Context.getTypeSize(destEltTy);
-
-  return (srcLen * srcEltSize == destLen * destEltSize);
+  return areVectorTypesSameSize(srcTy, destTy);
 }
 
 /// Is this a legal conversion between two types, one of which is
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2328,6 +2328,15 @@
   return TC_Success;
 }
 
+if (Self.LangOpts.OpenCL && !CStyle) {
+  if (DestType->isExtVectorType() || SrcType->isExtVectorType()) {
+if (Self.areVectorTypesSameSize(SrcType, DestType)) {
+  Kind = CK_BitCast;
+  return TC_Success;
+}
+  }
+}
+
 // Otherwise, pick a reasonable diagnostic.
 if (!destIsVector)
   msg = diag::err_bad_cxx_cast_vector_to_scalar_different_size;
@@ -2339,7 +2348,10 @@
 return TC_Failed;
   }
 
-  if (SrcType == DestType) {
+  if (SrcType == DestType ||
+  (Self.LangOpts.OpenCL &&
+   Self.Context.removeAddrSpaceQualType(SrcType) ==
+   Self.Context.removeAddrSpaceQualType(DestType))) {
 // C++ 5.2.10p2 has a note that mentions that, subject 

[PATCH] D101566: Let -Wweak-template-vtables warn on implicit instantiations

2021-04-30 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 341845.
aaronpuchert added a comment.

- Fix punctuation in expected warning message.
- Fix test failure: the instantiated class might not be a template, it could 
also be the member of another template.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101566

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-weak-vtables.cpp


Index: clang/test/SemaCXX/warn-weak-vtables.cpp
===
--- clang/test/SemaCXX/warn-weak-vtables.cpp
+++ clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -8,7 +8,7 @@
   virtual void f() { } 
 };
 
-template struct B {
+template struct B { // expected-warning {{there is no explicit 
instantiation declaration for 'B'; its vtable will be emitted in every 
translation unit}}
   virtual void f() { } 
 };
 
@@ -29,7 +29,8 @@
 // Use the vtables
 void uses_abc() {
   A a;
-  B b;
+  B b; // expected-note{{implicit instantiation first required here}}
+  B b_internal;
   C c;
 }
 
@@ -63,7 +64,7 @@
   virtual void f();
 };
 
-template class TemplVirt; // expected-warning{{explicit template 
instantiation 'TemplVirt' will emit a vtable in every translation unit}}
+template class TemplVirt;
 
 template<> struct TemplVirt {
   virtual void f();
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -17359,15 +17359,24 @@
 // no key function or the key function is inlined. Don't warn in C++ ABIs
 // that lack key functions, since the user won't be able to make one.
 if (Context.getTargetInfo().getCXXABI().hasKeyFunctions() &&
-Class->isExternallyVisible() && ClassTSK != TSK_ImplicitInstantiation) 
{
+Class->isExternallyVisible() &&
+ClassTSK != TSK_ExplicitInstantiationDefinition) {
   const FunctionDecl *KeyFunctionDef = nullptr;
   if (!KeyFunction || (KeyFunction->hasBody(KeyFunctionDef) &&
KeyFunctionDef->isInlined())) {
-Diag(Class->getLocation(),
- ClassTSK == TSK_ExplicitInstantiationDefinition
- ? diag::warn_weak_template_vtable
- : diag::warn_weak_vtable)
-<< Class;
+if (ClassTSK == TSK_ImplicitInstantiation) {
+  Diag(Class->getLocation(), diag::warn_weak_template_vtable) << Class;
+
+  SourceLocation InstLoc;
+  if (const auto *CTSD =
+  dyn_cast(Class))
+InstLoc = CTSD->getPointOfInstantiation();
+  else
+InstLoc =
+
Class->getMemberSpecializationInfo()->getPointOfInstantiation();
+  Diag(InstLoc, diag::note_instantiation_required_here) << false;
+} else
+  Diag(Class->getLocation(), diag::warn_weak_vtable) << Class;
   }
 }
   }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1583,8 +1583,8 @@
   "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
 def warn_weak_template_vtable : Warning<
-  "explicit template instantiation %0 will emit a vtable in every "
-  "translation unit">,
+  "there is no explicit instantiation declaration for %0; its vtable will be "
+  "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
 
 def ext_using_undefined_std : ExtWarn<


Index: clang/test/SemaCXX/warn-weak-vtables.cpp
===
--- clang/test/SemaCXX/warn-weak-vtables.cpp
+++ clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -8,7 +8,7 @@
   virtual void f() { } 
 };
 
-template struct B {
+template struct B { // expected-warning {{there is no explicit instantiation declaration for 'B'; its vtable will be emitted in every translation unit}}
   virtual void f() { } 
 };
 
@@ -29,7 +29,8 @@
 // Use the vtables
 void uses_abc() {
   A a;
-  B b;
+  B b; // expected-note{{implicit instantiation first required here}}
+  B b_internal;
   C c;
 }
 
@@ -63,7 +64,7 @@
   virtual void f();
 };
 
-template class TemplVirt; // expected-warning{{explicit template instantiation 'TemplVirt' will emit a vtable in every translation unit}}
+template class TemplVirt;
 
 template<> struct TemplVirt {
   virtual void f();
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -17359,15 +17359,24 @@
 // no key function or the key function is inlined. Don't warn in C++ ABIs
 // that lack key functions, since the user won't be able to make one.
 if (Context.getTargetInfo().getCXXABI().hasKeyFunctions()

[PATCH] D101168: [C++4OpenCL] Add clang extension for non-portable kernel parameters

2021-04-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


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

https://reviews.llvm.org/D101168

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


[clang] 76f84e7 - [Doc] Fix sphinx warnings about wrong code-block format

2021-04-30 Thread Alexey Bader via cfe-commits

Author: Alexey Bader
Date: 2021-04-30T11:40:10+03:00
New Revision: 76f84e772978a3daef33df5bea7da676a0163f28

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

LOG: [Doc] Fix sphinx warnings about wrong code-block format

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

Added: 


Modified: 
clang/docs/SYCLSupport.rst

Removed: 




diff  --git a/clang/docs/SYCLSupport.rst b/clang/docs/SYCLSupport.rst
index 8c1ed19dff4e6..d45ecfbea53f8 100644
--- a/clang/docs/SYCLSupport.rst
+++ b/clang/docs/SYCLSupport.rst
@@ -99,7 +99,7 @@ space attributes for pointers:
  - private_space
 
 
-.. code-block::
+.. code-block:: C++
+
+//TODO: add support for __attribute__((opencl_global_host)) and 
__attribute__((opencl_global_device)).
 
-   TODO: add support for `__attribute__((opencl_global_host))` and
-   `__attribute__((opencl_global_device))`.



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


[PATCH] D101549: [Doc] Fix sphynx warnings about wrong code-block format

2021-04-30 Thread Alexey Bader via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG76f84e772978: [Doc] Fix sphinx warnings about wrong 
code-block format (authored by bader).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101549

Files:
  clang/docs/SYCLSupport.rst


Index: clang/docs/SYCLSupport.rst
===
--- clang/docs/SYCLSupport.rst
+++ clang/docs/SYCLSupport.rst
@@ -99,7 +99,7 @@
  - private_space
 
 
-.. code-block::
+.. code-block:: C++
+
+//TODO: add support for __attribute__((opencl_global_host)) and 
__attribute__((opencl_global_device)).
 
-   TODO: add support for `__attribute__((opencl_global_host))` and
-   `__attribute__((opencl_global_device))`.


Index: clang/docs/SYCLSupport.rst
===
--- clang/docs/SYCLSupport.rst
+++ clang/docs/SYCLSupport.rst
@@ -99,7 +99,7 @@
  - private_space
 
 
-.. code-block::
+.. code-block:: C++
+
+//TODO: add support for __attribute__((opencl_global_host)) and __attribute__((opencl_global_device)).
 
-   TODO: add support for `__attribute__((opencl_global_host))` and
-   `__attribute__((opencl_global_device))`.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69498: IR: Invert convergent attribute handling

2021-04-30 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added a comment.

In D69498#2728451 , @JonChesterfield 
wrote:

> I wonder if it is necessary for the exec mask to be implicit state, managed 
> by a convergent/divergent abstraction.
>
> We could reify it as an argument passed to kernels (where all bits are set), 
> and adjusted by phi nodes at entry to basic blocks. Various intrinsics take 
> and return that reified value. __ballot, a comparison op, possibly load/store.
>
> At that point all the awkward control flow constraints are raised to data 
> flow, and I think (but haven't really chased this into the dark corners) that 
> solves the problems I know about. Notably, a uniform branch would be one 
> where the exec mask value was unchanged, so the associated phi is constant 
> folded.
>
> Makes a mess of the human readable IR, but possibly at a lower overall 
> complexity than continuing to handle divergence as control flow.

That is essentially what the current divergence analysis (Karrenberg and Hack) 
does anyway. Except that since we don't know how many threads are running 
concurrently, the mask is a symbolic value that can either be "divergent" or 
"uniform". If I am looking at this the right way, you seem to be saying two 
separate things: the notion of divergence/uniformity is what solves the problem 
at hand, and separately, the notion of divergence can be turned into explicit 
dataflow.

> edit: said reified mask, if integer, would also be the value post-volta sync 
> intrinsics take, where the developer is supposed to compute the mask across 
> branches and pass it around everywhere. Clang could therefore provide 
> builtins that lower to those sync intrinsics with an always correct mask 
> automatically passed. That would make volta much easier to program.

Additionally, the explicit mask (if we could agree on its type) would make it 
possible to have "dynamic uniformity". Currently we can only prove static 
uniformity.


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

https://reviews.llvm.org/D69498

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


[PATCH] D101515: clang-format: [JS] handle "off" in imports

2021-04-30 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 341849.
mprobst added a comment.

- review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101515

Files:
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/SortImportsTestJS.cpp

Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -358,7 +358,8 @@
 
   // do not merge imports and exports
   verifySort("import {A} from 'foo';\n"
- "export {B} from 'foo';",
+ "\n"
+ "export {B} from 'foo';\n",
  "import {A} from 'foo';\n"
  "export   {B} from 'foo';");
   // do merge exports
@@ -373,6 +374,63 @@
  "import './a';\n");
 }
 
+TEST_F(SortImportsTestJS, RespectsClangFormatOff) {
+  verifySort("// clang-format off\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format on\n",
+ "// clang-format off\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format on\n");
+
+  verifySort("import {A} from './sorted1_a';\n"
+ "import {B} from './sorted1_b';\n"
+ "// clang-format off\n"
+ "import {B} from './unsorted_b';\n"
+ "import {A} from './unsorted_a';\n"
+ "// clang-format on\n"
+ "import {A} from './sorted2_a';\n"
+ "import {B} from './sorted2_b';\n",
+ "import {B} from './sorted1_b';\n"
+ "import {A} from './sorted1_a';\n"
+ "// clang-format off\n"
+ "import {B} from './unsorted_b';\n"
+ "import {A} from './unsorted_a';\n"
+ "// clang-format on\n"
+ "import {B} from './sorted2_b';\n"
+ "import {A} from './sorted2_a';\n");
+
+  // Boundary cases
+  verifySort("// clang-format on\n", "// clang-format on\n");
+  verifySort("// clang-format off\n", "// clang-format off\n");
+  verifySort("// clang-format on\n"
+ "// clang-format off\n",
+ "// clang-format on\n"
+ "// clang-format off\n");
+  verifySort("// clang-format off\n"
+ "// clang-format on\n"
+ "import {A} from './a';\n"
+ "import {B} from './b';\n",
+ "// clang-format off\n"
+ "// clang-format on\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n");
+  // section ends with comment
+  verifySort("// clang-format on\n"
+ "import {A} from './a';\n"
+ "import {B} from './b';\n"
+ "import {C} from './c';\n"
+ "\n" // inserted empty line is working as intended: splits imports
+  // section from main code body
+ "// clang-format off\n",
+ "// clang-format on\n"
+ "import {C} from './c';\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format off\n");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -19,6 +19,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
@@ -69,6 +70,7 @@
 // This struct represents both exports and imports to build up the information
 // required for sorting module references.
 struct JsModuleReference {
+  bool FormattingOff = false;
   bool IsExport = false;
   // Module references are sorted into these categories, in order.
   enum ReferenceCategory {
@@ -146,39 +148,31 @@
 if (References.empty())
   return {Result, 0};
 
-SmallVector Indices;
-for (unsigned i = 0, e = References.size(); i != e; ++i)
-  Indices.push_back(i);
-llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  return References[LHSI] < References[RHSI];
-});
-bool ReferencesInOrder = llvm::is_sorted(Indices);
+// The text range of all parsed imports, to be replaced later.
+SourceRange InsertionPoint = References[0].Range;
+InsertionPoint.setEnd(References[References.size() - 1].Range.getEnd());
 
-mergeModuleReferences(References, Indices);
+References = sortModuleReferences(References);
 
 std::string ReferencesText;
-bool SymbolsInOrder = true;
-for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
-  JsModuleReference Reference = References[Indices[i]];
-  if (appendRefer

[clang] b2780cd - clang-format: [JS] handle "off" in imports

2021-04-30 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2021-04-30T14:18:52+02:00
New Revision: b2780cd744eaad6f5c7f39165054cf7000a1ff07

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

LOG: clang-format: [JS] handle "off" in imports

Previously, the JavaScript import sorter would ignore `// clang-format
off` and `on` comments. This change fixes that. It tracks whether
formatting is enabled for a stretch of imports, and then only sorts and
merges the imports where formatting is enabled, in individual chunks.

This means that there's no meaningful total order when module references are 
mixed
with blocks that have formatting disabled. The alternative approach
would have been to sort all imports that have formatting enabled in one
group. However that raises the question where to insert the
formatting-off block, which can also impact symbol visibility (in
particular for exports). In practice, sorting in chunks probably isn't a
big problem.

This change also simplifies the general algorithm: instead of tracking
indices separately and sorting them, it just sorts the vector of module
references. And instead of attempting to do fine grained tracking of
whether the code changed order, it just prints out the module references
text, and compares that to the previous text. Given that source files
typically have dozens, but not even hundreds of imports, the performance
impact seems negligible.

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

Added: 


Modified: 
clang/lib/Format/SortJavaScriptImports.cpp
clang/unittests/Format/SortImportsTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/SortJavaScriptImports.cpp 
b/clang/lib/Format/SortJavaScriptImports.cpp
index ca83f1926f6ce..4b88ece02a109 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -19,6 +19,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
@@ -69,6 +70,7 @@ struct JsImportedSymbol {
 // This struct represents both exports and imports to build up the information
 // required for sorting module references.
 struct JsModuleReference {
+  bool FormattingOff = false;
   bool IsExport = false;
   // Module references are sorted into these categories, in order.
   enum ReferenceCategory {
@@ -146,39 +148,31 @@ class JavaScriptImportSorter : public TokenAnalyzer {
 if (References.empty())
   return {Result, 0};
 
-SmallVector Indices;
-for (unsigned i = 0, e = References.size(); i != e; ++i)
-  Indices.push_back(i);
-llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  return References[LHSI] < References[RHSI];
-});
-bool ReferencesInOrder = llvm::is_sorted(Indices);
+// The text range of all parsed imports, to be replaced later.
+SourceRange InsertionPoint = References[0].Range;
+InsertionPoint.setEnd(References[References.size() - 1].Range.getEnd());
 
-mergeModuleReferences(References, Indices);
+References = sortModuleReferences(References);
 
 std::string ReferencesText;
-bool SymbolsInOrder = true;
-for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
-  JsModuleReference Reference = References[Indices[i]];
-  if (appendReference(ReferencesText, Reference))
-SymbolsInOrder = false;
-  if (i + 1 < e) {
+for (unsigned I = 0, E = References.size(); I != E; ++I) {
+  JsModuleReference Reference = References[I];
+  appendReference(ReferencesText, Reference);
+  if (I + 1 < E) {
 // Insert breaks between imports and exports.
 ReferencesText += "\n";
 // Separate imports groups with two line breaks, but keep all exports
 // in a single group.
 if (!Reference.IsExport &&
-(Reference.IsExport != References[Indices[i + 1]].IsExport ||
- Reference.Category != References[Indices[i + 1]].Category))
+(Reference.IsExport != References[I + 1].IsExport ||
+ Reference.Category != References[I + 1].Category))
   ReferencesText += "\n";
   }
 }
-if (ReferencesInOrder && SymbolsInOrder)
+llvm::StringRef PreviousText = getSourceText(InsertionPoint);
+if (ReferencesText == PreviousText)
   return {Result, 0};
 
-SourceRange InsertionPoint = References[0].Range;
-InsertionPoint.setEnd(References[References.size() - 1].Range.getEnd());
-
 // The loop above might collapse previously existing line breaks between
 // import blocks, and thus shrink the file. SortIncludes must not shrink
 // overall source length as there is currently no re-calculation 

[PATCH] D101515: clang-format: [JS] handle "off" in imports

2021-04-30 Thread Martin Probst 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 rGb2780cd744ea: clang-format: [JS] handle "off" in 
imports (authored by mprobst).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101515

Files:
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/SortImportsTestJS.cpp

Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -358,7 +358,8 @@
 
   // do not merge imports and exports
   verifySort("import {A} from 'foo';\n"
- "export {B} from 'foo';",
+ "\n"
+ "export {B} from 'foo';\n",
  "import {A} from 'foo';\n"
  "export   {B} from 'foo';");
   // do merge exports
@@ -373,6 +374,63 @@
  "import './a';\n");
 }
 
+TEST_F(SortImportsTestJS, RespectsClangFormatOff) {
+  verifySort("// clang-format off\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format on\n",
+ "// clang-format off\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format on\n");
+
+  verifySort("import {A} from './sorted1_a';\n"
+ "import {B} from './sorted1_b';\n"
+ "// clang-format off\n"
+ "import {B} from './unsorted_b';\n"
+ "import {A} from './unsorted_a';\n"
+ "// clang-format on\n"
+ "import {A} from './sorted2_a';\n"
+ "import {B} from './sorted2_b';\n",
+ "import {B} from './sorted1_b';\n"
+ "import {A} from './sorted1_a';\n"
+ "// clang-format off\n"
+ "import {B} from './unsorted_b';\n"
+ "import {A} from './unsorted_a';\n"
+ "// clang-format on\n"
+ "import {B} from './sorted2_b';\n"
+ "import {A} from './sorted2_a';\n");
+
+  // Boundary cases
+  verifySort("// clang-format on\n", "// clang-format on\n");
+  verifySort("// clang-format off\n", "// clang-format off\n");
+  verifySort("// clang-format on\n"
+ "// clang-format off\n",
+ "// clang-format on\n"
+ "// clang-format off\n");
+  verifySort("// clang-format off\n"
+ "// clang-format on\n"
+ "import {A} from './a';\n"
+ "import {B} from './b';\n",
+ "// clang-format off\n"
+ "// clang-format on\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n");
+  // section ends with comment
+  verifySort("// clang-format on\n"
+ "import {A} from './a';\n"
+ "import {B} from './b';\n"
+ "import {C} from './c';\n"
+ "\n" // inserted empty line is working as intended: splits imports
+  // section from main code body
+ "// clang-format off\n",
+ "// clang-format on\n"
+ "import {C} from './c';\n"
+ "import {B} from './b';\n"
+ "import {A} from './a';\n"
+ "// clang-format off\n");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -19,6 +19,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
@@ -69,6 +70,7 @@
 // This struct represents both exports and imports to build up the information
 // required for sorting module references.
 struct JsModuleReference {
+  bool FormattingOff = false;
   bool IsExport = false;
   // Module references are sorted into these categories, in order.
   enum ReferenceCategory {
@@ -146,39 +148,31 @@
 if (References.empty())
   return {Result, 0};
 
-SmallVector Indices;
-for (unsigned i = 0, e = References.size(); i != e; ++i)
-  Indices.push_back(i);
-llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  return References[LHSI] < References[RHSI];
-});
-bool ReferencesInOrder = llvm::is_sorted(Indices);
+// The text range of all parsed imports, to be replaced later.
+SourceRange InsertionPoint = References[0].Range;
+InsertionPoint.setEnd(References[References.size() - 1].Range.getEnd());
 
-mergeModuleReferences(References, Indices);
+References = sortModuleReferences(References);
 
 std::string ReferencesText;
-bool SymbolsInOrder = true;
-

[PATCH] D101616: [clangd] Fix data type of WorkDoneProgressReport::percentage

2021-04-30 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler created this revision.
ckandeler added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
ckandeler requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

According to the specification, this should be an unsigned integer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101616

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.h


Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -631,7 +631,7 @@
   ///
   /// The value should be steadily rising. Clients are free to ignore values
   /// that are not following this rule.
-  llvm::Optional percentage;
+  llvm::Optional percentage;
 };
 llvm::json::Value toJSON(const WorkDoneProgressReport &);
 //
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1604,7 +1604,7 @@
 if (Stats.Completed < Stats.Enqueued) {
   assert(Stats.Enqueued > Stats.LastIdle);
   WorkDoneProgressReport Report;
-  Report.percentage = 100.0 * (Stats.Completed - Stats.LastIdle) /
+  Report.percentage = 100 * (Stats.Completed - Stats.LastIdle) /
   (Stats.Enqueued - Stats.LastIdle);
   Report.message =
   llvm::formatv("{0}/{1}", Stats.Completed - Stats.LastIdle,


Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -631,7 +631,7 @@
   ///
   /// The value should be steadily rising. Clients are free to ignore values
   /// that are not following this rule.
-  llvm::Optional percentage;
+  llvm::Optional percentage;
 };
 llvm::json::Value toJSON(const WorkDoneProgressReport &);
 //
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1604,7 +1604,7 @@
 if (Stats.Completed < Stats.Enqueued) {
   assert(Stats.Enqueued > Stats.LastIdle);
   WorkDoneProgressReport Report;
-  Report.percentage = 100.0 * (Stats.Completed - Stats.LastIdle) /
+  Report.percentage = 100 * (Stats.Completed - Stats.LastIdle) /
   (Stats.Enqueued - Stats.LastIdle);
   Report.message =
   llvm::formatv("{0}/{1}", Stats.Completed - Stats.LastIdle,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101617: [clang-tidy] Tweak diag ranges for bugprone-sizeof-expression

2021-04-30 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman.
Herald added a subscriber: xazax.hun.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Provide more useful warning locations and diagnostic ranges.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101617

Files:
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -77,7 +77,7 @@
   sum += sizeof(LEN + 1);
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(K)'
   sum += sizeof(sum, LEN);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(..., ...)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: suspicious usage of 'sizeof(..., ...)'
   sum += sizeof(AsBool());
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof()' on an expression that results in an integer
   sum += sizeof(AsInt());
@@ -103,41 +103,41 @@
   sum += sizeof(LEN + - + -sizeof(X));
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(sizeof(...))'
   sum += sizeof(char) / sizeof(char);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
   sum += sizeof(A) / sizeof(S);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
   sum += sizeof(char) / sizeof(int);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
   sum += sizeof(char) / sizeof(A);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
   sum += sizeof(B[0]) / sizeof(A);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
   sum += sizeof(ptr) / sizeof(char);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
   sum += sizeof(ptr) / sizeof(ptr[0]);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
   sum += sizeof(ptr) / sizeof(char*);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
   sum += sizeof(ptr) / sizeof(void*);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
   sum += sizeof(ptr) / sizeof(const void volatile*);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
   sum += sizeof(ptr) / sizeof(char);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
   sum += sizeof(ptr) / sizeof(ptr[0]);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
   sum += sizeof(int) * sizeof(char);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious 'sizeof' by 'sizeof' multiplication
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious 'sizeof' by 'sizeof' multiplication
  

[PATCH] D101611: [clangd][NFC] Remove unnecessary string captures in lambdas.

2021-04-30 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG681503708594: [clangd][NFC] Remove unnecessary string 
captures in lambdas. (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101611

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp


Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -575,8 +575,7 @@
   // Tracks number of times a tweak has been offered.
   static constexpr trace::Metric TweakAvailable(
   "tweak_available", trace::Metric::Counter, "tweak_id");
-  auto Action = [File = File.str(), Sel, CB = std::move(CB),
- Filter = std::move(Filter),
+  auto Action = [Sel, CB = std::move(CB), Filter = std::move(Filter),
  FeatureModules(this->FeatureModules)](
 Expected InpAST) mutable {
 if (!InpAST)
@@ -756,8 +755,7 @@
 
 void ClangdServer::inlayHints(PathRef File,
   Callback> CB) {
-  auto Action = [File = File.str(),
- CB = std::move(CB)](Expected InpAST) mutable {
+  auto Action = [CB = std::move(CB)](Expected InpAST) mutable {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::inlayHints(InpAST->AST));
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -725,8 +725,8 @@
 
 void ClangdLSPServer::onCommandApplyTweak(const TweakArgs &Args,
   Callback Reply) {
-  auto Action = [this, Reply = std::move(Reply),
- File = Args.file](llvm::Expected R) mutable {
+  auto Action = [this, Reply = std::move(Reply)](
+llvm::Expected R) mutable {
 if (!R)
   return Reply(R.takeError());
 


Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -575,8 +575,7 @@
   // Tracks number of times a tweak has been offered.
   static constexpr trace::Metric TweakAvailable(
   "tweak_available", trace::Metric::Counter, "tweak_id");
-  auto Action = [File = File.str(), Sel, CB = std::move(CB),
- Filter = std::move(Filter),
+  auto Action = [Sel, CB = std::move(CB), Filter = std::move(Filter),
  FeatureModules(this->FeatureModules)](
 Expected InpAST) mutable {
 if (!InpAST)
@@ -756,8 +755,7 @@
 
 void ClangdServer::inlayHints(PathRef File,
   Callback> CB) {
-  auto Action = [File = File.str(),
- CB = std::move(CB)](Expected InpAST) mutable {
+  auto Action = [CB = std::move(CB)](Expected InpAST) mutable {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::inlayHints(InpAST->AST));
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -725,8 +725,8 @@
 
 void ClangdLSPServer::onCommandApplyTweak(const TweakArgs &Args,
   Callback Reply) {
-  auto Action = [this, Reply = std::move(Reply),
- File = Args.file](llvm::Expected R) mutable {
+  auto Action = [this, Reply = std::move(Reply)](
+llvm::Expected R) mutable {
 if (!R)
   return Reply(R.takeError());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 6815037 - [clangd][NFC] Remove unnecessary string captures in lambdas.

2021-04-30 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-04-30T13:27:24+01:00
New Revision: 6815037085945be8bb758c23b1a5daabe0a8667d

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

LOG: [clangd][NFC] Remove unnecessary string captures in lambdas.

Due to a somewhat annoying, but necessary, shortfall in 
-Wunused-lambda-capture, These unused captures aren't warned about.

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 4916dfaafd5ae..a7cc1ed42818f 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -725,8 +725,8 @@ void ClangdLSPServer::onCommandApplyEdit(const 
WorkspaceEdit &WE,
 
 void ClangdLSPServer::onCommandApplyTweak(const TweakArgs &Args,
   Callback Reply) {
-  auto Action = [this, Reply = std::move(Reply),
- File = Args.file](llvm::Expected R) mutable {
+  auto Action = [this, Reply = std::move(Reply)](
+llvm::Expected R) mutable {
 if (!R)
   return Reply(R.takeError());
 

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 11cd1a8fee537..3f8b95b9104ce 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -575,8 +575,7 @@ void ClangdServer::enumerateTweaks(
   // Tracks number of times a tweak has been offered.
   static constexpr trace::Metric TweakAvailable(
   "tweak_available", trace::Metric::Counter, "tweak_id");
-  auto Action = [File = File.str(), Sel, CB = std::move(CB),
- Filter = std::move(Filter),
+  auto Action = [Sel, CB = std::move(CB), Filter = std::move(Filter),
  FeatureModules(this->FeatureModules)](
 Expected InpAST) mutable {
 if (!InpAST)
@@ -756,8 +755,7 @@ void ClangdServer::incomingCalls(
 
 void ClangdServer::inlayHints(PathRef File,
   Callback> CB) {
-  auto Action = [File = File.str(),
- CB = std::move(CB)](Expected InpAST) mutable {
+  auto Action = [CB = std::move(CB)](Expected InpAST) mutable {
 if (!InpAST)
   return CB(InpAST.takeError());
 CB(clangd::inlayHints(InpAST->AST));



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


[PATCH] D93095: Introduce -Wreserved-identifier

2021-04-30 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 341853.
serge-sans-paille marked 10 inline comments as done.
serge-sans-paille added a comment.

Take into account latest reviews


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

https://reviews.llvm.org/D93095

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Preprocessor/macro-reserved.c
  clang/test/Preprocessor/macro-reserved.cpp
  clang/test/Sema/reserved-identifier.c
  clang/test/Sema/reserved-identifier.cpp

Index: clang/test/Sema/reserved-identifier.cpp
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wreserved-identifier %s
+
+int foo__bar() { return 0; }// expected-warning {{identifier 'foo__bar' is reserved because it contains '__'}}
+static int _bar() { return 0; } // expected-warning {{identifier '_bar' is reserved because it starts with '_' at global scope}}
+static int _Bar() { return 0; } // expected-warning {{identifier '_Bar' is reserved because it starts with '_' followed by a capital letter}}
+int _barbouille() { return 0; } // expected-warning {{identifier '_barbouille' is reserved because it starts with '_' at global scope}}
+
+void foo(unsigned int _Reserved) { // expected-warning {{identifier '_Reserved' is reserved because it starts with '_' followed by a capital letter}}
+  unsigned int __1 =   // expected-warning {{identifier '__1' is reserved because it starts with '__'}}
+  _Reserved;   // no-warning
+}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+template  constexpr bool __toucan = true; // expected-warning {{identifier '__toucan' is reserved because it starts with '__'}}
+
+template 
+concept _Barbotine = __toucan; // expected-warning {{identifier '_Barbotine' is reserved because it starts with '_' followed by a capital letter}}
+
+template  // expected-warning {{'__' is reserved because it starts with '__'}}
+struct BarbeNoire {};
+
+template  // no-warning
+struct BarbeJaune {};
+
+template  // expected-warning {{'__' is reserved because it starts with '__'}}
+void BarbeRousse() {}
+
+namespace _Barbidur { // expected-warning {{identifier '_Barbidur' is reserved because it starts with '_' followed by a capital letter}}
+
+struct __barbidou {}; // expected-warning {{identifier '__barbidou' is reserved because it starts with '__'}}
+struct _barbidou {};  // no-warning
+
+int __barbouille; // expected-warning {{identifier '__barbouille' is reserved because it starts with '__'}}
+int _barbouille;  // no-warning
+
+int __babar() { return 0; } // expected-warning {{identifier '__babar' is reserved because it starts with '__'}}
+int _babar() { return 0; }  // no-warning
+
+} // namespace _Barbidur
+
+class __barbapapa { // expected-warning {{identifier '__barbapapa' is reserved because it starts with '__'}}
+  void _barbabelle() {} // no-warning
+  int _Barbalala;   // expected-warning {{identifier '_Barbalala' is reserved because it starts with '_' followed by a capital letter}}
+};
+
+enum class __menu { // expected-warning {{identifier '__menu' is reserved because it starts with '__'}}
+  __some,   // expected-warning {{identifier '__some' is reserved because it starts with '__'}}
+  _Other,   // expected-warning {{identifier '_Other' is reserved because it starts with '_' followed by a capital letter}}
+  _other// no-warning
+};
+
+enum _Menu { // expected-warning {{identifier '_Menu' is reserved because it starts with '_' followed by a capital letter}}
+  _OtheR_,   // expected-warning {{identifier '_OtheR_' is reserved because it starts with '_' followed by a capital letter}}
+  _other_// expected-warning {{identifier '_other_' is reserved because it starts with '_' at global scope}}
+};
+
+enum {
+  __some, // expected-warning {{identifier '__some' is reserved because it starts with '__'}}
+  _Other, // expected-warning {{identifier '_Other' is reserved because it starts with '_' followed by a capital letter}}
+  _other  // expected-warning {{identifier '_other' is reserved because it starts with '_' at global scope}}
+};
+
+static union {
+  int _barbeFleurie; // no-warning
+};
+
+using _Barbamama = __barbapapa; // expected-warning {{identifier '_Barbamama' is reserved because it starts with '_' followed by a capital letter}}
+
+int foobar() {
+  return foo__bar(); // no-warning
+}
+
+namespace {
+int _bar

[PATCH] D100972: [clang-tidy] cppcoreguidelines-avoid-non-const-global-variables: add fixes to checks

2021-04-30 Thread Marco Gartmann via Phabricator via cfe-commits
mgartmann added a comment.

Friendly ping, any feedback would be appreciated :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100972

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


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

2021-04-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D99432#2726997 , @estewart08 wrote:

> In D99432#2726845 , @ABataev wrote:
>
>> In D99432#2726588 , @estewart08 
>> wrote:
>>
>>> In D99432#2726391 , @ABataev wrote:
>>>
 In D99432#2726337 , @estewart08 
 wrote:

> In D99432#2726060 , @ABataev 
> wrote:
>
>> In D99432#2726050 , @estewart08 
>> wrote:
>>
>>> In D99432#2726025 , @ABataev 
>>> wrote:
>>>
 In D99432#2726019 , 
 @estewart08 wrote:

> In reference to https://bugs.llvm.org/show_bug.cgi?id=48851, I do not 
> see how this helps SPMD mode with team privatization of declarations 
> in-between target teams and parallel regions.

 Diв you try the reproducer with the applied patch?
>>>
>>> Yes, I still saw the test fail, although it was not with latest 
>>> llvm-project. Are you saying the reproducer passes for you?
>>
>> I don't have CUDA installed but from what I see in the LLVM IR it shall 
>> pass. Do you have a debug log, does it crashes or produces incorrect 
>> results?
>
> This is on an AMDGPU but I assume the behavior would be similar for NVPTX.
>
> It produces incorrect/incomplete results in the dist[0] index after a 
> manual reduction and in turn the final global gpu_results array is 
> incorrect.
> When thread 0 does a reduction into dist[0] it has no knowledge of 
> dist[1] having been updated by thread 1. Which tells me the array is 
> still thread private.
> Adding some printfs, looking at one teams' output:
>
> SPMD
>
>   Thread 0: dist[0]: 1
>   Thread 0: dist[1]: 0  // This should be 1
>   After reduction into dist[0]: 1  // This should be 2
>   gpu_results = [1,1]  // [2,2] expected
>
> Generic Mode:
>
>   Thread 0: dist[0]: 1
>   Thread 0: dist[1]: 1   
>   After reduction into dist[0]: 2
>   gpu_results = [2,2]

 Hmm, I would expect a crash if the array was allocated in the local 
 memory. Could you try to add some more printfs (with data and addresses of 
 the array) to check the results? Maybe there is a data race somewhere in 
 the code?
>>>
>>> As a reminder, each thread updates a unique index in the dist array and 
>>> each team updates a unique index in gpu_results.
>>>
>>> SPMD - shows each thread has a unique address for dist array
>>>
>>>   Team 0 Thread 1: dist[0]: 0, 0x7f92e24a8bf8
>>>   Team 0 Thread 1: dist[1]: 1, 0x7f92e24a8bfc
>>>   
>>>   Team 0 Thread 0: dist[0]: 1, 0x7f92e24a8bf0
>>>   Team 0 Thread 0: dist[1]: 0, 0x7f92e24a8bf4
>>>   
>>>   Team 0 Thread 0: After reduction into dist[0]: 1
>>>   Team 0 Thread 0: gpu_results address: 0x7f92a500
>>>   --
>>>   Team 1 Thread 1: dist[0]: 0, 0x7f92f9ec5188
>>>   Team 1 Thread 1: dist[1]: 1, 0x7f92f9ec518c
>>>   
>>>   Team 1 Thread 0: dist[0]: 1, 0x7f92f9ec5180
>>>   Team 1 Thread 0: dist[1]: 0, 0x7f92f9ec5184
>>>   
>>>   Team 1 Thread 0: After reduction into dist[0]: 1
>>>   Team 1 Thread 0: gpu_results address: 0x7f92a500
>>>   
>>>   gpu_results[0]: 1
>>>   gpu_results[1]: 1
>>>
>>> Generic - shows each team shares dist array address amongst threads
>>>
>>>   Team 0 Thread 1: dist[0]: 1, 0x7fac01938880
>>>   Team 0 Thread 1: dist[1]: 1, 0x7fac01938884
>>>   
>>>   Team 0 Thread 0: dist[0]: 1, 0x7fac01938880
>>>   Team 0 Thread 0: dist[1]: 1, 0x7fac01938884
>>>   
>>>   Team 0 Thread 0: After reduction into dist[0]: 2
>>>   Team 0 Thread 0: gpu_results address: 0x7fabc500
>>>   --
>>>   Team 1 Thread 1: dist[0]: 1, 0x7fac19354e10
>>>   Team 1 Thread 1: dist[1]: 1, 0x7fac19354e14
>>>   
>>>   Team 1 Thread 0: dist[0]: 1, 0x7fac19354e10
>>>   Team 1 Thread 0: dist[1]: 1, 0x7fac19354e14
>>>   
>>>   Team 1 Thread 0: After reduction into dist[0]: 2
>>>   Team 1 Thread 0: gpu_results address: 0x7fabc500
>>
>> Could you check if it works with `-fno-openmp-cuda-parallel-target-regions` 
>> option?
>
> Unfortunately that crashes:
> llvm-project/llvm/lib/IR/Instructions.cpp:495: void 
> llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, 
> llvm::ArrayRef, 
> llvm::ArrayRef >, const llvm::Twine&): 
> Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == 
> Args[i]->getType()) && "Calling a function with a bad signature!"' failed.

Hmm, could you provide a full stack trace?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99432

[PATCH] D101191: [InstCombine] Fully disable select to and/or i1 folding

2021-04-30 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added inline comments.



Comment at: 
llvm/test/Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll:20
 
+; FIXME: noundef should be attached to args
 define i1 @will_not_overflow(i64 %arg, i64 %arg1) {

aqjune wrote:
> nikic wrote:
> > spatel wrote:
> > > aqjune wrote:
> > > > aqjune wrote:
> > > > > spatel wrote:
> > > > > > Any ideas about what it will take to get those argument attributes 
> > > > > > for the C++ source example shown in the code comment?
> > > > > > 
> > > > > > SDAG is still going to convert the `select` to `and`, so we can 
> > > > > > probably avoid regressions by replicating InstSimplify's 
> > > > > > omitCheckForZeroBeforeMulWithOverflow() as a DAG combine. Let me 
> > > > > > know if I should do that.
> > > > > I promised to do the patch at D82317, but these days I'm occupied 
> > > > > with other things, so it might not be a recent future (not in a month 
> > > > > at least)...
> > > > > 
> > > > > I think it is a good chance to use freeze here: We can add
> > > > > ```
> > > > > %cond = icmp ne %x, 0
> > > > > %v = call @llvm.umul.with.overflow(%x, %y)
> > > > > %ov = extractvalue %v, 1
> > > > > %res = select i1 %cond, %ov, false
> > > > >   =>
> > > > > %y.fr = freeze %y
> > > > > %v = call @llvm.umul.with.overflow(%x, %y.fr)
> > > > > %ov = extractvalue %v, 1
> > > > > %res = %ov
> > > > > ```
> > > > > into CodeGenPrepare.
> > > > > What do you think? CodeGenPrepare is already using freeze for a few 
> > > > > transformations.
> > > > Alive2 proof: https://alive2.llvm.org/ce/z/zgPUGT
> > > I don't think we want to add code to CGP if we can avoid it. CGP is 
> > > supposed to be a temporary hack that is not needed with GlobalISel. I do 
> > > acknowledge that "temporary" in the code may outlive the people working 
> > > on it today (!).
> > > 
> > > If we don't care about undef correctness in codegen (in other words, the 
> > > select->and transform will live on in codegen forever), then we might as 
> > > well add a DAG combine. Alternatively, are we comfortable creating freeze 
> > > in instcombine for rare code like umul.with.ov?
> > I think this is one of the rare cases where inserting Freeze in InstCombine 
> > makes sense. There's not much (any?) further optimization opportunities for 
> > a umul.with.overflow with non-constant operands.
> InstCombine sounds good as well!
For reference, that part is D101423, and it will be a preliminary patch before 
this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101191

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


[PATCH] D96418: [clang] Refactor mustprogress handling, add it to all loops in c++11+.

2021-04-30 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 341863.
fhahn added a comment.

Thanks everyone! I rebased the patch and addressed John's comments. I'll commit 
it shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96418

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/attr-mustprogress.c
  clang/test/CodeGenCXX/attr-mustprogress.cpp

Index: clang/test/CodeGenCXX/attr-mustprogress.cpp
===
--- clang/test/CodeGenCXX/attr-mustprogress.cpp
+++ clang/test/CodeGenCXX/attr-mustprogress.cpp
@@ -23,20 +23,22 @@
 
 // CHECK: datalayout
 
-// CXX98-NOT: mustprogress
-// CXX11-NOT: mustprogress
-// FINITE-NOT: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
+// FINITE-NOT: mustprogress
 // CHECK-LABEL: @_Z2f0v(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:br label %for.cond
 // CHECK:   for.cond:
-// CHECK-NOT:br {{.*}} llvm.loop
+// CXX98-NOT:br {{.*}} llvm.loop
+// CXX11-NEXT:   br label %for.cond, !llvm.loop [[LOOP1:!.*]]
+// FINITE-NEXT:  br label %for.cond, !llvm.loop [[LOOP1:!.*]]
 void f0() {
   for (; ;) ;
 }
 
-// CXX98-NOT: mustprogress
-// CXX11-NOT: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
 // FINITE-NOT: mustprogress
 // CHECK-LABEL: @_Z2f1v(
 // CHECK-NEXT:  entry:
@@ -44,7 +46,9 @@
 // CHECK:   for.cond:
 // CHECK-NEXT:br i1 true, label %for.body, label %for.end
 // CHECK:   for.body:
-// CHECK-NOT:br {{.*}}, !llvm.loop
+// CXX98-NOT: br {{.*}}, !llvm.loop
+// CXX11-NEXT:br label %for.cond, !llvm.loop [[LOOP2:!.*]]
+// FINITE-NEXT:  br label %for.cond, !llvm.loop [[LOOP2:!.*]]
 // CHECK:   for.end:
 // CHECK-NEXT:ret void
 //
@@ -53,8 +57,8 @@
 ;
 }
 
-// CXX98-NOT: mustprogress
-// CXX11: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
 // FINITE-NOT: mustprogress
 // CHECK-LABEL: @_Z2f2v(
 // CHECK-NEXT:  entry:
@@ -66,8 +70,8 @@
 // CHECK-NEXT:br i1 [[CMP]], label %for.body, label %for.end
 // CHECK:   for.body:
 // CXX98-NOT:br {{.*}}, !llvm.loop
-// CXX11:br label %for.cond, !llvm.loop [[LOOP1:!.*]]
-// FINITE-NEXT:   br label %for.cond, !llvm.loop [[LOOP1:!.*]]
+// CXX11:br label %for.cond, !llvm.loop [[LOOP3:!.*]]
+// FINITE-NEXT:  br label %for.cond, !llvm.loop [[LOOP3:!.*]]
 // CHECK:   for.end:
 // CHECK-NEXT:ret void
 //
@@ -76,8 +80,8 @@
 ;
 }
 
-// CXX98-NOT: mustprogress
-// CXX11-NOT: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
 // FINITE-NOT: mustprogress
 // CHECK-LABEL: @_Z1Fv(
 // CHECK-NEXT:  entry:
@@ -85,7 +89,9 @@
 // CHECK:   for.cond:
 // CHECK-NEXT:br i1 true, label %for.body, label %for.end
 // CHECK:   for.body:
-// CHECK-NOT: br {{.*}}, !llvm.loop
+// CXX98-NOT: br {{.*}}, !llvm.loop
+// CXX11-NEXT:br label %for.cond, !llvm.loop [[LOOP4:!.*]]
+// FINITE-NEXT:   br label %for.cond, !llvm.loop [[LOOP4:!.*]]
 // CHECK:   for.end:
 // CHECK-NEXT:br label %for.cond1
 // CHECK:   for.cond1:
@@ -95,8 +101,8 @@
 // CHECK-NEXT:br i1 [[CMP]], label %for.body2, label %for.end3
 // CHECK:   for.body2:
 // CXX98-NOT: br {{.*}}, !llvm.loop
-// CXX11-NEXT:br label %for.cond1, !llvm.loop [[LOOP2:!.*]]
-// FINITE-NEXT:   br label %for.cond1, !llvm.loop [[LOOP2:!.*]]
+// CXX11-NEXT:br label %for.cond1, !llvm.loop [[LOOP5:!.*]]
+// FINITE-NEXT:   br label %for.cond1, !llvm.loop [[LOOP5:!.*]]
 // CHECK:   for.end3:
 // CHECK-NEXT:ret void
 //
@@ -107,8 +113,8 @@
 ;
 }
 
-// CXX98-NOT: mustprogress
-// CXX11-NOT: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
 // FINITE-NOT: mustprogress
 // CHECK-LABEL: @_Z2F2v(
 // CHECK-NEXT:  entry:
@@ -120,14 +126,16 @@
 // CHECK-NEXT:br i1 [[CMP]], label %for.body, label %for.end
 // CHECK:   for.body:
 // CXX98_NOT: br {{.*}} !llvm.loop
-// CXX11-NEXT:br label %for.cond, !llvm.loop [[LOOP3:!.*]]
-// FINITE-NEXT:br label %for.cond, !llvm.loop [[LOOP3:!.*]]
+// CXX11-NEXT:br label %for.cond, !llvm.loop [[LOOP6:!.*]]
+// FINITE-NEXT:   br label %for.cond, !llvm.loop [[LOOP6:!.*]]
 // CHECK:   for.end:
 // CHECK-NEXT:br label %for.cond1
 // CHECK:   for.cond1:
 // CHECK-NEXT:br i1 true, label %for.body2, label %for.end3
 // CHECK:   for.body2:
-// CHECK-NOT: br {{.*}}, !llvm.loop
+// CXX98-NOT: br {{.*}}, !llvm.loop
+// CXX11-NEXT:br label %for.cond1, !llvm.loop [[LOOP7:!.*]]
+// FINITE-NEXT:   br label %for.cond1, !llvm.loop [[LOOP7:!.*]]
 // CHECK:   for.end3:
 // CHECK-NEXT:ret void
 //
@@ -138,22 +146,24 @@
 ;
 }
 
-// CXX98-NOT: mustprogress
-// CXX11-NOT: mustprogress
-// FINITE-NOT: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
+// FINITE-NOT: mu

[PATCH] D96418: [clang] Refactor mustprogress handling, add it to all loops in c++11+.

2021-04-30 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked an inline comment as done.
fhahn added inline comments.



Comment at: clang/lib/CodeGen/CGStmt.cpp:796
+  bool EmitBoolCondBranch = !C || !C->isOne();
+  bool CondIsConst = C;
   const SourceRange &R = S.getSourceRange();

rjmccall wrote:
> fhahn wrote:
> > lebedev.ri wrote:
> > > I think, if we really want to give this a name, perhaps we want something 
> > > even more specific,
> > > perhaps `CondIsConstImm`/`CondIsConstInt`?
> > I updated the name to `CondIsConstInt`
> Please use an explicit `!= nullptr` check when converting a pointer to `bool` 
> outside of an obvious boolean context.
Updated, thanks!



Comment at: clang/lib/CodeGen/CodeGenFunction.h:535-536
+// Hence each function is 'mustprogress' in C++11 or later.
 return getLangOpts().CPlusPlus11 || getLangOpts().CPlusPlus14 ||
getLangOpts().CPlusPlus17 || getLangOpts().CPlusPlus20;
   }

rjmccall wrote:
> fhahn wrote:
> > lebedev.ri wrote:
> > > Since every new standard version will have to be added here,
> > > can we invert this and just check for the know fixed set
> > > of the versions where this doesn't apply?
> > I tried, but it appears as if there's no LangOpt for `C++98`. (this also 
> > seems not directly related to the patch, so I guess we could do that as 
> > follow-up as well?)
> The way these options work is that the later standards imply the early 
> standards; that's why there isn't a `CPlusPlus98`.  You just need 
> `CPlusPlus11` here.
Great, thanks for clarifying John! I updated the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96418

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


[clang] b14a6f0 - [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Tomas Matheson via cfe-commits

Author: Tomas Matheson
Date: 2021-04-30T13:48:05+01:00
New Revision: b14a6f06cc8763830a25023edf5b9ccee18e426a

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

LOG: [ARM][MVE] vcreateq lane ordering for big endian

Use of bitcast resulted in lanes being swapped for vcreateq with big
endian. Fix this by using vreinterpret. No code change for little
endian. Adds IR lit test.

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

Added: 


Modified: 
clang/include/clang/Basic/arm_mve.td
clang/test/CodeGen/arm-mve-intrinsics/admin.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 8106f9a5a9def..55c2fbe7f0217 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -1543,7 +1543,7 @@ foreach desttype = T.All in {
 let params = T.All in {
   let pnt = PNT_None in {
 def vcreateq: Intrinsic), $a, 0),
+(vreinterpret (ielt_const (ielt_const (undef VecOf), $a, 0),
  $b, 1), Vector)>;
 def vuninitializedq: Intrinsic;
   }

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/admin.c 
b/clang/test/CodeGen/arm-mve-intrinsics/admin.c
index 137231557011a..6c81cda00bac8 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/admin.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/admin.c
@@ -1,51 +1,82 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | 
FileCheck %s
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa 
-early-cse | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | 
FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa 
-early-cse | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | 
FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa 
-early-cse | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+
 
 #include 
 
-// CHECK-LABEL: @test_vcreateq_f16(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], 
i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 
[[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
-// CHECK-NEXT:ret <8 x half> [[TMP2]]
+// CHECK-LE-LABEL: @test_vcreateq_f16(
+// CHECK-LE-NEXT:  entry:
+// CHECK-LE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 
[[A:%.*]], i64 0
+// CHECK-LE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 
[[B:%.*]], i64 1
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
+// CHECK-LE-NEXT:ret <8 x half> [[TMP2]]
+//
+// CHECK-BE-LABEL: @test_vcreateq_f16(
+// CHECK-BE-NEXT:  entry:
+// CHECK-BE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 
[[A:%.*]], i64 0
+// CHECK-BE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 
[[B:%.*]], i64 1
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <8 x half> 
@llvm.arm.mve.vreinterpretq.v8f16.v2i64(<2 x i64> [[TMP1]])
+// CHECK-BE-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vcreateq_f16(uint64_t a, uint64_t b)
 {
 return vcreateq_f16(a, b);
 }
 
-// CHECK-LABEL: @test_vcreateq_f32(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], 
i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 
[[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
-// CHECK-NEXT:ret <4 x float> [[TMP2]]
+// CHECK-LE-LABEL: @test_vcreateq_f32(
+// CHECK-LE-NEXT:  entry:
+// CHECK-LE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64

[PATCH] D101606: [ARM][MVE] vcreateq lane ordering for big endian

2021-04-30 Thread Tomas Matheson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb14a6f06cc87: [ARM][MVE] vcreateq lane ordering for big 
endian (authored by tmatheson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101606

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/admin.c

Index: clang/test/CodeGen/arm-mve-intrinsics/admin.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/admin.c
+++ clang/test/CodeGen/arm-mve-intrinsics/admin.c
@@ -1,51 +1,82 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang_cc1 -triple thumbebv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg -sroa -early-cse | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+
 
 #include 
 
-// CHECK-LABEL: @test_vcreateq_f16(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
-// CHECK-NEXT:ret <8 x half> [[TMP2]]
+// CHECK-LE-LABEL: @test_vcreateq_f16(
+// CHECK-LE-NEXT:  entry:
+// CHECK-LE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-LE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <8 x half>
+// CHECK-LE-NEXT:ret <8 x half> [[TMP2]]
+//
+// CHECK-BE-LABEL: @test_vcreateq_f16(
+// CHECK-BE-NEXT:  entry:
+// CHECK-BE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-BE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <8 x half> @llvm.arm.mve.vreinterpretq.v8f16.v2i64(<2 x i64> [[TMP1]])
+// CHECK-BE-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vcreateq_f16(uint64_t a, uint64_t b)
 {
 return vcreateq_f16(a, b);
 }
 
-// CHECK-LABEL: @test_vcreateq_f32(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
-// CHECK-NEXT:ret <4 x float> [[TMP2]]
+// CHECK-LE-LABEL: @test_vcreateq_f32(
+// CHECK-LE-NEXT:  entry:
+// CHECK-LE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-LE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <2 x i64> [[TMP1]] to <4 x float>
+// CHECK-LE-NEXT:ret <4 x float> [[TMP2]]
+//
+// CHECK-BE-LABEL: @test_vcreateq_f32(
+// CHECK-BE-NEXT:  entry:
+// CHECK-BE-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
+// CHECK-BE-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[B:%.*]], i64 1
+// CHECK-BE-NEXT:[[TMP2:%.*]] = call <4 x float> @llvm.arm.mve.vreinterpretq.v4f32.v2i64(<2 x i64> [[TMP1]])
+// CHECK-BE-NEXT:ret <4 x float> [[TMP2]]
 //
 float32x4_t test_vcreateq_f32(uint64_t a, uint64_t b)
 {
 return vcreateq_f32(a, b);
 }
 
-// CHECK-LABEL: @test_vcreateq_s16(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <2 x i64> undef, i64 [[A:%.*]], i64 0
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <2 x i64> [[T

[PATCH] D100801: Thread safety analysis: Replace flags in FactEntry by SourceKind [NFC]

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

LGTM aside from a formatting nit. Thanks, this is more clear than a set of 
booleans.




Comment at: clang/lib/Analysis/ThreadSafety.cpp:138
+  bool declared() const { return Source == Declared; }
+  bool managed()  const { return Source == Managed; }
 

Might as well fix the clang-tidy diagnostic (we don't usually try to line up 
function qualifiers like that).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100801

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


[PATCH] D101202: Thread safety analysis: Fix false negative on break

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

LGTM, thank you for explaining the test cases, that helped (and I agree that 
the drive-by test changes look sensible to me).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101202

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


[PATCH] D101608: [WebAssembly] Support for WebAssembly globals in LLVM IR

2021-04-30 Thread Andy Wingo via Phabricator via cfe-commits
wingo updated this revision to Diff 341868.
wingo added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix clang datalayout expectations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101608

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  clang/test/CodeGen/target-data.c
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/global-get.ll
  llvm/test/CodeGen/WebAssembly/global-set.ll

Index: llvm/test/CodeGen/WebAssembly/global-set.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/global-set.ll
@@ -0,0 +1,57 @@
+; RUN: llc --mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s
+
+@i32_global = local_unnamed_addr addrspace(1) global i32 undef
+@i64_global = local_unnamed_addr addrspace(1) global i64 undef
+@f32_global = local_unnamed_addr addrspace(1) global float undef
+@f64_global = local_unnamed_addr addrspace(1) global double undef
+
+define void @set_i32_global(i32 %v) {
+; CHECK-LABEL: set_i32_global:
+; CHECK-NEXT: functype   set_i32_global (i32) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set i32_global
+; CHECK-NEXT: end_function
+  store i32 %v, i32 addrspace(1)* @i32_global
+  ret void
+}
+
+define void @set_i64_global(i64 %v) {
+; CHECK-LABEL: set_i64_global:
+; CHECK-NEXT: functype   set_i64_global (i64) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set i64_global
+; CHECK-NEXT: end_function
+  store i64 %v, i64 addrspace(1)* @i64_global
+  ret void
+}
+
+define void @set_f32_global(float %v) {
+; CHECK-LABEL: set_f32_global:
+; CHECK-NEXT: functype   set_f32_global (f32) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set f32_global
+; CHECK-NEXT: end_function
+  store float %v, float addrspace(1)* @f32_global
+  ret void
+}
+
+define void @set_f64_global(double %v) {
+; CHECK-LABEL: set_f64_global:
+; CHECK-NEXT: functype   set_f64_global (f64) -> ()
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: global.set f64_global
+; CHECK-NEXT: end_function
+  store double %v, double addrspace(1)* @f64_global
+  ret void
+}
+
+;; LLVM doesn't yet declare proper WebAssembly globals for these values,
+;; instead placing them in linear memory.  To fix in a followup.
+; FIXME-CHECK: .globl i32_global
+; FIXME-CHECK: .globaltype i32_global, i32
+; FIXME-CHECK: .globl i64_global
+; FIXME-CHECK: .globaltype i64_global, i64
+; FIXME-CHECK: .globl f32_global
+; FIXME-CHECK: .globaltype f32_global, f32
+; FIXME-CHECK: .globl f64_global
+; FIXME-CHECK: .globaltype f64_global, f64
Index: llvm/test/CodeGen/WebAssembly/global-get.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/global-get.ll
@@ -0,0 +1,54 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+@i32_global = local_unnamed_addr addrspace(1) global i32 undef
+@i64_global = local_unnamed_addr addrspace(1) global i64 undef
+@f32_global = local_unnamed_addr addrspace(1) global float undef
+@f64_global = local_unnamed_addr addrspace(1) global double undef
+
+define i32 @return_i32_global() {
+; CHECK-LABEL: return_i32_global:
+; CHECK-NEXT: functype   return_i32_global () -> (i32)
+; CHECK-NEXT: global.get i32_global
+; CHECK-NEXT: end_function
+  %v = load i32, i32 addrspace(1)* @i32_global
+  ret i32 %v
+}
+
+define i64 @return_i64_global() {
+; CHECK-LABEL: return_i64_global:
+; CHECK-NEXT: functype   return_i64_global () -> (i64)
+; CHECK-NEXT: global.get i64_global
+; CHECK-NEXT: end_function
+  %v = load i64, i64 addrspace(1)* @i64_global
+  ret i64 %v
+}
+
+define float @return_f32_global() {
+; CHECK-LABEL: return_f32_global:
+; CHECK-NEXT: functype   return_f32_global () -> (f32)
+; CHECK-NEXT: global.get f32_global
+; CHECK-NEXT: end_function
+  %v = load float, float addrspace(1)* @f32_global
+  ret float %v
+}
+
+define double @return_f64_global() {
+; CHECK-LABEL: return_f64_global:
+; CHECK-NEXT: functype   return_f64_global () -> (f64)
+; CHECK-NEXT: global.get f64_global
+; CHECK-NEXT: end_function
+  %v = load double, double addrspace(1)* @f64_global
+  ret double %v
+}
+
+
+;; LLVM doesn't yet declare proper WebAssembly globals for these values,
+;; instead placing them in linear memory.  To fix in a followup.
+; FIXME-CHECK: .globl i32_global
+; FIXME-CHECK: .globaltype i32_global, i32
+; FIXME-CHECK: .globl i64_global
+; FIXME-CHECK: .globaltype i64_global, i64
+; FIXME-CHECK: .globl f32_global
+; FIXME-CHECK: .globaltype f32_global, f32
+; FIXME-CHECK: .globl f64_global
+; FIXME-CHECK: .globaltype f64_global, f64
Index: llvm/li

[PATCH] D101519: [C++4OpenCL] Fix reinterpret_cast of vectors and types with address spaces

2021-04-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a subscriber: rjmccall.
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:2352
+  if (SrcType == DestType ||
+  (Self.LangOpts.OpenCL &&
+   Self.Context.removeAddrSpaceQualType(SrcType) ==

I am thinking of whether we can allow something weird to be written by relaxing 
this address space case

```
local int i;
const global int & ii = reinterpret_cast(i);
```

I think this code is completely meaningless as it requires creating a temporary 
in global address space? I am not sure what we will even emit in IR?

Embedded C doesn't regulate the conversions between non-pointer types with 
different address spaces but in OpenCL C we have allowed them apparently 
https://godbolt.org/z/9f75zxj7v. I am not sure whether this was done 
intentionally or not.

However, in C there are no references and other features that might create 
problems.

At the same time it seems C++ allows casting away `const` 
https://godbolt.org/z/fo3axbq3e

But it contradicts the comment below:

```
// C++ 5.2.10p2 has a note that mentions that, subject to all other
// restrictions, a cast to the same type is allowed so long as it does not
// cast away constness. In C++98, the intent was not entirely clear here,
// since all other paragraphs explicitly forbid casts to the same type.
// C++11 clarifies this case with p2.
```

I would like to see if @rjmccall has any opinion on whether reinterpreting 
between non-pointer types with different address spaces is reasonable?



Comment at: clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp:1
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+

Btw I assume your patch also allows reinterpret_cast between vectors? What 
happens if we cast b/w vector of 3 elements and vector of 4 elements?


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

https://reviews.llvm.org/D101519

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


[PATCH] D96418: [clang] Refactor mustprogress handling, add it to all loops in c++11+.

2021-04-30 Thread Florian Hahn 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 rG6c3129549374: [clang] Refactor mustprogress handling, add it 
to all loops in c++11+. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96418

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/attr-mustprogress.c
  clang/test/CodeGenCXX/attr-mustprogress.cpp

Index: clang/test/CodeGenCXX/attr-mustprogress.cpp
===
--- clang/test/CodeGenCXX/attr-mustprogress.cpp
+++ clang/test/CodeGenCXX/attr-mustprogress.cpp
@@ -23,20 +23,22 @@
 
 // CHECK: datalayout
 
-// CXX98-NOT: mustprogress
-// CXX11-NOT: mustprogress
-// FINITE-NOT: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
+// FINITE-NOT: mustprogress
 // CHECK-LABEL: @_Z2f0v(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:br label %for.cond
 // CHECK:   for.cond:
-// CHECK-NOT:br {{.*}} llvm.loop
+// CXX98-NOT:br {{.*}} llvm.loop
+// CXX11-NEXT:   br label %for.cond, !llvm.loop [[LOOP1:!.*]]
+// FINITE-NEXT:  br label %for.cond, !llvm.loop [[LOOP1:!.*]]
 void f0() {
   for (; ;) ;
 }
 
-// CXX98-NOT: mustprogress
-// CXX11-NOT: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
 // FINITE-NOT: mustprogress
 // CHECK-LABEL: @_Z2f1v(
 // CHECK-NEXT:  entry:
@@ -44,7 +46,9 @@
 // CHECK:   for.cond:
 // CHECK-NEXT:br i1 true, label %for.body, label %for.end
 // CHECK:   for.body:
-// CHECK-NOT:br {{.*}}, !llvm.loop
+// CXX98-NOT: br {{.*}}, !llvm.loop
+// CXX11-NEXT:br label %for.cond, !llvm.loop [[LOOP2:!.*]]
+// FINITE-NEXT:  br label %for.cond, !llvm.loop [[LOOP2:!.*]]
 // CHECK:   for.end:
 // CHECK-NEXT:ret void
 //
@@ -53,8 +57,8 @@
 ;
 }
 
-// CXX98-NOT: mustprogress
-// CXX11: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
 // FINITE-NOT: mustprogress
 // CHECK-LABEL: @_Z2f2v(
 // CHECK-NEXT:  entry:
@@ -66,8 +70,8 @@
 // CHECK-NEXT:br i1 [[CMP]], label %for.body, label %for.end
 // CHECK:   for.body:
 // CXX98-NOT:br {{.*}}, !llvm.loop
-// CXX11:br label %for.cond, !llvm.loop [[LOOP1:!.*]]
-// FINITE-NEXT:   br label %for.cond, !llvm.loop [[LOOP1:!.*]]
+// CXX11:br label %for.cond, !llvm.loop [[LOOP3:!.*]]
+// FINITE-NEXT:  br label %for.cond, !llvm.loop [[LOOP3:!.*]]
 // CHECK:   for.end:
 // CHECK-NEXT:ret void
 //
@@ -76,8 +80,8 @@
 ;
 }
 
-// CXX98-NOT: mustprogress
-// CXX11-NOT: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
 // FINITE-NOT: mustprogress
 // CHECK-LABEL: @_Z1Fv(
 // CHECK-NEXT:  entry:
@@ -85,7 +89,9 @@
 // CHECK:   for.cond:
 // CHECK-NEXT:br i1 true, label %for.body, label %for.end
 // CHECK:   for.body:
-// CHECK-NOT: br {{.*}}, !llvm.loop
+// CXX98-NOT: br {{.*}}, !llvm.loop
+// CXX11-NEXT:br label %for.cond, !llvm.loop [[LOOP4:!.*]]
+// FINITE-NEXT:   br label %for.cond, !llvm.loop [[LOOP4:!.*]]
 // CHECK:   for.end:
 // CHECK-NEXT:br label %for.cond1
 // CHECK:   for.cond1:
@@ -95,8 +101,8 @@
 // CHECK-NEXT:br i1 [[CMP]], label %for.body2, label %for.end3
 // CHECK:   for.body2:
 // CXX98-NOT: br {{.*}}, !llvm.loop
-// CXX11-NEXT:br label %for.cond1, !llvm.loop [[LOOP2:!.*]]
-// FINITE-NEXT:   br label %for.cond1, !llvm.loop [[LOOP2:!.*]]
+// CXX11-NEXT:br label %for.cond1, !llvm.loop [[LOOP5:!.*]]
+// FINITE-NEXT:   br label %for.cond1, !llvm.loop [[LOOP5:!.*]]
 // CHECK:   for.end3:
 // CHECK-NEXT:ret void
 //
@@ -107,8 +113,8 @@
 ;
 }
 
-// CXX98-NOT: mustprogress
-// CXX11-NOT: mustprogress
+// CXX98-NOT:  mustprogress
+// CXX11:  mustprogress
 // FINITE-NOT: mustprogress
 // CHECK-LABEL: @_Z2F2v(
 // CHECK-NEXT:  entry:
@@ -120,14 +126,16 @@
 // CHECK-NEXT:br i1 [[CMP]], label %for.body, label %for.end
 // CHECK:   for.body:
 // CXX98_NOT: br {{.*}} !llvm.loop
-// CXX11-NEXT:br label %for.cond, !llvm.loop [[LOOP3:!.*]]
-// FINITE-NEXT:br label %for.cond, !llvm.loop [[LOOP3:!.*]]
+// CXX11-NEXT:br label %for.cond, !llvm.loop [[LOOP6:!.*]]
+// FINITE-NEXT:   br label %for.cond, !llvm.loop [[LOOP6:!.*]]
 // CHECK:   for.end:
 // CHECK-NEXT:br label %for.cond1
 // CHECK:   for.cond1:
 // CHECK-NEXT:br i1 true, label %for.body2, label %for.end3
 // CHECK:   for.body2:
-// CHECK-NOT: br {{.*}}, !llvm.loop
+// CXX98-NOT: br {{.*}}, !llvm.loop
+// CXX11-NEXT:br label %for.cond1, !llvm.loop [[LOOP7:!.*]]
+// FINITE-NEXT:   br label %for.cond1, !llvm.loop [[LOOP7:!.*]]
 // CHECK:   for.end3:
 // CHECK-NEXT:ret void
 //
@@ -138,22 +146,24 @@
 ;
 }
 
-// CXX98-NOT: mustprogress
-// CXX11-NOT: mustprogress
-// FINITE-NOT:

[clang] 6c31295 - [clang] Refactor mustprogress handling, add it to all loops in c++11+.

2021-04-30 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2021-04-30T14:13:47+01:00
New Revision: 6c3129549374c0e81e28fd0a21e96f8087b63a78

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

LOG: [clang] Refactor mustprogress handling, add it to all loops in c++11+.

Currently Clang does not add mustprogress to inifinite loops with a
known constant condition, matching C11 behavior. The forward progress
guarantee in C++11 and later should allow us to add mustprogress to any
loop (http://eel.is/c++draft/intro.progress#1).

This allows us to simplify the code dealing with adding mustprogress a
bit.

Reviewed By: aaron.ballman, lebedev.ri

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGen/attr-mustprogress.c
clang/test/CodeGenCXX/attr-mustprogress.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index b6f4f98fbd2ea..0fc0ba10e6674 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -816,20 +816,14 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
 
   // while(1) is common, avoid extra exit blocks.  Be sure
   // to correctly handle break/continue though.
-  bool EmitBoolCondBranch = true;
-  bool LoopMustProgress = false;
-  if (llvm::ConstantInt *C = dyn_cast(BoolCondVal)) {
-if (C->isOne()) {
-  EmitBoolCondBranch = false;
-  FnIsMustProgress = false;
-}
-  } else if (LanguageRequiresProgress())
-LoopMustProgress = true;
-
+  llvm::ConstantInt *C = dyn_cast(BoolCondVal);
+  bool CondIsConstInt = C != nullptr;
+  bool EmitBoolCondBranch = !CondIsConstInt || !C->isOne();
   const SourceRange &R = S.getSourceRange();
   LoopStack.push(LoopHeader.getBlock(), CGM.getContext(), CGM.getCodeGenOpts(),
  WhileAttrs, SourceLocToDebugLoc(R.getBegin()),
- SourceLocToDebugLoc(R.getEnd()), LoopMustProgress);
+ SourceLocToDebugLoc(R.getEnd()),
+ checkIfLoopMustProgress(CondIsConstInt));
 
   // As long as the condition is true, go to the loop body.
   llvm::BasicBlock *LoopBody = createBasicBlock("while.body");
@@ -920,20 +914,15 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S,
 
   // "do {} while (0)" is common in macros, avoid extra blocks.  Be sure
   // to correctly handle break/continue though.
-  bool EmitBoolCondBranch = true;
-  bool LoopMustProgress = false;
-  if (llvm::ConstantInt *C = dyn_cast(BoolCondVal)) {
-if (C->isZero())
-  EmitBoolCondBranch = false;
-else if (C->isOne())
-  FnIsMustProgress = false;
-  } else if (LanguageRequiresProgress())
-LoopMustProgress = true;
+  llvm::ConstantInt *C = dyn_cast(BoolCondVal);
+  bool CondIsConstInt = C;
+  bool EmitBoolCondBranch = !C || !C->isZero();
 
   const SourceRange &R = S.getSourceRange();
   LoopStack.push(LoopBody, CGM.getContext(), CGM.getCodeGenOpts(), DoAttrs,
  SourceLocToDebugLoc(R.getBegin()),
- SourceLocToDebugLoc(R.getEnd()), LoopMustProgress);
+ SourceLocToDebugLoc(R.getEnd()),
+ checkIfLoopMustProgress(CondIsConstInt));
 
   // As long as the condition is true, iterate the loop.
   if (EmitBoolCondBranch) {
@@ -971,20 +960,15 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
   llvm::BasicBlock *CondBlock = CondDest.getBlock();
   EmitBlock(CondBlock);
 
-  bool LoopMustProgress = false;
   Expr::EvalResult Result;
-  if (LanguageRequiresProgress()) {
-if (!S.getCond()) {
-  FnIsMustProgress = false;
-} else if (!S.getCond()->EvaluateAsInt(Result, getContext())) {
-  LoopMustProgress = true;
-}
-  }
+  bool CondIsConstInt =
+  !S.getCond() || S.getCond()->EvaluateAsInt(Result, getContext());
 
   const SourceRange &R = S.getSourceRange();
   LoopStack.push(CondBlock, CGM.getContext(), CGM.getCodeGenOpts(), ForAttrs,
  SourceLocToDebugLoc(R.getBegin()),
- SourceLocToDebugLoc(R.getEnd()), LoopMustProgress);
+ SourceLocToDebugLoc(R.getEnd()),
+ checkIfLoopMustProgress(CondIsConstInt));
 
   // Create a cleanup scope for the condition variable cleanups.
   LexicalScope ConditionScope(*this, S.getSourceRange());
@@ -1033,10 +1017,6 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
   BoolCondVal = emitCondLikelihoodViaExpectIntrinsic(
   BoolCondVal, Stmt::getLikelihood(S.getBody()));
 
-if (llvm::ConstantInt *C = dyn_cast(BoolCondVal))
-  if (C->isOne())
-FnIsMustProgress = false;
-
 Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
 
 if (ExitBlock != LoopExit.getBlock()) {

diff  --git a/clang/

[PATCH] D101624: [clang-tidy] Make performance-inefficient-vector-operation work on members

2021-04-30 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh, gribozavr2.
Herald added a subscriber: xazax.hun.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Fixes https://llvm.org/PR50157

Adds support for when the container being read from in a range-for is a member 
of a struct.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101624

Files:
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
@@ -44,7 +44,7 @@
   void reserve(size_t n);
   void resize(size_t n);
 
-  size_t size();
+  size_t size() const;
   const_reference operator[] (size_type) const;
   reference operator[] (size_type);
 
@@ -359,3 +359,31 @@
 }
   }
 }
+
+struct StructWithFieldContainer {
+  std::vector Numbers;
+  std::vector getNumbers() const {
+std::vector Result;
+// CHECK-FIXES: Result.reserve(Numbers.size());
+for (auto Number : Numbers) {
+  Result.push_back(Number);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+return Result;
+  }
+};
+
+StructWithFieldContainer getStructWithField();
+
+void foo(const StructWithFieldContainer &Src) {
+  std::vector A;
+  // CHECK-FIXES: A.reserve(Src.Numbers.size());
+  for (auto Number : Src.Numbers) {
+A.push_back(Number);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+  std::vector B;
+  for (auto Number : getStructWithField().Numbers) {
+B.push_back(Number);
+  }
+}
Index: 
clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
@@ -68,6 +68,10 @@
   "::std::unordered_map", "::std::array", "::std::deque")));
 }
 
+AST_MATCHER(Expr, hasSideEffects) {
+  return Node.HasSideEffects(Finder->getASTContext());
+}
+
 } // namespace
 
 InefficientVectorOperationCheck::InefficientVectorOperationCheck(
@@ -145,7 +149,10 @@
   // FIXME: Support more complex range-expressions.
   Finder->addMatcher(
   cxxForRangeStmt(
-  hasRangeInit(declRefExpr(supportedContainerTypesMatcher())),
+  hasRangeInit(
+  anyOf(declRefExpr(supportedContainerTypesMatcher()),
+memberExpr(hasObjectExpression(unless(hasSideEffects())),
+   supportedContainerTypesMatcher(,
   HasInterestingLoopBody, InInterestingCompoundStmt)
   .bind(RangeLoopName),
   this);


Index: clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
@@ -44,7 +44,7 @@
   void reserve(size_t n);
   void resize(size_t n);
 
-  size_t size();
+  size_t size() const;
   const_reference operator[] (size_type) const;
   reference operator[] (size_type);
 
@@ -359,3 +359,31 @@
 }
   }
 }
+
+struct StructWithFieldContainer {
+  std::vector Numbers;
+  std::vector getNumbers() const {
+std::vector Result;
+// CHECK-FIXES: Result.reserve(Numbers.size());
+for (auto Number : Numbers) {
+  Result.push_back(Number);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+return Result;
+  }
+};
+
+StructWithFieldContainer getStructWithField();
+
+void foo(const StructWithFieldContainer &Src) {
+  std::vector A;
+  // CHECK-FIXES: A.reserve(Src.Numbers.size());
+  for (auto Number : Src.Numbers) {
+A.push_back(Number);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+  std::vector B;
+  for (auto Number : getStructWithField().Numbers) {
+B.push_back(Number);
+  }
+}
Index: clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
@@ -68,6 +68,10 @@
   "::std::unordered_map", "::std::array", "::std::deque")));
 }
 
+AST_MATCHER(Expr, hasSideEffects) {
+  return Node.HasSideEffects(Finder->getASTContext());
+}
+
 } // namespace
 
 

[PATCH] D100396: [SYCL] Enable `opencl_global_[host,device]` attributes for SYCL

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



Comment at: clang/include/clang/AST/Type.h:489
B == LangAS::opencl_global_host)) ||
+   (A == LangAS::sycl_global && (B == LangAS::sycl_global_device ||
+ B == LangAS::sycl_global_host)) ||

Ok, so you want to allow converting implicitly to global but not to device/host?

Let's update the doc straight away!



Comment at: clang/test/SemaSYCL/address-space-conversions.cpp:74
+  GLOB = GLOB_DEVICE;
+  GLOB_DEVICE = GLOB; // expected-error {{assigning '__global int *' to 
'__global_device int *' changes address space of pointer}}
 }

Let's add explicit casts too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100396

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


[PATCH] D100396: [SYCL] Enable `opencl_global_[host,device]` attributes for SYCL

2021-04-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:2495
 break;
   //   ::= "SY" [ "global" | "local" | "private" ]
   case LangAS::sycl_global:

Can you also update this comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100396

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


[PATCH] D101617: [clang-tidy] Tweak diag ranges for bugprone-sizeof-expression

2021-04-30 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 341883.
njames93 added a comment.
Herald added subscribers: usaxena95, kadircet, arphaman.

Fix clangd test cases failing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101617

Files:
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clangd/test/diagnostics.test
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -77,7 +77,7 @@
   sum += sizeof(LEN + 1);
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(K)'
   sum += sizeof(sum, LEN);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(..., ...)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: suspicious usage of 'sizeof(..., ...)'
   sum += sizeof(AsBool());
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof()' on an expression that results in an integer
   sum += sizeof(AsInt());
@@ -103,41 +103,41 @@
   sum += sizeof(LEN + - + -sizeof(X));
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(sizeof(...))'
   sum += sizeof(char) / sizeof(char);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
   sum += sizeof(A) / sizeof(S);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
   sum += sizeof(char) / sizeof(int);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
   sum += sizeof(char) / sizeof(A);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
   sum += sizeof(B[0]) / sizeof(A);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
   sum += sizeof(ptr) / sizeof(char);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
   sum += sizeof(ptr) / sizeof(ptr[0]);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
   sum += sizeof(ptr) / sizeof(char*);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
   sum += sizeof(ptr) / sizeof(void*);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
   sum += sizeof(ptr) / sizeof(const void volatile*);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
   sum += sizeof(ptr) / sizeof(char);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
   sum += sizeof(ptr) / sizeof(ptr[0]);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
   sum += sizeof(int) * sizeof(char);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious 'sizeof' by 'sizeof' multiplication
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious 'sizeof' b

[clang] 3ec82e5 - [OpenCL] Prevent adding vendor extensions for all targets

2021-04-30 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-04-30T14:42:51+01:00
New Revision: 3ec82e519513b231bb0e8dd5e098c4c5a51501a2

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

LOG: [OpenCL] Prevent adding vendor extensions for all targets

Removed extension begin/end pragma as it has no effect and
it is added unconditionally for all targets.

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

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Headers/opencl-c.h
clang/test/Headers/opencl-c-header.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index dd038a23ee0f9..72f8c2576ebd3 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -567,7 +567,6 @@ int printf(__constant const char* st, ...) 
__attribute__((format(printf, 1, 2)))
 #endif
 
 #ifdef cl_intel_device_side_avc_motion_estimation
-#pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : begin
 
 #define CLK_AVC_ME_MAJOR_16x16_INTEL 0x0
 #define CLK_AVC_ME_MAJOR_16x8_INTEL 0x1
@@ -701,7 +700,6 @@ int printf(__constant const char* st, ...) 
__attribute__((format(printf, 1, 2)))
 #define CLK_AVC_IME_RESULT_DUAL_REFERENCE_STREAMOUT_INITIALIZE_INTEL 0x0
 #define CLK_AVC_IME_RESULT_DUAL_REFERENCE_STREAMIN_INITIALIZE_INTEL 0x0
 
-#pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : end
 #endif // cl_intel_device_side_avc_motion_estimation
 
 // Disable any extensions we may have enabled previously.

diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 6a532db4b1cb2..62dbe459baa76 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -23,10 +23,11 @@
 #endif //cl_khr_3d_image_writes
 #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+
+#if (defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_1_2)) && defined(__SPIR__)
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : begin
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : end
-#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_1_2)
+#endif // (defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_1_2)) && defined(__SPIR__)
 
 #define __ovld __attribute__((overloadable))
 #define __conv __attribute__((convergent))

diff  --git a/clang/test/Headers/opencl-c-header.cl 
b/clang/test/Headers/opencl-c-header.cl
index f72cea61fcd91..f97a089e744a4 100644
--- a/clang/test/Headers/opencl-c-header.cl
+++ b/clang/test/Headers/opencl-c-header.cl
@@ -89,9 +89,10 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 
 // Check that extension macros are defined correctly.
 
-// FIXME: this should not be defined for all targets
-// Verify that non-builtin cl_intel_planar_yuv extension is defined from
-// OpenCL 1.2 onwards.
+// For SPIR all extensions are supported.
+#if defined(__SPIR__)
+
+// Verify that cl_intel_planar_yuv extension is defined from OpenCL 1.2 
onwards.
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 // expected-no-diagnostics
 #else //__OPENCL_C_VERSION__
@@ -99,9 +100,6 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 #endif //__OPENCL_C_VERSION__
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
 
-// For SPIR all extensions are supported.
-#if defined(__SPIR__)
-
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 
 #if cl_khr_subgroup_extended_types != 1



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


[PATCH] D92244: [OpenCL] Prevent adding vendor extensions for all targets

2021-04-30 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ec82e519513: [OpenCL] Prevent adding vendor extensions for 
all targets (authored by Anastasia).
Herald added a subscriber: ldrumm.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D92244?vs=308103&id=341884#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92244

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h
  clang/test/Headers/opencl-c-header.cl


Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -89,9 +89,10 @@
 
 // Check that extension macros are defined correctly.
 
-// FIXME: this should not be defined for all targets
-// Verify that non-builtin cl_intel_planar_yuv extension is defined from
-// OpenCL 1.2 onwards.
+// For SPIR all extensions are supported.
+#if defined(__SPIR__)
+
+// Verify that cl_intel_planar_yuv extension is defined from OpenCL 1.2 
onwards.
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 // expected-no-diagnostics
 #else //__OPENCL_C_VERSION__
@@ -99,9 +100,6 @@
 #endif //__OPENCL_C_VERSION__
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
 
-// For SPIR all extensions are supported.
-#if defined(__SPIR__)
-
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 
 #if cl_khr_subgroup_extended_types != 1
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -23,10 +23,11 @@
 #endif //cl_khr_3d_image_writes
 #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+
+#if (defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_1_2)) && defined(__SPIR__)
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : begin
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : end
-#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_1_2)
+#endif // (defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_1_2)) && defined(__SPIR__)
 
 #define __ovld __attribute__((overloadable))
 #define __conv __attribute__((convergent))
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -567,7 +567,6 @@
 #endif
 
 #ifdef cl_intel_device_side_avc_motion_estimation
-#pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : begin
 
 #define CLK_AVC_ME_MAJOR_16x16_INTEL 0x0
 #define CLK_AVC_ME_MAJOR_16x8_INTEL 0x1
@@ -701,7 +700,6 @@
 #define CLK_AVC_IME_RESULT_DUAL_REFERENCE_STREAMOUT_INITIALIZE_INTEL 0x0
 #define CLK_AVC_IME_RESULT_DUAL_REFERENCE_STREAMIN_INITIALIZE_INTEL 0x0
 
-#pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : end
 #endif // cl_intel_device_side_avc_motion_estimation
 
 // Disable any extensions we may have enabled previously.


Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -89,9 +89,10 @@
 
 // Check that extension macros are defined correctly.
 
-// FIXME: this should not be defined for all targets
-// Verify that non-builtin cl_intel_planar_yuv extension is defined from
-// OpenCL 1.2 onwards.
+// For SPIR all extensions are supported.
+#if defined(__SPIR__)
+
+// Verify that cl_intel_planar_yuv extension is defined from OpenCL 1.2 onwards.
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 // expected-no-diagnostics
 #else //__OPENCL_C_VERSION__
@@ -99,9 +100,6 @@
 #endif //__OPENCL_C_VERSION__
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
 
-// For SPIR all extensions are supported.
-#if defined(__SPIR__)
-
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 
 #if cl_khr_subgroup_extended_types != 1
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -23,10 +23,11 @@
 #endif //cl_khr_3d_image_writes
 #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+
+#if (defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)) && defined(__SPIR__)
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : begin
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : end
-#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+#endif // (defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)) && de

[PATCH] D101628: [Format] Don't sort includes if DisableFormat is true

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

Fixes https://llvm.org/PR35099.

I'm not sure if this decision was intentional but its definitely confusing for 
users.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101628

Files:
  clang/lib/Format/Format.cpp


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2603,7 +2603,7 @@
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2603,7 +2603,7 @@
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
-  if (!Style.SortIncludes)
+  if (!Style.SortIncludes || Style.DisableFormat)
 return Replaces;
   if (isLikelyXml(Code))
 return Replaces;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101554: [clangd] Add support for the `defaultLibrary` semantic token modifier

2021-04-30 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:413
+  /// different heuristics may be used in the future (e.g. sysroot paths).
+  bool inDefaultLibrary(SourceLocation Loc) const {
+if (!Loc.isValid())

kadircet wrote:
> you can make this a free function by accepting a decl instead. as 
> sourcemanager is accessible via `D->getASTContext().getSourceManager()`. this 
> way you don't need to modify signatures for `scopeModifier` overloads (and 
> get rid of the duplicate in `CollectExtraHighlightings`).
TIL decls can reference the ASTContext. I can swap over to that if you'd like, 
the one advantage the current approach has is that we can easily add a caching 
layer into the Builder to say cache the results by FileID (but I'm not sure how 
useful/necessary such caching would be)



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:436
+  if (HB.inDefaultLibrary(D->getLocation()))
+return HighlightingModifier::DefaultLibrary;
   const DeclContext *DC = D->getDeclContext();

sammccall wrote:
> kadircet wrote:
> > I don't use semantic highlighting enough to judge whether it is more useful 
> > to say `DefaultLibrary` than `{Class,Function}Scope`. (i.e. having the 
> > check here vs at the end of the function as a fallback). Can you provide 
> > some rationale about the decision (probably as comments in code)?
> > 
> > By looking at the testcase, I suppose you are trying to indicate 
> > "overriden"/"extended" attribute of a symbol, which makes sense but would 
> > be nice to know if there's more. I am just worried that this is very obj-c 
> > specific and won't really generalize to c/c++. As most of the system 
> > headers only provide platform specific structs (e.g. posix) and they are 
> > almost never extended. So it might be confusing for user to see different 
> > colors on some memberexprs.
> I think default-library isn't a scope modifier at all, it should be 
> independent.
> 
> e.g. std::string is defaultlLibrary | globalScope, while 
> std::string::push_back() is defaultLibrary | classScope.
I can break it up if you'd like - just let me know what you had in mind. I can 
change the scopeModifier function's name and then have it return a list of 
modifiers or I can just add a new function which all existing callers of 
scopeModifier will also need to call.

And what we're really trying to do here is color the system/SDK symbols 
differently - this is definitely useful for iOS dev since Apple has a very 
large SDK, but if it's not useful for C++ maybe we could just make this 
configurable?



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:465
+llvm::Optional
+scopeModifier(const Type *T, const HighlightingsBuilder &HB) {
   if (!T)

sammccall wrote:
> I'm confused about the interface change - looks like the new parameter never 
> actually used, just passed around
It's used (currently) as the HighlightingsBuilder is the one who checks for 
default/systemness





Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:474
+return scopeModifier(TD, HB);
+  if (auto *OT = dyn_cast(T))
+return scopeModifier(OT->getInterface(), HB);

kadircet wrote:
> should this be put in a separate patch?
If you want I can move it over


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101554

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


[PATCH] D89055: [analyzer] Wrong type cast occures during pointer dereferencing after type punning

2021-04-30 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:765
+R = StateMgr.getStoreManager().castRegion(ER, CastTy);
+return loc::MemRegionVal(R);
+  }

This caused some problems with assertion failures, see 
https://bugs.llvm.org/show_bug.cgi?id=50179


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89055

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


[PATCH] D101630: [HIP] Fix device-only compilation

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

When clang compiles a HIP program with -E, there are multiple output
files for host and different GPU archs. Clang uses clang-offload-bundler
to bundle them as one output file.

Currently clang does this for combined host/device compilation but does not do
it for device-only compilation. This causes issue when there are multiple
GPU arch's in device-only compilation. If -o is specified, the output for
different GPU arch's will overwrite each other.

This patch fixes that by bundling the output files if there are multiple
GPU arch's. This is consistent with the behavior for combined host/device 
compilation.
Clang will automatically unbundle it if the preprocessor expansion output
is used as input.

The same thing with -emit-llvm or -S.


https://reviews.llvm.org/D101630

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Driver/hip-output-file-name.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-rdc-device-only.hip
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -117,6 +117,9 @@
 /// The index of the host input in the list of inputs.
 static unsigned HostInputIndex = ~0u;
 
+/// Whether not having host target is allowed.
+static bool AllowNoHost = false;
+
 /// Path to the current binary.
 static std::string BundlerExecutable;
 
@@ -857,9 +860,10 @@
   }
 
   // Get the file handler. We use the host buffer as reference.
-  assert(HostInputIndex != ~0u && "Host input index undefined??");
+  assert((HostInputIndex != ~0u || AllowNoHost) &&
+ "Host input index undefined??");
   Expected> FileHandlerOrErr =
-  CreateFileHandler(*InputBuffers[HostInputIndex]);
+  CreateFileHandler(*InputBuffers[AllowNoHost ? 0 : HostInputIndex]);
   if (!FileHandlerOrErr)
 return FileHandlerOrErr.takeError();
 
@@ -1126,6 +1130,7 @@
   // have exactly one host target.
   unsigned Index = 0u;
   unsigned HostTargetNum = 0u;
+  bool HIPOnly = true;
   llvm::DenseSet ParsedTargets;
   for (StringRef Target : TargetNames) {
 if (ParsedTargets.contains(Target)) {
@@ -1167,12 +1172,21 @@
   HostInputIndex = Index;
 }
 
+if (Kind != "hip" && Kind != "hipv4")
+  HIPOnly = false;
+
 ++Index;
   }
 
+  // HIP uses clang-offload-bundler to bundle device-only compilation results
+  // for multiple GPU archs, therefore allow no host target if all entries
+  // are for HIP.
+  AllowNoHost = HIPOnly;
+
   // Host triple is not really needed for unbundling operation, so do not
   // treat missing host triple as error if we do unbundling.
-  if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {
+  if ((Unbundle && HostTargetNum > 1) ||
+  (!Unbundle && HostTargetNum != 1 && !AllowNoHost)) {
 reportError(createStringError(errc::invalid_argument,
   "expecting exactly one host target but got " +
   Twine(HostTargetNum)));
Index: clang/test/Driver/hip-rdc-device-only.hip
===
--- clang/test/Driver/hip-rdc-device-only.hip
+++ clang/test/Driver/hip-rdc-device-only.hip
@@ -56,8 +56,8 @@
 // COMMON-SAME: "-fapply-global-visibility-to-externs"
 // COMMON-SAME: "-target-cpu" "gfx803"
 // COMMON-SAME: "-fgpu-rdc"
-// EMITBC-SAME: {{.*}} "-o" {{"a.*bc"}} "-x" "hip"
-// EMITLL-SAME: {{.*}} "-o" {{"a.*ll"}} "-x" "hip"
+// EMITBC-SAME: {{.*}} "-o" {{".*a.*bc"}} "-x" "hip"
+// EMITLL-SAME: {{.*}} "-o" {{".*a.*ll"}} "-x" "hip"
 // CHECK-SAME: {{.*}} {{".*a.cu"}}
 
 // COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -69,10 +69,14 @@
 // COMMON-SAME: "-fapply-global-visibility-to-externs"
 // COMMON-SAME: "-target-cpu" "gfx900"
 // COMMON-SAME: "-fgpu-rdc"
-// EMITBC-SAME: {{.*}} "-o" {{"a.*bc"}} "-x" "hip"
-// EMITLL-SAME: {{.*}} "-o" {{"a.*ll"}} "-x" "hip"
+// EMITBC-SAME: {{.*}} "-o" {{".*a.*bc"}} "-x" "hip"
+// EMITLL-SAME: {{.*}} "-o" {{".*a.*ll"}} "-x" "hip"
 // COMMON-SAME: {{.*}} {{".*a.cu"}}
 
+// COMMON: "{{.*}}clang-offload-bundler" "-type={{(bc|ll)}}"
+// COMMON-SAME: "-targets=hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
+// COMMON-SAME: "-outputs=a-hip-amdgcn-amd-amdhsa.{{(bc|ll)}}"
+
 // COMMON: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // COMMON-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // EMITBC-SAME: "-emit-llvm-bc"
@@ -82,8 +86,8 @@
 // COMMON-SAME: "-fapply-global-visibility-to-externs"
 // COMMON-SAME: "-target-cpu" "gfx803"
 // COMMON-SAME: "-fgpu-rdc"
-// EMITBC-SAME: {{.*}} "-o" {{"b.*bc"}} "-x" "hip"
-// EMITLL-SAME: {{.*}} "-o" {{"b.*ll"}} "-x" "hip"
+// EMITBC-SAME: {{.*}} 

[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-30 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 marked an inline comment as done.
DNS320 added a comment.

In D100092#2726808 , @steveire wrote:

> I implemented something like this recently too. The code I was trying to 
> refactor was something like
>
>   auto ii = 0;
>   for (ii = 0; ii < thing.size(); ++ii)
>   {
>   // code
>   }
>   // code
>   for (ii = 0; ii < thing.size(); ++ii)
>   {
>   // code
>   }
>   // code
>   for (ii = 0; ii < thing.size(); ++ii)
>   {
>   // code
>   }
>
> ie, the variable was used repeatedly, but always initialized in the loop.
>
> I also had code like
>
>   auto ii = 0;
>   for (ii = 0; ii < thing.size(); ++ii)
>   {
>   // code
>   }
>   // code
>   ii = getNumber();
>   doSomething(ii);
>
> ie, the next statement referring to `ii` outside the loop was an assignment, 
> so I could just change it to
>
>   for (auto ii = 0; ii < thing.size(); ++ii)
>   {
>   // code
>   }
>   // code
>   auto ii = getNumber();
>   doSomething(ii);
>
> You don't necessarily have to handle these cases in the initial version of 
> this check, but you could consider them in the future.

Thank you for your comment!
I agree with you and I can see the need to cover such code with a style check.
The initial check was contributed to implement the ES.74 C++ Core Guideline. As 
I think, your code examples should be covered by a check that implements the 
ES.26 rule of the C++ Core Guidelines, which could be implemented in the future.
Due to your comment, I noticed the link to the ES.26 rule in the description of 
this check is not accurate, so I will remove it.




Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.cpp:37
+  bool VisitDeclRefExpr(DeclRefExpr *D) {
+if (const VarDecl *To = dyn_cast(D->getDecl())) {
+  if (To == MatchedDecl &&

Eugene.Zelenko wrote:
> `const auto*` could be used because type is spelled in same statement.
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100092

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


[PATCH] D101554: [clangd] Add support for the `defaultLibrary` semantic token modifier

2021-04-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:436
+  if (HB.inDefaultLibrary(D->getLocation()))
+return HighlightingModifier::DefaultLibrary;
   const DeclContext *DC = D->getDeclContext();

dgoldman wrote:
> sammccall wrote:
> > kadircet wrote:
> > > I don't use semantic highlighting enough to judge whether it is more 
> > > useful to say `DefaultLibrary` than `{Class,Function}Scope`. (i.e. having 
> > > the check here vs at the end of the function as a fallback). Can you 
> > > provide some rationale about the decision (probably as comments in code)?
> > > 
> > > By looking at the testcase, I suppose you are trying to indicate 
> > > "overriden"/"extended" attribute of a symbol, which makes sense but would 
> > > be nice to know if there's more. I am just worried that this is very 
> > > obj-c specific and won't really generalize to c/c++. As most of the 
> > > system headers only provide platform specific structs (e.g. posix) and 
> > > they are almost never extended. So it might be confusing for user to see 
> > > different colors on some memberexprs.
> > I think default-library isn't a scope modifier at all, it should be 
> > independent.
> > 
> > e.g. std::string is defaultlLibrary | globalScope, while 
> > std::string::push_back() is defaultLibrary | classScope.
> I can break it up if you'd like - just let me know what you had in mind. I 
> can change the scopeModifier function's name and then have it return a list 
> of modifiers or I can just add a new function which all existing callers of 
> scopeModifier will also need to call.
> 
> And what we're really trying to do here is color the system/SDK symbols 
> differently - this is definitely useful for iOS dev since Apple has a very 
> large SDK, but if it's not useful for C++ maybe we could just make this 
> configurable?
> just let me know what you had in mind

I think this should follow `isStatic()` etc: just a boolean function that gets 
called in the minimum number of places needed.

scopeModifier is slightly different pattern because there are a bunch of 
mutually-exclusive modifiers. defaultLibrary is (mostly) independent of other 
modifiers.

> if it's not useful for C++ maybe we could just make this configurable

No need really - sending more modifiers is cheap (one string at startup and one 
bit in an integer we're sending anyway).
It's up to clients to style the ones they care about, and at least in VSCode 
this can be customized per-lang I think. Important thing is that they don't 
interact with other modifiers.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:465
+llvm::Optional
+scopeModifier(const Type *T, const HighlightingsBuilder &HB) {
   if (!T)

dgoldman wrote:
> sammccall wrote:
> > I'm confused about the interface change - looks like the new parameter 
> > never actually used, just passed around
> It's used (currently) as the HighlightingsBuilder is the one who checks for 
> default/systemness
> 
> 
Oops yes, in the other overload.

Please do remove this as Kadir suggests, it's noisy and makes inputs/outputs 
less clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101554

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


[PATCH] D100667: [clang] Fix assert() crash when checking undeduced arg alignment

2021-04-30 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 341898.
adamcz added a comment.

typeof


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100667

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast 
-frecovery-ast-type -o - %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast 
-frecovery-ast-type -o - %s -std=gnu++17 -fsyntax-only -verify
 
 namespace test0 {
 struct Indestructible {
@@ -26,7 +26,7 @@
 void foo(); // expected-note 3{{requires 0 arguments}}
 void func() {
   // verify that "field has incomplete type" diagnostic is suppressed.
-  typeof(foo(42)) var; // expected-error {{no matching function}}
+  typeof(foo(42)) var; // expected-error {{no matching function}} \
 
   // FIXME: suppress the "cannot initialize a variable" diagnostic.
   int a = foo(1); // expected-error {{no matching function}} \
@@ -116,3 +116,23 @@
 template const int k = f(T()); // expected-error {{no matching 
function}}
 static_assert(k == 1, ""); // expected-note {{instantiation of}}
 }
+
+namespace test11 {
+// Verify we do not assert()-fail here.
+template  void foo(T &t);
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
+} // namespace test11
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19662,8 +19662,10 @@
   if (isSFINAEContext())
 return ExprError();
 
-  if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
+  if (T.isNull() || T->isUndeducedType() ||
+  !Context.getLangOpts().RecoveryASTType)
 // We don't know the concrete type, fallback to dependent type.
 T = Context.DependentTy;
+
   return RecoveryExpr::Create(Context, T, Begin, End, SubExprs);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4540,8 +4540,7 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast -frecovery-ast-type -o - %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast -frecovery-ast-type -o - %s -std=gnu++17 -fsyntax-only -verify
 
 namespace test0 {
 struct Indestructible {
@@ -26,7 +26,7 @@
 void foo(); // expected-note 3{{requires 0 arguments}}
 void func() {
   // verify that "field has incomplete type" diagnostic is suppressed.
-  typeof(foo(42)) var; // expected-error {{no matching function}}
+  typeof(foo(42)) var; // expected-error {{no matching function}} \
 
   // FIXME: suppress the "cannot initialize a variable" diagnostic.
   int a = foo(1); // expected-error {{no matching function}} \
@@ -116,3 +116,23 @@
 template const int k = f(T()); // expected-error {{no matching function}}
 static_assert(k == 1, ""); // expected-note {{instantiation of}}
 }
+
+namespace test11 {
+// Verify we do not assert()-fail here.
+template  void foo(T &t);
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
+} // namespace test11
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19662,8 +19662,10 @@
   if (isSFINAEContext())
 return ExprError();
 
-  if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
+  if (T.isNull() || T->isUndeducedType() ||
+  !Context.getLangOpts().RecoveryASTType)
 // We don't know the concrete type, fallback to dependent type.
 T = Context.DependentTy;
+
   return Recovery

[PATCH] D77013: [AMDGPU] Add options -mamdgpu-ieee -mno-amdgpu-ieee

2021-04-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:131-133
+  "invalid argument '-mno-amdgpu-ieee' only allowed with floating point 
options "
+  "which do not honor NaNs, e.g. '-fno-honor-nans', '-ffast-math', "
+  "'-ffinite-math-only', etc.">;

arsenm wrote:
> e.g. and a list of flags seems weird for an error message. How about "only 
> allowed with relaxed NaN handling"?
sounds good. will do. I think users should be able to look up clang options 
which relax NaN handling.


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

https://reviews.llvm.org/D77013

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


[PATCH] D77013: [AMDGPU] Add options -mamdgpu-ieee -mno-amdgpu-ieee

2021-04-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 341900.
yaxunl marked an inline comment as done.
yaxunl added a comment.

revised by Matt's comments


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

https://reviews.llvm.org/D77013

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenOpenCL/amdgpu-ieee.cl

Index: clang/test/CodeGenOpenCL/amdgpu-ieee.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/amdgpu-ieee.cl
@@ -0,0 +1,47 @@
+// REQUIRES: amdgpu-registered-target
+//
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   | FileCheck -check-prefixes=COMMON,ON %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -mno-amdgpu-ieee -menable-no-nans \
+// RUN:   | FileCheck -check-prefixes=COMMON,OFF %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -mno-amdgpu-ieee -cl-fast-relaxed-math \
+// RUN:   | FileCheck -check-prefixes=COMMON,OFF %s
+
+// Check AMDGCN ISA generation.
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O3 -S -o - %s \
+// RUN:   | FileCheck -check-prefixes=ISA-ON %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -O3 -S -o - %s \
+// RUN:   -mno-amdgpu-ieee -menable-no-nans \
+// RUN:   | FileCheck -check-prefixes=ISA-OFF %s
+
+// Check diagnostics when using -mno-amdgpu-ieee without NoHonorNaNs.
+
+// RUN: not %clang_cc1 -triple amdgcn-amd-amdhsa -O0 -emit-llvm -o - %s \
+// RUN:   -mno-amdgpu-ieee 2>&1 | FileCheck -check-prefixes=DIAG %s
+
+// COMMON: define{{.*}} amdgpu_kernel void @kern{{.*}} [[ATTRS1:#[0-9]+]]
+// ISA-ON: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-ON: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-ON: v_min_f32_e32
+// ISA-ON: ; IeeeMode: 1
+// ISA-OFF-NOT: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-OFF-NOT: v_mul_f32_e64 v{{[0-9]+}}, 1.0, s{{[0-9]+}}
+// ISA-OFF: v_min_f32_e32
+// ISA-OFF: ; IeeeMode: 0
+kernel void kern(global float *x, float y, float z) {
+  *x = __builtin_fmin(y, z);
+}
+
+// COMMON: define{{.*}}void @fun() [[ATTRS2:#[0-9]+]]
+void fun() {
+}
+
+// ON-NOT: attributes [[ATTRS1]] = {{.*}} "amdgpu-ieee"
+// OFF: attributes [[ATTRS1]] = {{.*}} "amdgpu-ieee"="false"{{.*}}"no-nans-fp-math"="true"{{.*}}"no-trapping-math"="true"
+// ON-NOT: attributes [[ATTRS2]] = {{.*}} "amdgpu-ieee"
+// OFF: attributes [[ATTRS2]] = {{.*}} "amdgpu-ieee"="false"{{.*}}"no-nans-fp-math"="true"{{.*}}"no-trapping-math"="true"
+
+// DIAG: invalid argument '-mno-amdgpu-ieee' only allowed with floating point options which do not honor NaNs, e.g. '-fno-honor-nans', '-ffast-math', '-ffinite-math-only', etc.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1943,6 +1943,11 @@
   else if (Args.hasArg(options::OPT_fno_finite_loops))
 Opts.FiniteLoops = CodeGenOptions::FiniteLoopsKind::Never;
 
+  Opts.EmitIEEENaNCompliantInsts =
+  Args.hasFlag(options::OPT_mamdgpu_ieee, options::OPT_mno_amdgpu_ieee);
+  if (!Opts.EmitIEEENaNCompliantInsts && !LangOptsRef.NoHonorNaNs)
+Diags.Report(diag::err_drv_amdgpu_ieee_without_no_honor_nans);
+
   return Diags.getNumErrors() == NumErrorsBefore;
 }
 
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9166,6 +9166,9 @@
 
   if (M.getContext().getTargetInfo().allowAMDGPUUnsafeFPAtomics())
 F->addFnAttr("amdgpu-unsafe-fp-atomics", "true");
+
+  if (!getABIInfo().getCodeGenOpts().EmitIEEENaNCompliantInsts)
+F->addFnAttr("amdgpu-ieee", "false");
 }
 
 unsigned AMDGPUTargetCodeGenInfo::getOpenCLKernelCallingConv() const {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3178,6 +3178,14 @@
  Values<"command,reactor">,
  HelpText<"Execution model (WebAssembly only)">;
 
+defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
+  CodeGenOpts<"EmitIEEENaNCompliantInsts">, DefaultTrue,
+  PosFlag,
+  NegFlag>, Group;
+
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, Group,
   HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -129,6 +129,8 @@
   "invalid -Xopenmp-target 

[PATCH] D101635: [analyzer] Fix assertion in SVals.h

2021-04-30 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers created this revision.
vabridgers added reviewers: ASDenysPetrov, NoQ, steakhal, martong, vsavchenko.
Herald added subscribers: dkrupp, donat.nagy, Szelethus, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, whisperity.
vabridgers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix assertion in SVals.h apparently caused by
https://reviews.llvm.org/D89055.

clang:clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:596:
clang::ento::loc::MemRegionVal::MemRegionVal(const clang::ento::MemRegion *):

  Assertion `r' failed.

Backtrace:
...

  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h:597:3
  clang::QualType, clang::QualType)
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:773:18
  clang::QualType, clang::QualType)
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:612:12
  clang::QualType) clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:587:12
  namespace)::RegionBindingsRef const&, clang::ento::Loc, clang::QualType)
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1510:24

...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101635

Files:
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/test/Analysis/casts.c


Index: clang/test/Analysis/casts.c
===
--- clang/test/Analysis/casts.c
+++ clang/test/Analysis/casts.c
@@ -250,3 +250,19 @@
   if (**a == 0) // no-crash
 ;
 }
+
+// See PR50179.
+// Just don't crash.
+typedef struct taskS {
+  void *pJob;
+} taskS;
+
+typedef struct workS {
+  taskS *pTaskList;
+} workS;
+
+void *getTaskJob(unsigned jobId, workS *pWork, unsigned taskId) {
+  const taskS *pTask = pWork->pTaskList + taskId;
+  taskS task = *pTask;
+  return task.pJob;
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -761,8 +761,8 @@
   // Next fixes pointer dereference using type different from its initial
   // one. See PR37503 and PR49007 for details.
   if (const auto *ER = dyn_cast(R)) {
-R = StateMgr.getStoreManager().castRegion(ER, CastTy);
-return loc::MemRegionVal(R);
+if ((R = StateMgr.getStoreManager().castRegion(ER, CastTy)))
+  return loc::MemRegionVal(R);
   }
 
   return V;


Index: clang/test/Analysis/casts.c
===
--- clang/test/Analysis/casts.c
+++ clang/test/Analysis/casts.c
@@ -250,3 +250,19 @@
   if (**a == 0) // no-crash
 ;
 }
+
+// See PR50179.
+// Just don't crash.
+typedef struct taskS {
+  void *pJob;
+} taskS;
+
+typedef struct workS {
+  taskS *pTaskList;
+} workS;
+
+void *getTaskJob(unsigned jobId, workS *pWork, unsigned taskId) {
+  const taskS *pTask = pWork->pTaskList + taskId;
+  taskS task = *pTask;
+  return task.pJob;
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -761,8 +761,8 @@
   // Next fixes pointer dereference using type different from its initial
   // one. See PR37503 and PR49007 for details.
   if (const auto *ER = dyn_cast(R)) {
-R = StateMgr.getStoreManager().castRegion(ER, CastTy);
-return loc::MemRegionVal(R);
+if ((R = StateMgr.getStoreManager().castRegion(ER, CastTy)))
+  return loc::MemRegionVal(R);
   }
 
   return V;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fbfcfdb - [clang] Fix assert() crash when checking undeduced arg alignment

2021-04-30 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2021-04-30T16:24:33+02:00
New Revision: fbfcfdbf6828b8d36f4ec0ff5f4eac11fb1411a5

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

LOG: [clang] Fix assert() crash when checking undeduced arg alignment

There already was a check for undeduced and incomplete types, but it
failed to trigger when outer type (SubstTemplateTypeParm in test) looked
fine, but inner type was not.

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/recovery-expr-type.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 7b6e0541aa4d7..38cda657bac8b 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4540,8 +4540,7 @@ void Sema::CheckArgAlignment(SourceLocation Loc, 
NamedDecl *FDecl,
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e0f46a0ead40a..73d7675eb189f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19662,8 +19662,10 @@ ExprResult Sema::CreateRecoveryExpr(SourceLocation 
Begin, SourceLocation End,
   if (isSFINAEContext())
 return ExprError();
 
-  if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
+  if (T.isNull() || T->isUndeducedType() ||
+  !Context.getLangOpts().RecoveryASTType)
 // We don't know the concrete type, fallback to dependent type.
 T = Context.DependentTy;
+
   return RecoveryExpr::Create(Context, T, Begin, End, SubExprs);
 }

diff  --git a/clang/test/SemaCXX/recovery-expr-type.cpp 
b/clang/test/SemaCXX/recovery-expr-type.cpp
index ed18b7f262cdc..8bdf83e9512fd 100644
--- a/clang/test/SemaCXX/recovery-expr-type.cpp
+++ b/clang/test/SemaCXX/recovery-expr-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast 
-frecovery-ast-type -o - %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast 
-frecovery-ast-type -o - %s -std=gnu++17 -fsyntax-only -verify
 
 namespace test0 {
 struct Indestructible {
@@ -26,7 +26,7 @@ namespace test2 {
 void foo(); // expected-note 3{{requires 0 arguments}}
 void func() {
   // verify that "field has incomplete type" diagnostic is suppressed.
-  typeof(foo(42)) var; // expected-error {{no matching function}}
+  typeof(foo(42)) var; // expected-error {{no matching function}} \
 
   // FIXME: suppress the "cannot initialize a variable" diagnostic.
   int a = foo(1); // expected-error {{no matching function}} \
@@ -116,3 +116,23 @@ int f(); // expected-note {{candidate}}
 template const int k = f(T()); // expected-error {{no matching 
function}}
 static_assert(k == 1, ""); // expected-note {{instantiation of}}
 }
+
+namespace test11 {
+// Verify we do not assert()-fail here.
+template  void foo(T &t);
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
+} // namespace test11



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


[PATCH] D100667: [clang] Fix assert() crash when checking undeduced arg alignment

2021-04-30 Thread Adam Czachorowski 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 rGfbfcfdbf6828: [clang] Fix assert() crash when checking 
undeduced arg alignment (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100667

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast 
-frecovery-ast-type -o - %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast 
-frecovery-ast-type -o - %s -std=gnu++17 -fsyntax-only -verify
 
 namespace test0 {
 struct Indestructible {
@@ -26,7 +26,7 @@
 void foo(); // expected-note 3{{requires 0 arguments}}
 void func() {
   // verify that "field has incomplete type" diagnostic is suppressed.
-  typeof(foo(42)) var; // expected-error {{no matching function}}
+  typeof(foo(42)) var; // expected-error {{no matching function}} \
 
   // FIXME: suppress the "cannot initialize a variable" diagnostic.
   int a = foo(1); // expected-error {{no matching function}} \
@@ -116,3 +116,23 @@
 template const int k = f(T()); // expected-error {{no matching 
function}}
 static_assert(k == 1, ""); // expected-note {{instantiation of}}
 }
+
+namespace test11 {
+// Verify we do not assert()-fail here.
+template  void foo(T &t);
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
+} // namespace test11
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19662,8 +19662,10 @@
   if (isSFINAEContext())
 return ExprError();
 
-  if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
+  if (T.isNull() || T->isUndeducedType() ||
+  !Context.getLangOpts().RecoveryASTType)
 // We don't know the concrete type, fallback to dependent type.
 T = Context.DependentTy;
+
   return RecoveryExpr::Create(Context, T, Begin, End, SubExprs);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4540,8 +4540,7 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast -frecovery-ast-type -o - %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -frecovery-ast -frecovery-ast-type -o - %s -std=gnu++17 -fsyntax-only -verify
 
 namespace test0 {
 struct Indestructible {
@@ -26,7 +26,7 @@
 void foo(); // expected-note 3{{requires 0 arguments}}
 void func() {
   // verify that "field has incomplete type" diagnostic is suppressed.
-  typeof(foo(42)) var; // expected-error {{no matching function}}
+  typeof(foo(42)) var; // expected-error {{no matching function}} \
 
   // FIXME: suppress the "cannot initialize a variable" diagnostic.
   int a = foo(1); // expected-error {{no matching function}} \
@@ -116,3 +116,23 @@
 template const int k = f(T()); // expected-error {{no matching function}}
 static_assert(k == 1, ""); // expected-note {{instantiation of}}
 }
+
+namespace test11 {
+// Verify we do not assert()-fail here.
+template  void foo(T &t);
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
+} // namespace test11
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19662,8 +19662,10 @@
   if (isSFINAEContext())
 return ExprError();
 
-  if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
+  if (T.isNull() || T->isUndeducedTyp

[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments-64: widen integer arguments to int64 in unprototyped function calls

2021-04-30 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: kbsmith1, erichkeane.
mibintc added a project: clang-c.
Herald added subscribers: dexonsmith, dang, Anastasia.
mibintc requested review of this revision.
Herald added a project: clang.

The Intel C++ and Fortran compilers support the option 
-fextend-arguments={32,64}. One of our customers has requested that this 
support be added clang.  This option controls how scalar integral arguments are 
extended in calls to unprototyped and varargs functions. When we investigated 
the support for the ICL option, we discovered that "-fextend-arguments=32" had 
no effect in the generated code, so this patch proposes to support only 64 bit 
extension.  This patch is only meaningful for targets that pass int arguments 
in 64 bits.

For supported targets, signed int values are sign extended to 64 bits in the 
parameter list, and unsigned int values are zero extended to 64 bits.

@kbsmith1 tells me that this option is primarily useful for porting 32-bit 
programs to the 64-bit environment, and although that architecture shift 
happened years ago, the customer is still interested in this support.

It turns out that there is currently similar logic in clang support for the 
OpenCL option "cl_khr_fp64" which causes certain float arguments, in 
unprototyped context, to be expanded to float or double.

Will this change be acceptable?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101640

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/extend-arg-64.c

Index: clang/test/CodeGen/extend-arg-64.c
===
--- /dev/null
+++ clang/test/CodeGen/extend-arg-64.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fextend-arguments-64  \
+// RUN:%s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
+
+// When the option isn't selected, no effect
+// RUN: %clang_cc1 -triple x86_64-apple-darwin  \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on x86, no effect
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments-64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+// The option isn't supported on ppc, no effect
+// RUN: %clang_cc1 -triple ppc64le -fextend-arguments-64 \
+// RUN: %s -emit-llvm -o - | FileCheck %s \
+// RUN:--implicit-check-not "ext {{.*}}to i64"
+
+int vararg(int, ...);
+
+unsigned int u32;
+int s32;
+unsigned short u16;
+short s16;
+unsigned char u8;
+signed char s8;
+
+int test() {
+  // CHECK: define{{.*}} i32 @test{{.*}}
+
+  // CHECKEXT:  [[TAG_u32:%.*]] = load i32, i32* @u32{{.*}}
+  // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
+
+  // CHECKEXT:  [[TAG_s32:%.*]] = load i32, i32* @s32
+  // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
+
+  // CHECKEXT:  [[TAG_u16:%.*]] = load i16, i16* @u16
+  // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
+
+  // CHECKEXT:  [[TAG_s16:%.*]] = load i16, i16* @s16
+  // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
+
+  // CHECKEXT:  [[TAG_u8:%.*]] = load i8, i8* @u8
+  // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
+
+  // CHECKEXT:  [[TAG_s8:%.*]] = load i8, i8* @s8
+  // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
+  // CHECKEXT: call{{.*}} @vararg(i32 %0, i64 [[CONV_u32]], i64 [[CONV_s32]], i64 [[CONV_u16]], i64 [[CONV_s16]], i64 [[CONV_u8]], i64 [[CONV_s8]]
+
+  int sum = 0;
+  sum = vararg(sum, u32, s32, u16, s16, u8, s8);
+  return sum;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -821,6 +821,15 @@
   E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
 }
   }
+  if (BTy && getLangOpts().ExtendArgs64 &&
+  Context.getTargetInfo().supportsExtendArgs64() && Ty->isIntegerType()) {
+E = (Ty->isUnsignedIntegerType())
+? ImpCastExprToType(E, Context.UnsignedLongLongTy, CK_IntegralCast)
+  .get()
+: ImpCastExprToType(E, Context.LongLongTy, CK_IntegralCast).get();
+assert(8 == Context.getTypeSizeInChars(Context.LongLongTy).getQuantity() &&
+   "Unexpected typesize for LongLongTy");
+  }
 
   // C++ performs lvalue-to-rvalue conversion as a default argument
   // promotion, even on class types, but note:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4908,6 +4908,9 @@
 
   RenderFloatingPo

[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments-64: widen integer arguments to int64 in unprototyped function calls

2021-04-30 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@erichkeane Can you suggest reviewers for this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101640

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


[PATCH] D101641: [Sema] Preserve invalid CXXCtorInitializers using RecoveryExpr in initializer

2021-04-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before this patch, CXXCtorInitializers that don't typecheck get discarded in
most cases. In particular:

- typos that can't be corrected don't turn into RecoveryExpr. The full expr 
disappears instead, and without an init expr we discard the node.
- initializers that fail initialization (e.g. constructor overload resolution) 
are discarded too.

This patch addresses both these issues (a bit clunkily and repetitively, for
member/base/delegating initializers)

It does not preserve any AST nodes when the member/base can't be resolved or
other problems of that nature. That breaks invariants of CXXCtorInitializer
itself, and we don't have a "weak" RecoveryCtorInitializer like we do for Expr.

I believe the changes to diagnostics in existing tests are improvements.
(We're able to do some analysis on the non-broken parts of the initializer)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101641

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp

Index: clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
@@ -102,7 +102,9 @@
 struct A { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const A' for 1st argument}} \
 // expected-note{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'A' for 1st argument}} \
 // expected-note{{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
-struct B { };
+struct B { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const B' for 1st argument}} \
+// expected-note{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'B' for 1st argument}} \
+// expected-note{{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
 struct C { };
 struct D { };
 
@@ -123,7 +125,9 @@
 HasMixins::HasMixins(const HasMixins &other): Mixins(other)... { }
 
 template
-HasMixins::HasMixins(int i): Mixins(i)... { } // expected-error{{no matching constructor for initialization of 'A'}}
+HasMixins::HasMixins(int i): Mixins(i)... { }
+// expected-error@-1 {{no matching constructor for initialization of 'A'}}
+// expected-error@-2 {{no matching constructor for initialization of 'B'}}
 
 void test_has_mixins() {
   HasMixins ab;
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -606,11 +606,13 @@
 
 namespace dr655 { // dr655: yes
   struct A { A(int); }; // expected-note 2-3{{not viable}}
+// expected-note@-1 {{'dr655::A' declared here}}
   struct B : A {
-A a;
+A a; // expected-note {{member is declared here}}
 B();
 B(int) : B() {} // expected-error 0-1 {{C++11}}
 B(int*) : A() {} // expected-error {{no matching constructor}}
+ // expected-error@-1 {{must explicitly initialize the member 'a'}}
   };
 }
 
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -296,3 +296,54 @@
   // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 2
   invalid() ? 1 : 2;
 }
+
+void CtorInitializer() {
+  struct S{int m};
+  class MemberInit {
+int x, y;
+S s;
+MemberInit() : x(invalid), y(invalid, invalid), s(1,2) {}
+// CHECK:  CXXConstructorDecl {{.*}} MemberInit 'void ()'
+// CHECK-NEXT: |-CXXCtorInitializer Field {{.*}} 'x' 'int'
+// CHECK-NEXT: | `-ParenListExpr
+// CHECK-NEXT: |   `-RecoveryExpr {{.*}} ''
+// CHECK-NEXT: |-CXXCtorInitializer Field {{.*}} 'y' 'int'
+// CHECK-NEXT: | `-ParenListExpr
+// CHECK-NEXT: |   |-RecoveryExpr {{.*}} ''
+// CHECK-NEXT: |   `-RecoveryExpr {{.*}} ''
+// CHECK-NEXT: |-CXXCtorInitializer Field {{.*}} 's' 'S'
+// CHECK-NEXT: | `-RecoveryExpr {{.*}} 'S' contains-errors
+// CHECK-NEXT: |   |-IntegerLiteral {{.*}} 1
+// CHECK-NEXT: |   `-IntegerLiteral {{.*}} 2
+  };
+  class BaseInit : S {
+BaseInit(float) : S("no match") {}
+// CHECK:  CXXConstructorDecl {{.*}} BaseInit 'void (float)'
+// CHECK-NEXT: |-ParmVarDecl
+// CHECK-NEXT: |-CXXCtorInitializer 'S'
+// CHECK-NEXT: | `-RecoveryExpr {{.*}} 'S'
+// CHECK-NEXT: |   `-StringLiteral
+
+

[PATCH] D101516: Introduce clangd-server-monitor tool

2021-04-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 341922.
kbobyrev marked 3 inline comments as done.
kbobyrev added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101516

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Index: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
===
--- clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
+++ clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -15,9 +15,10 @@
 import sys
 import time
 import threading
+import json
 
 
-def kill_server_after_delay(server_process):
+def kill_process_after_delay(server_process):
   time.sleep(10)
   if server_process.poll() is None:
 server_process.kill()
@@ -48,7 +49,7 @@
   # This will kill index_server_process if it hangs without printing init
   # message.
   shutdown_thread = threading.Thread(
-  target=kill_server_after_delay, args=(index_server_process,))
+  target=kill_process_after_delay, args=(index_server_process,))
   shutdown_thread.daemon = True
   shutdown_thread.start()
 
@@ -67,6 +68,16 @@
 print('Server initialization failed. Shutting down.', file=sys.stderr)
 sys.exit(1)
 
+  print('Running clangd-index-server-monitor...', file=sys.stderr)
+  index_server_monitor_process = subprocess.Popen([
+  'clangd-index-server-monitor', server_address,
+  ], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+  index_server_monitor_process.wait()
+  for line in index_server_monitor_process.stderr:
+args.server_log.write(line)
+args.server_log.flush()
+
   in_file = open(args.input_file_name)
 
   print('Staring clangd...', file=sys.stderr)
@@ -84,6 +95,17 @@
 args.server_log.write(line)
 args.server_log.flush()
 
+  monitor_info = index_server_monitor_process.stdout.read()
+  if not monitor_info:
+print('clangd-index-server-monitor\'s output is empty', file=sys.stderr)
+sys.exit(1)
+  monitor_info = json.loads(monitor_info)
+  for key in ['uptime_seconds', 'index_age_seconds', 'index_commit_hash',
+  'index_link']:
+if not key in monitor_info:
+  print('Key', key, 'not found in clangd-index-server-monitor output',
+file=sys.stderr)
+  sys.exit(1)
 
 if __name__ == '__main__':
   main()
Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -22,7 +22,7 @@
 endif()
 
 if(CLANGD_ENABLE_REMOTE)
-  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server clangd-index-server-monitor)
 endif()
 
 foreach(dep FileCheck count not llvm-config)
Index: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
@@ -0,0 +1,78 @@
+//===--- Monitor.cpp - Request server monitoring information through CLI --===//
+//
+// 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 "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
+
+#include "support/Logger.h"
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace remote {
+namespace {
+
+static constexpr char Overview[] = R"(
+This tool requests monitoring information (uptime, index freshness) from the
+server and prints it to stdout.
+)";
+
+llvm::cl::opt
+ServerAddress("server-address", llvm::cl::Positional,
+  llvm::cl::desc("Address of the invoked server."),
+  llvm::cl::Required);
+
+} // namespace
+} // namespace remote
+} // namespace clangd
+} // namespace clang
+
+int main(int argc, char *argv[]) {
+  using namespace clang::clangd::remote;
+  llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+
+  const auto Channel =
+  grpc::CreateChannel(ServerAddress, grpc::InsecureChannelCredentials());
+  const auto Stub = clang::clangd::remote::v1::Monitor::NewStub(Channel);
+  grpc::ClientContext Context;
+  std::chrono::system_clock::time_point StartTime =
+  std::chrono::system_clo

[PATCH] D101519: [C++4OpenCL] Fix reinterpret_cast of vectors and types with address spaces

2021-04-30 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm added inline comments.



Comment at: clang/test/SemaOpenCLCXX/reinterpret-cast.clcpp:1
+// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only
+

Anastasia wrote:
> Btw I assume your patch also allows reinterpret_cast between vectors? What 
> happens if we cast b/w vector of 3 elements and vector of 4 elements?
Yes, this is essentially the same as line 10, as int is treated as a 1 element 
vector, but I can add some more test cases that shows this more specifically.


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

https://reviews.llvm.org/D101519

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


[PATCH] D101516: Introduce clangd-server-monitor tool

2021-04-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 341925.
kbobyrev added a comment.

Inline gRPC deadline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101516

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/remote-index/pipeline_helper.py

Index: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
===
--- clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
+++ clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
@@ -15,9 +15,10 @@
 import sys
 import time
 import threading
+import json
 
 
-def kill_server_after_delay(server_process):
+def kill_process_after_delay(server_process):
   time.sleep(10)
   if server_process.poll() is None:
 server_process.kill()
@@ -48,7 +49,7 @@
   # This will kill index_server_process if it hangs without printing init
   # message.
   shutdown_thread = threading.Thread(
-  target=kill_server_after_delay, args=(index_server_process,))
+  target=kill_process_after_delay, args=(index_server_process,))
   shutdown_thread.daemon = True
   shutdown_thread.start()
 
@@ -67,6 +68,16 @@
 print('Server initialization failed. Shutting down.', file=sys.stderr)
 sys.exit(1)
 
+  print('Running clangd-index-server-monitor...', file=sys.stderr)
+  index_server_monitor_process = subprocess.Popen([
+  'clangd-index-server-monitor', server_address,
+  ], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+  index_server_monitor_process.wait()
+  for line in index_server_monitor_process.stderr:
+args.server_log.write(line)
+args.server_log.flush()
+
   in_file = open(args.input_file_name)
 
   print('Staring clangd...', file=sys.stderr)
@@ -84,6 +95,17 @@
 args.server_log.write(line)
 args.server_log.flush()
 
+  monitor_info = index_server_monitor_process.stdout.read()
+  if not monitor_info:
+print('clangd-index-server-monitor\'s output is empty', file=sys.stderr)
+sys.exit(1)
+  monitor_info = json.loads(monitor_info)
+  for key in ['uptime_seconds', 'index_age_seconds', 'index_commit_hash',
+  'index_link']:
+if not key in monitor_info:
+  print('Key', key, 'not found in clangd-index-server-monitor output',
+file=sys.stderr)
+  sys.exit(1)
 
 if __name__ == '__main__':
   main()
Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -22,7 +22,7 @@
 endif()
 
 if(CLANGD_ENABLE_REMOTE)
-  list(APPEND CLANGD_TEST_DEPS clangd-index-server)
+  list(APPEND CLANGD_TEST_DEPS clangd-index-server clangd-index-server-monitor)
 endif()
 
 foreach(dep FileCheck count not llvm-config)
Index: clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/monitor/Monitor.cpp
@@ -0,0 +1,76 @@
+//===--- Monitor.cpp - Request server monitoring information through CLI --===//
+//
+// 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 "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
+
+#include "support/Logger.h"
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace remote {
+namespace {
+
+static constexpr char Overview[] = R"(
+This tool requests monitoring information (uptime, index freshness) from the
+server and prints it to stdout.
+)";
+
+llvm::cl::opt
+ServerAddress("server-address", llvm::cl::Positional,
+  llvm::cl::desc("Address of the invoked server."),
+  llvm::cl::Required);
+
+} // namespace
+} // namespace remote
+} // namespace clangd
+} // namespace clang
+
+int main(int argc, char *argv[]) {
+  using namespace clang::clangd::remote;
+  llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+
+  const auto Channel =
+  grpc::CreateChannel(ServerAddress, grpc::InsecureChannelCredentials());
+  const auto Stub = clang::clangd::remote::v1::Monitor::NewStub(Channel);
+  grpc::ClientContext Context;
+  Context.set_deadline(std::chrono::system_clock::now() +
+   std::chrono::seconds(10));
+  Context.AddMetad

[PATCH] D101503: [OpenMPIRBuilder] Add createOffloadMaptypes and createOffloadMapnames functions

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

I assume clang tests apply here. It replaces clang functionality after all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101503

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


[PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

2021-04-30 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

This is now approved and passing CI, and I have also normalized the quoting 
@compnerd asked about (in I hope a satisfactory way). Should I be pinging 
someone to land it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

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


[PATCH] D101503: [OpenMPIRBuilder] Add createOffloadMaptypes and createOffloadMapnames functions

2021-04-30 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D101503#2729385 , @jdoerfert wrote:

> I assume clang tests apply here. It replaces clang functionality after all.

The policy so far was to have LLVM functionality tested in LLVM itself. See 
https://reviews.llvm.org/D91470#2395409 and D91643 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101503

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


[PATCH] D101635: [analyzer] Fix assertion in SVals.h

2021-04-30 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision.
ASDenysPetrov added a comment.
This revision is now accepted and ready to land.

@vabridgers 
Thank you for a good catch! The fix looks fairly reasonable for me!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101635

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


[PATCH] D100092: [clang-tidy] cppcoreguidelines-declare-loop-variable-in-the-initializer: a new check

2021-04-30 Thread Fabian Thurnheer via Phabricator via cfe-commits
DNS320 updated this revision to Diff 341929.
DNS320 added a comment.

Removed a link to the ES.26 C++ Core Guideline in the documentation part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100092

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/DeclareLoopVariableInTheInitializerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-declare-loop-variable-in-the-initializer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-declare-loop-variable-in-the-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-declare-loop-variable-in-the-initializer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-declare-loop-variable-in-the-initializer.cpp
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-declare-loop-variable-in-the-initializer %t
+
+const int Limit{10};
+
+void func1() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'A' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :11:5: note: Variable gets modified here
+  int A{0};
+
+  for (int I{0}; I < Limit; I++) {
+A = 3;
+  }
+}
+
+void func2() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'A' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :21:5: note: Variable gets modified here
+  int A{0};
+
+  for (int I{0}; I < Limit; I++) {
+A += 3;
+  }
+}
+
+void func3() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'I' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :30:8: note: Variable gets modified here
+  int I{0};
+
+  for (I = 1; I < Limit; I++) {
+  }
+}
+
+void func4() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'I' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :39:21: note: Variable gets modified here
+  int I{0};
+
+  for (; I < Limit; I++) {
+  }
+}
+
+void func5() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'I' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :48:34: note: Variable gets modified here
+  int I{0};
+
+  for (int Unused{0}; I < Limit; I++) {
+  }
+}
+
+void func6() {
+  // CHECK-MESSAGES: :[[@LINE+2]]:7: warning: Variable 'I' is only modified in a for statement and not used elsewhere. Consider declaring it inside the for statement. [cppcoreguidelines-declare-loop-variable-in-the-initializer]
+  // CHECK-MESSAGES: :58:8: note: Variable gets modified here
+  int I{0};
+  int Z{0};
+
+  for (I = 3; I < Limit; I++) {
+  }
+  Z = 3;
+}
+
+void func7() {
+  // OK
+  int A{0};
+
+  for (int I{0}; I < Limit; I++) {
+const int B{A};
+  }
+}
+
+void func8() {
+  // OK
+  int I{0};
+
+  for (I = 0; I < Limit; I++) {
+  }
+  const int A{I};
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -143,6 +143,7 @@
`concurrency-thread-canceltype-asynchronous `_,
`cppcoreguidelines-avoid-goto `_,
`cppcoreguidelines-avoid-non-const-global-variables `_,
+   `cppcoreguidelines-declare-loop-variable-in-the-initializer `_,
`cppcoreguidelines-init-variables `_, "Yes"
`cppcoreguidelines-interfaces-global-init `_,
`cppcoreguidelines-macro-usage `_,
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-declare-loop-variable-in-the-initializer.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-declare-loop-variable-in-the-initializer.rst
@@ -0,0 +1,49 @@
+.. title:: clang-tidy - cppcoreguidelines-declare-loop-variable-in-the-initializer
+
+cppcoreguidelines-declare-loop-variable-in-the-initializer
+==
+
+Finds variables that are 

[PATCH] D99484: Use `GNUInstallDirs` to support custom installation dirs.

2021-04-30 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added inline comments.



Comment at: compiler-rt/cmake/base-config-ix.cmake:72
+  set(COMPILER_RT_INSTALL_PATH "" CACHE PATH
+"Prefix where built compiler-rt artifacts should be installed, comes 
before CMAKE_INSTALL_PREFIX.")
   option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit 
tests." OFF)

Ericson2314 wrote:
> compnerd wrote:
> > Ericson2314 wrote:
> > > compnerd wrote:
> > > > Please don't change the descriptions of the options as part of the 
> > > > `GNUInstallDirs` handling.  The change to `COMPILER_RT_INSTALL_PATH` 
> > > > looks incorrect.  Can you explain this change please?
> > > I tried explain this https://reviews.llvm.org/D99484#2655885 and the 
> > > original description about prefixes. The GNU install dir variables are 
> > > allowed to be absolute paths (and not necessary with the installation 
> > > prefix) (and I needed that for the NixOS patch), so always prepending 
> > > `COMPILER_RT_INSTALL_PATH` as is done doesn't work if that is 
> > > `CMAKE_INSTALL_PREFIX` by default.
> > > 
> > > If you do `git grep '_PREFIX ""'` and also `git grep GRPC_INSTALL_PATH` 
> > > you will see that many similar variables also were already empty by 
> > > default. I agree this thing is a bit ugly, but by that argument I am not 
> > > doing a new hack for `GNUInstallDIrs` but rather applying an existing 
> > > ideom consistently in all packages.
> > Sure, but the *descriptions* of the options are needed to changed for 
> > changing the value.
> > 
> > That said, I'm not convinced that this change is okay.  It changes the way 
> > that compiler-rt can be built and used when building a toolchain image.  
> > The handling of the install prefix in compiler-rt is significantly 
> > different from the other parts of LLVM, and so, I think that it may need to 
> > be done as a separate larger effort.
> So just skip everything compile-rt related for now?
compile-rt is skipped in the latest version, and I have an independent 
https://reviews.llvm.org/D101497 laying the groundwork for a future 
`GNUInstallDirs`-adding patch to do the regular thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99484

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


  1   2   >