[clang-tools-extra] 08274d7 - [clang-include-fixer] Pre-reserve vector size. NFC

2021-02-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-02-03T08:30:45+01:00
New Revision: 08274d7d5db7c4dddc271b84239a01cd116e42b8

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

LOG: [clang-include-fixer] Pre-reserve vector size. NFC

Added: 


Modified: 
clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp 
b/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
index 97015f2468e9..cbd79b64eae0 100644
--- a/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
+++ b/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
@@ -149,6 +149,7 @@ SymbolIndexManager::search(llvm::StringRef Identifier,
   rank(MatchedSymbols, FileName);
   // Strip signals, they are no longer needed.
   std::vector Res;
+  Res.reserve(MatchedSymbols.size());
   for (auto  : MatchedSymbols)
 Res.push_back(std::move(SymAndSig.Symbol));
   return Res;



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


[PATCH] D95701: [clangd] Add semanticTokens modifiers for function/class/file/global scope

2021-02-02 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/test/initialize-params.test:91
 # CHECK-NEXT:"abstract"
+# CHECK-NEXT:"functionScope"
+# CHECK-NEXT:"classScope"

nit: missing commas


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95701

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


[PATCH] D76802: [InstrProfiling] Use !associated metadata for counters, data and values

2021-02-02 Thread Petr Hosek 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 rG97ba5cde5266: [InstrProfiling] Use !associated metadata for 
counters, data and values (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76802

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  compiler-rt/test/CMakeLists.txt
  compiler-rt/test/profile/CMakeLists.txt
  compiler-rt/test/profile/instrprof-gc-sections.c
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/icall.ll
  llvm/test/Instrumentation/InstrProfiling/linkage.ll
  llvm/test/Transforms/PGOProfile/associated.ll
  llvm/test/Transforms/PGOProfile/counter_promo.ll
  llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll

Index: llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll
===
--- llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll
+++ llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll
@@ -69,7 +69,7 @@
 ; PROMO-NEXT:  %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 4)
 ; PROMO-NEXT: add 
 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}4)
-; PROMO-NOT: @__profc_foo
+; PROMO-NOT: @__profc_foo{{.*}})
 
 
 bb15: ; preds = %bb14, %bb4
Index: llvm/test/Transforms/PGOProfile/counter_promo.ll
===
--- llvm/test/Transforms/PGOProfile/counter_promo.ll
+++ llvm/test/Transforms/PGOProfile/counter_promo.ll
@@ -60,7 +60,7 @@
 ; ATOMIC_PROMO: atomicrmw add {{.*}} @__profc_foo{{.*}}0), i64 %[[LIVEOUT1]] seq_cst
 ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}1), i64 %[[LIVEOUT2]] seq_cst
 ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}2), i64 %[[LIVEOUT3]] seq_cst
-; PROMO-NOT: @__profc_foo
+; PROMO-NOT: @__profc_foo{{.*}})
 
 
 }
Index: llvm/test/Transforms/PGOProfile/associated.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/associated.ll
@@ -0,0 +1,12 @@
+; RUN: opt < %s -pgo-instr-gen -instrprof -counter-link-order -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-gen,instrprof -counter-link-order -S | FileCheck %s
+
+; CHECK: @__profc_foo = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8, !associated !0
+; CHECK: @__profd_foo = private global {{.*}}, section "__llvm_prf_data", align 8, !associated !1
+
+define void @foo() {
+  ret void
+}
+
+; CHECK: !0 = !{void ()* @foo}
+; CHECK: !1 = !{[1 x i64]* @__profc_foo}
Index: llvm/test/Instrumentation/InstrProfiling/linkage.ll
===
--- llvm/test/Instrumentation/InstrProfiling/linkage.ll
+++ llvm/test/Instrumentation/InstrProfiling/linkage.ll
@@ -8,6 +8,8 @@
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
 ; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
 ; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
+; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -counter-link-order -S | FileCheck %s --check-prefixes=LINUX,POSIX,METADATA
+; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -counter-link-order -S | FileCheck %s --check-prefixes=LINUX,POSIX,METADATA
 
 ; MACHO: @__llvm_profile_runtime = external global i32
 ; LINUX-NOT: @__llvm_profile_runtime = external global i32
@@ -19,7 +21,9 @@
 @__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern"
 
 ; POSIX: @__profc_foo = hidden global
+; METADATA-SAME: !associated !0
 ; POSIX: @__profd_foo = hidden global
+; METADATA-SAME: !associated !1
 ; COFF: @__profc_foo = internal global
 ; COFF-NOT: comdat
 ; COFF: @__profd_foo = internal global
@@ -29,7 +33,9 @@
 }
 
 ; POSIX: @__profc_foo_weak = weak hidden global
+; METADATA: !associated !2
 ; POSIX: @__profd_foo_weak = weak hidden global
+; METADATA: !associated !3
 ; COFF: @__profc_foo_weak = internal global
 ; COFF: @__profd_foo_weak = internal global
 define weak void @foo_weak() {
@@ -38,7 +44,9 @@
 }
 
 ; POSIX: @"__profc_linkage.ll:foo_internal" = internal global
+; METADATA-SAME: !associated !4
 ; POSIX: @"__profd_linkage.ll:foo_internal" = internal global
+; METADATA-SAME: !associated !5
 ; COFF: @"__profc_linkage.ll:foo_internal" = internal global
 ; COFF: @"__profd_linkage.ll:foo_internal" = internal global
 define internal void @foo_internal() {
@@ -47,7 +55,9 @@
 }
 
 ; POSIX: @__profc_foo_inline = linkonce_odr hidden global
+; METADATA-SAME: !associated !6
 ; POSIX: @__profd_foo_inline = linkonce_odr hidden 

[clang] 97ba5cd - [InstrProfiling] Use !associated metadata for counters, data and values

2021-02-02 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-02-02T23:19:51-08:00
New Revision: 97ba5cde52664200819446c1a18de28faf2ed1c6

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

LOG: [InstrProfiling] Use !associated metadata for counters, data and values

C identifier name input sections such as __llvm_prf_* are GC roots so
they cannot be discarded. In LLD, the SHF_LINK_ORDER flag overrides the
C identifier name semantics.

The !associated metadata may be attached to a global object declaration
with a single argument that references another global object, and it
gets lowered to SHF_LINK_ORDER flag. When a function symbol is discarded
by the linker, setting up !associated metadata allows linker to discard
counters, data and values associated with that function symbol.

Note that !associated metadata is only supported by ELF, it does not have
any effect on non-ELF targets.

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

Added: 
compiler-rt/test/profile/instrprof-gc-sections.c
llvm/test/Transforms/PGOProfile/associated.ll

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
compiler-rt/test/CMakeLists.txt
compiler-rt/test/profile/CMakeLists.txt
llvm/include/llvm/Transforms/Instrumentation.h
llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/test/Instrumentation/InstrProfiling/icall.ll
llvm/test/Instrumentation/InstrProfiling/linkage.ll
llvm/test/Transforms/PGOProfile/counter_promo.ll
llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 52bcd971dc8c9..f995c47024197 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -615,6 +615,9 @@ getInstrProfOptions(const CodeGenOptions ,
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
   Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
+  std::pair BinutilsVersion =
+  llvm::TargetMachine::parseBinutilsVersion(CodeGenOpts.BinutilsVersion);
+  Options.CounterLinkOrder = BinutilsVersion >= std::make_pair(2, 36);
   return Options;
 }
 

diff  --git a/compiler-rt/test/CMakeLists.txt b/compiler-rt/test/CMakeLists.txt
index 0836005e10dbb..4d2a6ec2be103 100644
--- a/compiler-rt/test/CMakeLists.txt
+++ b/compiler-rt/test/CMakeLists.txt
@@ -22,7 +22,7 @@ if(NOT ANDROID)
 # Use LLVM utils and Clang from the same build tree.
 list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS
   clang clang-resource-headers FileCheck count not llvm-config llvm-nm 
llvm-objdump
-  llvm-readobj llvm-symbolizer compiler-rt-headers sancov)
+  llvm-readelf llvm-readobj llvm-symbolizer compiler-rt-headers sancov)
 if (WIN32)
   list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS KillTheDoctor)
 endif()

diff  --git a/compiler-rt/test/profile/CMakeLists.txt 
b/compiler-rt/test/profile/CMakeLists.txt
index 4b031306594f8..446e850a3bc11 100644
--- a/compiler-rt/test/profile/CMakeLists.txt
+++ b/compiler-rt/test/profile/CMakeLists.txt
@@ -5,6 +5,9 @@ set(PROFILE_TESTSUITES)
 set(PROFILE_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
 if(NOT COMPILER_RT_STANDALONE_BUILD)
   list(APPEND PROFILE_TEST_DEPS profile llvm-profdata llvm-cov)
+  if(NOT APPLE AND COMPILER_RT_HAS_LLD AND TARGET lld)
+list(APPEND PROFILE_TEST_DEPS lld)
+  endif()
 endif()
 
 set(PROFILE_TEST_ARCH ${PROFILE_SUPPORTED_ARCH})

diff  --git a/compiler-rt/test/profile/instrprof-gc-sections.c 
b/compiler-rt/test/profile/instrprof-gc-sections.c
new file mode 100644
index 0..2876be1cf01a2
--- /dev/null
+++ b/compiler-rt/test/profile/instrprof-gc-sections.c
@@ -0,0 +1,91 @@
+// REQUIRES: linux, lld-available
+
+// RUN: %clang_profgen=%t.profraw -fuse-ld=lld -fcoverage-mapping -mllvm 
-counter-link-order -mllvm -enable-name-compression=false -DCODE=1 
-ffunction-sections -fdata-sections -Wl,--gc-sections -o %t %s
+// RUN: %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-profdata show --all-functions %t.profdata | FileCheck %s 
-check-prefix=PROF
+// RUN: llvm-cov show %t -instr-profile %t.profdata | FileCheck %s 
-check-prefix=COV
+// RUN: llvm-nm %t | FileCheck %s -check-prefix=NM
+// RUN: llvm-readelf -x __llvm_prf_names %t | FileCheck %s 
-check-prefix=PRF_NAMES
+// RUN: llvm-readelf -x __llvm_prf_cnts %t | FileCheck %s 
-check-prefix=PRF_CNTS
+
+// RUN: %clang_lto_profgen=%t.lto.profraw -fuse-ld=lld -fcoverage-mapping 
-mllvm -counter-link-order -mllvm -enable-name-compression=false -DCODE=1 
-ffunction-sections -fdata-sections -Wl,--gc-sections -flto -o %t.lto %s
+// RUN: %run %t.lto
+// RUN: llvm-profdata merge -o %t.lto.profdata %t.lto.profraw
+// RUN: 

[PATCH] D76802: [InstrProfiling] Use !associated metadata for counters, data and values

2021-02-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 321015.
Herald added a subscriber: mgorny.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76802

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  compiler-rt/test/CMakeLists.txt
  compiler-rt/test/profile/CMakeLists.txt
  compiler-rt/test/profile/instrprof-gc-sections.c
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/icall.ll
  llvm/test/Instrumentation/InstrProfiling/linkage.ll
  llvm/test/Transforms/PGOProfile/associated.ll
  llvm/test/Transforms/PGOProfile/counter_promo.ll
  llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll

Index: llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll
===
--- llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll
+++ llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll
@@ -69,7 +69,7 @@
 ; PROMO-NEXT:  %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 4)
 ; PROMO-NEXT: add 
 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}4)
-; PROMO-NOT: @__profc_foo
+; PROMO-NOT: @__profc_foo{{.*}})
 
 
 bb15: ; preds = %bb14, %bb4
Index: llvm/test/Transforms/PGOProfile/counter_promo.ll
===
--- llvm/test/Transforms/PGOProfile/counter_promo.ll
+++ llvm/test/Transforms/PGOProfile/counter_promo.ll
@@ -60,7 +60,7 @@
 ; ATOMIC_PROMO: atomicrmw add {{.*}} @__profc_foo{{.*}}0), i64 %[[LIVEOUT1]] seq_cst
 ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}1), i64 %[[LIVEOUT2]] seq_cst
 ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}2), i64 %[[LIVEOUT3]] seq_cst
-; PROMO-NOT: @__profc_foo
+; PROMO-NOT: @__profc_foo{{.*}})
 
 
 }
Index: llvm/test/Transforms/PGOProfile/associated.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/associated.ll
@@ -0,0 +1,12 @@
+; RUN: opt < %s -pgo-instr-gen -instrprof -counter-link-order -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-gen,instrprof -counter-link-order -S | FileCheck %s
+
+; CHECK: @__profc_foo = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8, !associated !0
+; CHECK: @__profd_foo = private global {{.*}}, section "__llvm_prf_data", align 8, !associated !1
+
+define void @foo() {
+  ret void
+}
+
+; CHECK: !0 = !{void ()* @foo}
+; CHECK: !1 = !{[1 x i64]* @__profc_foo}
Index: llvm/test/Instrumentation/InstrProfiling/linkage.ll
===
--- llvm/test/Instrumentation/InstrProfiling/linkage.ll
+++ llvm/test/Instrumentation/InstrProfiling/linkage.ll
@@ -8,6 +8,8 @@
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
 ; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
 ; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
+; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -counter-link-order -S | FileCheck %s --check-prefixes=LINUX,POSIX,METADATA
+; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -counter-link-order -S | FileCheck %s --check-prefixes=LINUX,POSIX,METADATA
 
 ; MACHO: @__llvm_profile_runtime = external global i32
 ; LINUX-NOT: @__llvm_profile_runtime = external global i32
@@ -19,7 +21,9 @@
 @__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern"
 
 ; POSIX: @__profc_foo = hidden global
+; METADATA-SAME: !associated !0
 ; POSIX: @__profd_foo = hidden global
+; METADATA-SAME: !associated !1
 ; COFF: @__profc_foo = internal global
 ; COFF-NOT: comdat
 ; COFF: @__profd_foo = internal global
@@ -29,7 +33,9 @@
 }
 
 ; POSIX: @__profc_foo_weak = weak hidden global
+; METADATA: !associated !2
 ; POSIX: @__profd_foo_weak = weak hidden global
+; METADATA: !associated !3
 ; COFF: @__profc_foo_weak = internal global
 ; COFF: @__profd_foo_weak = internal global
 define weak void @foo_weak() {
@@ -38,7 +44,9 @@
 }
 
 ; POSIX: @"__profc_linkage.ll:foo_internal" = internal global
+; METADATA-SAME: !associated !4
 ; POSIX: @"__profd_linkage.ll:foo_internal" = internal global
+; METADATA-SAME: !associated !5
 ; COFF: @"__profc_linkage.ll:foo_internal" = internal global
 ; COFF: @"__profd_linkage.ll:foo_internal" = internal global
 define internal void @foo_internal() {
@@ -47,7 +55,9 @@
 }
 
 ; POSIX: @__profc_foo_inline = linkonce_odr hidden global
+; METADATA-SAME: !associated !6
 ; POSIX: @__profd_foo_inline = linkonce_odr hidden global
+; METADATA-SAME: !associated !7
 ; COFF: @__profc_foo_inline = internal global{{.*}} section ".lprfc$M", align 8
 ; COFF: @__profd_foo_inline = internal global{{.*}} 

[PATCH] D95706: [clangd] Expose more dependent-name detail via semanticTokens

2021-02-02 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge added a comment.
This revision is now accepted and ready to land.

Looks great, thanks again for doing this!




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:239
+  auto Result = Priority1 > Priority2 ? Tokens[0] : Tokens[1];
+  Result.Modifiers = Tokens[0].Modifiers | Tokens[1].Modifiers;
+  return Result;

I like that this ends up with a concrete kind + dependent modifier, to give a 
hint that the concrete kind was determined heuristically :)

Maybe we could adjust the comment at the top of the function to call this 
behaviour out.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.h:78
   Abstract,
+  DependentName,
 

Just `Dependent` might be enough


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95706

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


[PATCH] D95928: [OpenMP] Delay more diagnostics of potentially non-emitted code

2021-02-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, grokos, ABataev, Fznamznon, tra, 
yaxunl.
Herald added a reviewer: bollu.
Herald added a subscriber: guansong.
jdoerfert requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Even code in target and declare target regions might not be emitted.
With this patch we delay more diagnostics and use laziness and linkage
to determine if a function is emitted (for the device). Note that we
still eagerly emit diagnostics for target regions, unfortunately, see
the TODO for the reason.

This hopefully fixes PR48933.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95928

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/nvptx_allocate_messages.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
  clang/test/OpenMP/nvptx_unsupported_type_messages.cpp

Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -81,18 +81,12 @@
   T1 t = bar1();
 }
 
-// TODO: We should not emit an error for dead functions we do not emit.
 inline void dead_inline_declare_target() {
-// expected-note@+1 {{'b' defined here}}
   long double *a, b = 0;
-// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
   a = 
 }
-// TODO: We should not emit an error for dead functions we do not emit.
 static void dead_static_declare_target() {
-// expected-note@+1 {{'b' defined here}}
   long double *a, b = 0;
-// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
   a = 
 }
 template
@@ -108,7 +102,6 @@
 // expected-error@+1 {{'ld_arg1a' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 void ld_arg1a(long double ld) {}
 
-// TODO: We should diagnose the return type and argument type here.
 typedef long double ld_ty;
 // expected-note@+2 {{'ld_return1b' defined here}}
 // expected-error@+1 {{'ld_return1b' requires 128 bit size 'ld_ty' (aka 'long double') type support, but device 'nvptx64-unknown-unknown' does not support it}}
@@ -117,48 +110,28 @@
 // expected-error@+1 {{'ld_arg1b' requires 128 bit size 'ld_ty' (aka 'long double') type support, but device 'nvptx64-unknown-unknown' does not support it}}
 void ld_arg1b(ld_ty ld) {}
 
-// TODO: These errors should not be emitted.
-// expected-note@+2 {{'ld_return1c' defined here}}
-// expected-error@+1 {{'ld_return1c' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 static long double ld_return1c() { return 0; }
-// expected-note@+2 {{'ld_arg1c' defined here}}
-// expected-error@+1 {{'ld_arg1c' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 static void ld_arg1c(long double ld) {}
 
-// TODO: These errors should not be emitted.
-// expected-note@+2 {{'ld_return1d' defined here}}
-// expected-error@+1 {{'ld_return1d' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 inline long double ld_return1d() { return 0; }
-// expected-note@+2 {{'ld_arg1d' defined here}}
-// expected-error@+1 {{'ld_arg1d' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 inline void ld_arg1d(long double ld) {}
 
-// expected-error@+2 {{'ld_return1e' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 // expected-note@+1 {{'ld_return1e' defined here}}
 static long double ld_return1e() { return 0; }
-// expected-error@+2 {{'ld_arg1e' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 // expected-note@+1 {{'ld_arg1e' defined here}}
 static void ld_arg1e(long double ld) {}
 
-// expected-error@+2 {{'ld_return1f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 // expected-note@+1 {{'ld_return1f' defined here}}
 inline long double ld_return1f() { return 0; }
-// expected-error@+2 {{'ld_arg1f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 // expected-note@+1 {{'ld_arg1f' defined here}}
 inline void ld_arg1f(long double ld) {}
 
 inline void ld_use1() {
-// expected-note@+1 {{'ld' defined here}}
   long double ld = 0;
-// TODO: We should not diagnose this as the function is dead.
-// expected-error@+1 {{'ld' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
   ld += 1;
 }
 static void ld_use2() {
-// 

[PATCH] D95701: [clangd] Add semanticTokens modifiers for function/class/file/global scope

2021-02-02 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:466
 case TemplateArgument::TemplateExpansion:
+  // FIXME: I don't understand why this is DependentType.
   H.addToken(L.getTemplateNameLoc(), HighlightingKind::DependentType);

nridge wrote:
> The testcase which relies on this is this one:
> 
> ```
>   // Dependent template name
>   R"cpp(
>   template  class> struct $Class[[A]] {};
>   template 
>   using $Typedef[[W]] = $Class[[A]]<
> $TemplateParameter[[T]]::template $DependentType[[Waldo]]
>   >;
> ```
> 
> However, it does appear that we get into here even for non-dependent template 
> template arguments (but then also get a non-dependent highlighting kind via 
> `findExplicitReferences()`, and end up discarding the `DependentType` via 
> `resolveConflict()`).
I see you've already figured this out in D95706 :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95701

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


[PATCH] D95912: [OpenMP] Attribute target diagnostics properly

2021-02-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 321012.
jdoerfert added a comment.

Rebase on top of D95903 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95912

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/nvptx_unsupported_type_messages.cpp

Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -39,10 +39,12 @@
 };
 
 #ifndef _ARCH_PPC
-// expected-note@+1 {{'boo' defined here}}
+// expected-error@+2 {{'boo' requires 128 bit size '__float128' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+// expected-note@+1 2{{'boo' defined here}}
 void boo(__float128 A) { return; }
 #else
-// expected-note@+1 {{'boo' defined here}}
+// expected-error@+2 {{'boo' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+// expected-note@+1 2{{'boo' defined here}}
 void boo(long double A) { return; }
 #endif
 #pragma omp declare target
@@ -51,10 +53,11 @@
 void foo(T a = T()) {
   a = a + f; // expected-note {{called by 'foo'}}
 #ifndef _ARCH_PPC
-// expected-error@+4 {{'boo' requires 128 bit size '__float128' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+// expected-error@+5 {{'boo' requires 128 bit size '__float128' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 #else
-// expected-error@+2 {{'boo' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+// expected-error@+3 {{'boo' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 #endif
+// expected-note@+1 {{called by 'foo'}}
   boo(0);
   return;
 }
@@ -98,28 +101,49 @@
   a = 
 }
 
-// TODO: We should diagnose the return type and argument type here.
+// expected-note@+2 {{'ld_return1a' defined here}}
+// expected-error@+1 {{'ld_return1a' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 long double ld_return1a() { return 0; }
+// expected-note@+2 {{'ld_arg1a' defined here}}
+// expected-error@+1 {{'ld_arg1a' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 void ld_arg1a(long double ld) {}
 
 // TODO: We should diagnose the return type and argument type here.
 typedef long double ld_ty;
+// expected-note@+2 {{'ld_return1b' defined here}}
+// expected-error@+1 {{'ld_return1b' requires 128 bit size 'ld_ty' (aka 'long double') type support, but device 'nvptx64-unknown-unknown' does not support it}}
 ld_ty ld_return1b() { return 0; }
+// expected-note@+2 {{'ld_arg1b' defined here}}
+// expected-error@+1 {{'ld_arg1b' requires 128 bit size 'ld_ty' (aka 'long double') type support, but device 'nvptx64-unknown-unknown' does not support it}}
 void ld_arg1b(ld_ty ld) {}
 
+// TODO: These errors should not be emitted.
+// expected-note@+2 {{'ld_return1c' defined here}}
+// expected-error@+1 {{'ld_return1c' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 static long double ld_return1c() { return 0; }
+// expected-note@+2 {{'ld_arg1c' defined here}}
+// expected-error@+1 {{'ld_arg1c' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 static void ld_arg1c(long double ld) {}
 
+// TODO: These errors should not be emitted.
+// expected-note@+2 {{'ld_return1d' defined here}}
+// expected-error@+1 {{'ld_return1d' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 inline long double ld_return1d() { return 0; }
+// expected-note@+2 {{'ld_arg1d' defined here}}
+// expected-error@+1 {{'ld_arg1d' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 inline void ld_arg1d(long double ld) {}
 
+// expected-error@+2 {{'ld_return1e' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 // expected-note@+1 {{'ld_return1e' defined here}}
 static long double ld_return1e() { return 0; }
+// expected-error@+2 {{'ld_arg1e' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 // expected-note@+1 {{'ld_arg1e' defined here}}
 static void ld_arg1e(long double ld) {}
 
+// expected-error@+2 {{'ld_return1f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 // expected-note@+1 {{'ld_return1f' defined here}}
 

[PATCH] D95903: [OpenMP][NFC] Pre-commit test changes regarding PR48933

2021-02-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 321011.
jdoerfert added a comment.

Add *not* to TODOs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95903

Files:
  clang/test/OpenMP/nvptx_unsupported_type_messages.cpp

Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -77,11 +77,135 @@
 void baz1() {
   T1 t = bar1();
 }
+
+// TODO: We should not emit an error for dead functions we do not emit.
+inline void dead_inline_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+// TODO: We should not emit an error for dead functions we do not emit.
+static void dead_static_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+template
+void dead_template_declare_target() {
+  long double *a, b = 0;
+  a = 
+}
+
+// TODO: We should diagnose the return type and argument type here.
+long double ld_return1a() { return 0; }
+void ld_arg1a(long double ld) {}
+
+// TODO: We should diagnose the return type and argument type here.
+typedef long double ld_ty;
+ld_ty ld_return1b() { return 0; }
+void ld_arg1b(ld_ty ld) {}
+
+static long double ld_return1c() { return 0; }
+static void ld_arg1c(long double ld) {}
+
+inline long double ld_return1d() { return 0; }
+inline void ld_arg1d(long double ld) {}
+
+// expected-note@+1 {{'ld_return1e' defined here}}
+static long double ld_return1e() { return 0; }
+// expected-note@+1 {{'ld_arg1e' defined here}}
+static void ld_arg1e(long double ld) {}
+
+// expected-note@+1 {{'ld_return1f' defined here}}
+inline long double ld_return1f() { return 0; }
+// expected-note@+1 {{'ld_arg1f' defined here}}
+inline void ld_arg1f(long double ld) {}
+
+inline void ld_use1() {
+// expected-note@+1 {{'ld' defined here}}
+  long double ld = 0;
+// TODO: We should not diagnose this as the function is dead.
+// expected-error@+1 {{'ld' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  ld += 1;
+}
+static void ld_use2() {
+// expected-note@+1 {{'ld' defined here}}
+  long double ld = 0;
+// TODO: We should not diagnose this as the function is dead.
+// expected-error@+1 {{'ld' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  ld += 1;
+}
+
+inline void ld_use3() {
+// expected-note@+1 {{'ld' defined here}}
+  long double ld = 0;
+// expected-error@+1 {{'ld' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  ld += 1;
+}
+static void ld_use4() {
+// expected-note@+1 {{'ld' defined here}}
+  long double ld = 0;
+// expected-error@+1 {{'ld' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  ld += 1;
+}
+
+void external() {
+// expected-error@+1 {{'ld_return1e' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  void *p1 = reinterpret_cast(_return1e);
+// expected-error@+1 {{'ld_arg1e' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  void *p2 = reinterpret_cast(_arg1e);
+// expected-error@+1 {{'ld_return1f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  void *p3 = reinterpret_cast(_return1f);
+// expected-error@+1 {{'ld_arg1f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  void *p4 = reinterpret_cast(_arg1f);
+  void *p5 = reinterpret_cast(_use3);
+  void *p6 = reinterpret_cast(_use4);
+}
+
+#ifndef _ARCH_PPC
+// TODO: We should diagnose the return type and argument type here.
+__float128 ld_return2a() { return 0; }
+void ld_arg2a(__float128 ld) {}
+
+// TODO: We should diagnose the return type and argument type here.
+typedef __float128 fp128_ty;
+fp128_ty ld_return2b() { return 0; }
+void ld_arg2b(fp128_ty ld) {}
+#endif
+
 #pragma omp end declare target
 
+// TODO: There should not be an error here, dead_inline is never emitted.
+// expected-note@+1 3{{'f' defined here}}
+inline long double dead_inline(long double f) {
+#pragma omp target map(f)
+// TODO: We should not emit the same error message 3 times, here and elsewhere in this file.
+  // expected-error@+1 3{{'f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  f = 

[PATCH] D95903: [OpenMP][NFC] Pre-commit test changes regarding PR48933

2021-02-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 321010.
jdoerfert added a comment.

Add more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95903

Files:
  clang/test/OpenMP/nvptx_unsupported_type_messages.cpp

Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -77,11 +77,135 @@
 void baz1() {
   T1 t = bar1();
 }
+
+// TODO: We should not emit an error for dead functions we do not emit.
+inline void dead_inline_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+// TODO: We should not emit an error for dead functions we do not emit.
+static void dead_static_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+template
+void dead_template_declare_target() {
+  long double *a, b = 0;
+  a = 
+}
+
+// TODO: We should diagnose the return type and argument type here.
+long double ld_return1a() { return 0; }
+void ld_arg1a(long double ld) {}
+
+// TODO: We should diagnose the return type and argument type here.
+typedef long double ld_ty;
+ld_ty ld_return1b() { return 0; }
+void ld_arg1b(ld_ty ld) {}
+
+static long double ld_return1c() { return 0; }
+static void ld_arg1c(long double ld) {}
+
+inline long double ld_return1d() { return 0; }
+inline void ld_arg1d(long double ld) {}
+
+// expected-note@+1 {{'ld_return1e' defined here}}
+static long double ld_return1e() { return 0; }
+// expected-note@+1 {{'ld_arg1e' defined here}}
+static void ld_arg1e(long double ld) {}
+
+// expected-note@+1 {{'ld_return1f' defined here}}
+inline long double ld_return1f() { return 0; }
+// expected-note@+1 {{'ld_arg1f' defined here}}
+inline void ld_arg1f(long double ld) {}
+
+inline void ld_use1() {
+// expected-note@+1 {{'ld' defined here}}
+  long double ld = 0;
+// TODO: We should diagnose this as the function is dead.
+// expected-error@+1 {{'ld' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  ld += 1;
+}
+static void ld_use2() {
+// expected-note@+1 {{'ld' defined here}}
+  long double ld = 0;
+// TODO: We should diagnose this as the function is dead.
+// expected-error@+1 {{'ld' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  ld += 1;
+}
+
+inline void ld_use3() {
+// expected-note@+1 {{'ld' defined here}}
+  long double ld = 0;
+// expected-error@+1 {{'ld' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  ld += 1;
+}
+static void ld_use4() {
+// expected-note@+1 {{'ld' defined here}}
+  long double ld = 0;
+// expected-error@+1 {{'ld' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  ld += 1;
+}
+
+void external() {
+// expected-error@+1 {{'ld_return1e' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  void *p1 = reinterpret_cast(_return1e);
+// expected-error@+1 {{'ld_arg1e' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  void *p2 = reinterpret_cast(_arg1e);
+// expected-error@+1 {{'ld_return1f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  void *p3 = reinterpret_cast(_return1f);
+// expected-error@+1 {{'ld_arg1f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  void *p4 = reinterpret_cast(_arg1f);
+  void *p5 = reinterpret_cast(_use3);
+  void *p6 = reinterpret_cast(_use4);
+}
+
+#ifndef _ARCH_PPC
+// TODO: We should diagnose the return type and argument type here.
+__float128 ld_return2a() { return 0; }
+void ld_arg2a(__float128 ld) {}
+
+// TODO: We should diagnose the return type and argument type here.
+typedef __float128 fp128_ty;
+fp128_ty ld_return2b() { return 0; }
+void ld_arg2b(fp128_ty ld) {}
+#endif
+
 #pragma omp end declare target
 
+// TODO: There should not be an error here, dead_inline is never emitted.
+// expected-note@+1 3{{'f' defined here}}
+inline long double dead_inline(long double f) {
+#pragma omp target map(f)
+// TODO: We should not emit the same error message 3 times, here and elsewhere in this file.
+  // expected-error@+1 3{{'f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  f = 1;
+  return 

[PATCH] D95701: [clangd] Add semanticTokens modifiers for function/class/file/global scope

2021-02-02 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge added a comment.
This revision is now accepted and ready to land.

Looks good to me!




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:379
+  // ExternalLinkage threshold could be tweaked, e.g. module-visible as global.
+  // Avoid caching linkage if it may change after enclosing code completion.
+  if (hasUnstableLinkage(D) || D->getLinkageInternal() < ExternalLinkage)

code completion? I'm a bit lost :)



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:466
 case TemplateArgument::TemplateExpansion:
+  // FIXME: I don't understand why this is DependentType.
   H.addToken(L.getTemplateNameLoc(), HighlightingKind::DependentType);

The testcase which relies on this is this one:

```
  // Dependent template name
  R"cpp(
  template  class> struct $Class[[A]] {};
  template 
  using $Typedef[[W]] = $Class[[A]]<
$TemplateParameter[[T]]::template $DependentType[[Waldo]]
  >;
```

However, it does appear that we get into here even for non-dependent template 
template arguments (but then also get a non-dependent highlighting kind via 
`findExplicitReferences()`, and end up discarding the `DependentType` via 
`resolveConflict()`).



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:785
+  case HighlightingModifier::FunctionScope:
+return "functionScope";
+  case HighlightingModifier::ClassScope:

Maybe add a `// nonstandard` comment for these as well



Comment at: clang-tools-extra/clangd/SemanticHighlighting.h:82
+  FileScope,
+  GlobalScope,
+

Would it make sense to call this `NamespaceScope` instead?

I understand it's "global" in the sense that it's visible to other translation 
units, but it's not "global" in the sense that it's not necessarily in the 
global namespace.

(On the other hand, I can see how `FileScope` symbols are also "namespace 
scope", so... could go either way.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95701

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


[PATCH] D95925: [clangd] Detect rename conflicits within enclosing scope

2021-02-02 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: hokein.
Herald added subscribers: usaxena95, kadircet, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

This patch allows detecting conflicts with variables defined in the current
CompoundStmt or If/While/For variable init statements.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95925

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1010,13 +1010,41 @@
   )cpp",
"conflict", !HeaderFile, nullptr, "Conflict"},
 
-  {R"cpp(// FIXME: detecting local variables is not supported yet.
+  {R"cpp(
 void func() {
   int Conflict;
-  int [[V^ar]];
+  int V^ar;
+}
+  )cpp",
+   "conflict", !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(
+void func() {
+  if (int Conflict = 42) {
+int V^ar;
+  }
 }
   )cpp",
-   nullptr, !HeaderFile, nullptr, "Conflict"},
+   "conflict", !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(
+void func() {
+  while (int V^ar = 10) {
+bool Conflict = true;
+  }
+}
+  )cpp",
+   "conflict", !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(
+void func() {
+  for (int Something = 9000, Anything = 14, Conflict = 42; Anything > 9;
+   ++Something) {
+int V^ar;
+  }
+}
+  )cpp",
+   "conflict", !HeaderFile, nullptr, "Conflict"},
 
   {R"cpp(// Trying to rename into the same name, SameName == SameName.
 void func() {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -15,8 +15,12 @@
 #include "index/SymbolCollector.h"
 #include "support/Logger.h"
 #include "support/Trace.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/ParentMapContext.h"
+#include "clang/AST/Stmt.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
@@ -318,13 +322,72 @@
   return Results;
 }
 
+// Detect name conflict with othter DeclStmts in the same enclosing scope.
+const NamedDecl *lookupSiblingWithinEnclosingScope(ASTContext ,
+   const NamedDecl ,
+   StringRef NewName) {
+  DynTypedNodeList Parents = Ctx.getParents(RenamedDecl);
+  if (Parents.size() != 1 || !Parents.begin()->get())
+return nullptr;
+  Parents = Ctx.getParents(*Parents.begin()->get());
+  if (Parents.size() != 1)
+return nullptr;
+  // For now, only CompoundStmts are supported;
+  const auto *ParentNode = Parents.begin();
+  const CompoundStmt *EnclosingScope = ParentNode->get();
+  if (const auto *If = ParentNode->get())
+if (const auto *Then = dyn_cast(If->getThen()))
+  EnclosingScope = Then;
+  if (const auto *While = ParentNode->get())
+if (const auto *Body = dyn_cast(While->getBody()))
+  EnclosingScope = Body;
+  if (const auto *For = ParentNode->get())
+if (const auto *Body = dyn_cast(For->getBody()))
+  EnclosingScope = Body;
+  if (!EnclosingScope)
+return nullptr;
+  // This helper checks if any statement within DeclStmt has NewName.
+  auto CheckDeclStmt = [&](const DeclStmt *DS) -> const NamedDecl * {
+for (const auto  : DS->getDeclGroup())
+  if (const auto *VD = dyn_cast(Child))
+if (VD !=  && VD->getName() == NewName)
+  return VD;
+return nullptr;
+  };
+  for (const auto *Node : EnclosingScope->children())
+if (const auto *DS = dyn_cast(Node))
+  if (const auto *Result = CheckDeclStmt(DS))
+return Result;
+  Parents = Ctx.getParents(*EnclosingScope);
+  if (Parents.size() != 1)
+return nullptr;
+  // This helper checks if there is a condition variable has NewName.
+  auto CheckConditionVariable = [&](const auto *Scope) -> const NamedDecl * {
+if (!Scope)
+  return nullptr;
+if (const auto *ConditionDS = Scope->getConditionVariableDeclStmt())
+  if (const auto *Result = CheckDeclStmt(ConditionDS))
+return Result;
+return nullptr;
+  };
+  const auto *Parent = Parents.begin();
+  if (const auto *Result = CheckConditionVariable(Parent->get()))
+return Result;
+  if (const auto *Result = CheckConditionVariable(Parent->get()))
+return Result;
+  if (const auto *For 

[PATCH] D95204: [lld-macho] Switch default to new Darwin port

2021-02-02 Thread Jez Ng via Phabricator via cfe-commits
int3 updated this revision to Diff 321001.
int3 added a subscriber: gkm.
int3 added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95204

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/Inputs/lld/ld64.lld.darwinnew
  clang/test/Driver/Inputs/lld/ld64.lld.darwinold
  clang/test/Driver/darwin-ld-demangle-lld.c
  clang/test/Driver/darwin-ld-platform-version-ios.c
  clang/test/Driver/darwin-ld-platform-version-macos.c
  clang/test/Driver/darwin-ld-platform-version-tvos.c
  clang/test/Driver/darwin-ld-platform-version-watchos.c
  lld/tools/lld/CMakeLists.txt
  lld/tools/lld/lld.cpp
  llvm/utils/gn/build/BUILD.gn
  llvm/utils/gn/secondary/lld/tools/lld/BUILD.gn

Index: llvm/utils/gn/secondary/lld/tools/lld/BUILD.gn
===
--- llvm/utils/gn/secondary/lld/tools/lld/BUILD.gn
+++ llvm/utils/gn/secondary/lld/tools/lld/BUILD.gn
@@ -4,7 +4,7 @@
   "lld-link",
   "ld.lld",
   "ld64.lld",
-  "ld64.lld.darwinnew",
+  "ld64.lld.darwinold",
   "wasm-ld",
 ]
 foreach(target, symlinks) {
Index: llvm/utils/gn/build/BUILD.gn
===
--- llvm/utils/gn/build/BUILD.gn
+++ llvm/utils/gn/build/BUILD.gn
@@ -237,7 +237,7 @@
   # On Windows, the linker is not invoked through the compiler driver.
   if (use_lld && host_os != "win") {
 if (host_os == "mac") {
-  ldflags += [ "-fuse-ld=lld.darwinnew" ]
+  ldflags += [ "-fuse-ld=ld64.lld" ]
 } else {
   ldflags += [ "-fuse-ld=lld" ]
 }
Index: lld/tools/lld/lld.cpp
===
--- lld/tools/lld/lld.cpp
+++ lld/tools/lld/lld.cpp
@@ -56,7 +56,7 @@
   Gnu,   // -flavor gnu
   WinLink,   // -flavor link
   Darwin,// -flavor darwin
-  DarwinNew, // -flavor darwinnew
+  DarwinOld, // -flavor darwinold
   Wasm,  // -flavor wasm
 };
 
@@ -71,7 +71,7 @@
   .CasesLower("wasm", "ld-wasm", Wasm)
   .CaseLower("link", WinLink)
   .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
-  .CasesLower("darwinnew", "ld64.lld.darwinnew", DarwinNew)
+  .CasesLower("darwinold", "ld64.lld.darwinold", DarwinOld)
   .Default(Invalid);
 }
 
@@ -154,9 +154,9 @@
   case WinLink:
 return !coff::link(args, exitEarly, stdoutOS, stderrOS);
   case Darwin:
-return !mach_o::link(args, exitEarly, stdoutOS, stderrOS);
-  case DarwinNew:
 return !macho::link(args, exitEarly, stdoutOS, stderrOS);
+  case DarwinOld:
+return !mach_o::link(args, exitEarly, stdoutOS, stderrOS);
   case Wasm:
 return !lld::wasm::link(args, exitEarly, stdoutOS, stderrOS);
   default:
Index: lld/tools/lld/CMakeLists.txt
===
--- lld/tools/lld/CMakeLists.txt
+++ lld/tools/lld/CMakeLists.txt
@@ -25,7 +25,7 @@
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
   set(LLD_SYMLINKS_TO_CREATE
-  lld-link ld.lld ld64.lld ld64.lld.darwinnew wasm-ld)
+  lld-link ld.lld ld64.lld ld64.lld.darwinold wasm-ld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: clang/test/Driver/darwin-ld-platform-version-watchos.c
===
--- clang/test/Driver/darwin-ld-platform-version-watchos.c
+++ clang/test/Driver/darwin-ld-platform-version-watchos.c
@@ -1,6 +1,6 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld= \
+// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinold \
 // RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
@@ -8,7 +8,7 @@
 // RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinnew \
+// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld \
 // RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
Index: clang/test/Driver/darwin-ld-platform-version-tvos.c
===
--- clang/test/Driver/darwin-ld-platform-version-tvos.c
+++ clang/test/Driver/darwin-ld-platform-version-tvos.c
@@ -1,6 +1,6 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld= \
+// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld=lld.darwinold \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
@@ -8,7 +8,7 @@
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64-apple-tvos12.3 

[clang] fcf03e7 - [OpenMP] Add OpenMP offloading toolchain for AMDGPU

2021-02-02 Thread Pushpinder Singh via cfe-commits

Author: Pushpinder Singh
Date: 2021-02-03T00:42:52-05:00
New Revision: fcf03e728007fa4aa1f64985a3a9bf91fd476d78

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

LOG: [OpenMP] Add OpenMP offloading toolchain for AMDGPU

This patch adds AMDGPUOpenMPToolChain for supporting OpenMP
offloading to AMD GPU's.

Originally authored by Greg Rodgers

Reviewed By: jdoerfert

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

Added: 
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
clang/test/Driver/amdgpu-openmp-toolchain.c

Modified: 
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/HIP.h

Removed: 




diff  --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index aeffcf0bb43a..7542daf3b8f7 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -36,6 +36,7 @@ add_clang_library(clangDriver
   ToolChains/AIX.cpp
   ToolChains/Ananas.cpp
   ToolChains/AMDGPU.cpp
+  ToolChains/AMDGPUOpenMP.cpp
   ToolChains/AVR.cpp
   ToolChains/BareMetal.cpp
   ToolChains/Clang.cpp

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 418e1d3e8ec9..21e602436549 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -10,6 +10,7 @@
 #include "InputInfo.h"
 #include "ToolChains/AIX.h"
 #include "ToolChains/AMDGPU.h"
+#include "ToolChains/AMDGPUOpenMP.h"
 #include "ToolChains/AVR.h"
 #include "ToolChains/Ananas.h"
 #include "ToolChains/BareMetal.h"
@@ -739,18 +740,27 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation 
,
 Diag(clang::diag::err_drv_invalid_omp_target) << Val;
   else {
 const ToolChain *TC;
-// CUDA toolchains have to be selected 
diff erently. They pair host
+// Device toolchains have to be selected 
diff erently. They pair host
 // and device in their implementation.
-if (TT.isNVPTX()) {
+if (TT.isNVPTX() || TT.isAMDGCN()) {
   const ToolChain *HostTC =
   C.getSingleOffloadToolChain();
   assert(HostTC && "Host toolchain should be always defined.");
-  auto  =
+  auto  =
   ToolChains[TT.str() + "/" + HostTC->getTriple().normalize()];
-  if (!CudaTC)
-CudaTC = std::make_unique(
-*this, TT, *HostTC, C.getInputArgs(), Action::OFK_OpenMP);
-  TC = CudaTC.get();
+  if (!DeviceTC) {
+if (TT.isNVPTX())
+  DeviceTC = std::make_unique(
+  *this, TT, *HostTC, C.getInputArgs(), 
Action::OFK_OpenMP);
+else if (TT.isAMDGCN())
+  DeviceTC =
+  std::make_unique(
+  *this, TT, *HostTC, C.getInputArgs());
+else
+  assert(DeviceTC && "Device toolchain not defined.");
+  }
+
+  TC = DeviceTC.get();
 } else
   TC = (C.getInputArgs(), TT);
 C.addOffloadDeviceToolChain(TC, Action::OFK_OpenMP);

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.h 
b/clang/lib/Driver/ToolChains/AMDGPU.h
index 55ef6e01967e..1aa0849ee922 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -64,6 +64,13 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public 
Generic_ELF {
   bool IsIntegratedAssemblerDefault() const override { return true; }
   bool IsMathErrnoDefault() const override { return false; }
 
+  bool useIntegratedAs() const override { return true; }
+  bool isCrossCompiling() const override { return true; }
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return false; }
+  bool SupportsProfiling() const override { return false; }
+
   llvm::opt::DerivedArgList *
   TranslateArgs(const llvm::opt::DerivedArgList , StringRef BoundArch,
 Action::OffloadKind DeviceOffloadKind) const override;

diff  --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 
b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
new file mode 100644
index ..43b07360625f
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -0,0 +1,262 @@
+//===- AMDGPUOpenMP.cpp - AMDGPUOpenMP ToolChain Implementation -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//

[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain for AMDGPU

2021-02-02 Thread Pushpinder Singh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfcf03e728007: [OpenMP] Add OpenMP offloading toolchain for 
AMDGPU (authored by Pushpinder Singh pushpinderdhaliwa...@gmail.com, 
committed by pdhaliwal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
  clang/lib/Driver/ToolChains/HIP.h
  clang/test/Driver/amdgpu-openmp-toolchain.c

Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- /dev/null
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -0,0 +1,36 @@
+// REQUIRES: amdgpu-registered-target
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s 2>&1 \
+// RUN:   | FileCheck %s
+
+// verify the tools invocations
+// CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "c"{{.*}}
+// CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" "ir"{{.*}}
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" "-emit-llvm-bc"{{.*}}
+// CHECK: llvm-link{{.*}}"-o" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc"
+// CHECK: llc{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" "-mtriple=amdgcn-amd-amdhsa" "-mcpu=gfx906" "-filetype=obj" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
+// CHECK: lld{{.*}}"-flavor" "gnu" "--no-undefined" "-shared" "-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}.out" "{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
+// CHECK: clang-offload-wrapper{{.*}}"-target" "x86_64-unknown-linux-gnu" "-o" "{{.*}}a-{{.*}}.bc" {{.*}}amdgpu-openmp-toolchain-{{.*}}.out"
+// CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-o" "{{.*}}a-{{.*}}.o" "-x" "ir" "{{.*}}a-{{.*}}.bc"
+// CHECK: ld{{.*}}"-o" "a.out"{{.*}}"{{.*}}amdgpu-openmp-toolchain-{{.*}}.o" "{{.*}}a-{{.*}}.o" "-lomp" "-lomptarget"
+
+// RUN:   %clang -ccc-print-phases --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PHASES %s
+// phases
+// CHECK-PHASES: 0: input, "{{.*}}amdgpu-openmp-toolchain.c", c, (host-openmp)
+// CHECK-PHASES: 1: preprocessor, {0}, cpp-output, (host-openmp)
+// CHECK-PHASES: 2: compiler, {1}, ir, (host-openmp)
+// CHECK-PHASES: 3: backend, {2}, assembler, (host-openmp)
+// CHECK-PHASES: 4: assembler, {3}, object, (host-openmp)
+// CHECK-PHASES: 5: input, "{{.*}}amdgpu-openmp-toolchain.c", c, (device-openmp)
+// CHECK-PHASES: 6: preprocessor, {5}, cpp-output, (device-openmp)
+// CHECK-PHASES: 7: compiler, {6}, ir, (device-openmp)
+// CHECK-PHASES: 8: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (amdgcn-amd-amdhsa)" {7}, ir
+// CHECK-PHASES: 9: backend, {8}, assembler, (device-openmp)
+// CHECK-PHASES: 10: assembler, {9}, object, (device-openmp)
+// CHECK-PHASES: 11: linker, {10}, image, (device-openmp)
+// CHECK-PHASES: 12: offload, "device-openmp (amdgcn-amd-amdhsa)" {11}, image
+// CHECK-PHASES: 13: clang-offload-wrapper, {12}, ir, (host-openmp)
+// CHECK-PHASES: 14: backend, {13}, assembler, (host-openmp)
+// CHECK-PHASES: 15: assembler, {14}, object, (host-openmp)
+// CHECK-PHASES: 16: linker, {4, 15}, image, (host-openmp)
+
Index: clang/lib/Driver/ToolChains/HIP.h
===
--- clang/lib/Driver/ToolChains/HIP.h
+++ clang/lib/Driver/ToolChains/HIP.h
@@ -71,15 +71,6 @@
   void addClangTargetOptions(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ,
  Action::OffloadKind DeviceOffloadKind) const override;
-
-  bool useIntegratedAs() const override { return true; }
-  bool isCrossCompiling() const override { return true; }
-  bool isPICDefault() const override { return false; }
-  bool isPIEDefault() const override { return false; }
-  bool isPICDefaultForced() const override { return false; }
-  bool SupportsProfiling() const override { return false; }
-  bool IsMathErrnoDefault() const override { return false; }
-
   void addClangWarningOptions(llvm::opt::ArgStringList ) const override;
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList ) const override;
   void
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
@@ -0,0 +1,106 @@
+//===- AMDGPUOpenMP.h - AMDGPUOpenMP ToolChain Implementation -*- C++ -*---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 

[clang-tools-extra] 4454a9c - [NFC] Fix typo in comment

2021-02-02 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-02-03T05:18:07Z
New Revision: 4454a9cd77e7481f6a2d75b4986fe7fbc364204d

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

LOG: [NFC] Fix typo in comment

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 57ee992e64ba..fccff502e183 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -352,7 +352,7 @@ static bool isParamInMainLikeFunction(const ParmVarDecl 
,
 return false;
   if (FDecl->getAccess() != AS_public && FDecl->getAccess() != AS_none)
 return false;
-  // If the function doesn't have a name thats an identifier, can occur of the
+  // If the function doesn't have a name that's an identifier, can occur if the
   // function is an operator overload, bail out early.
   if (!FDecl->getDeclName().isIdentifier())
 return false;



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


[PATCH] D77811: [clangd] Implement semanticTokens modifiers

2021-02-02 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:264
+$Class[[D]] $Field_decl[[E]];
+static double $StaticField_decl_static[[S]];
+static void $StaticMethod_decl_static[[bar]]() {}

sammccall wrote:
> nridge wrote:
> > Presumably, the highlighting kinds `StaticField` and `StaticMethod` are 
> > going to be collapsed into `Field` and `Method` in a future change (after 
> > the removal of TheiaSemanticHighlighting, I guess)?
> Yeah, merging any kinds that are exported with the same name should be NFC at 
> that point.
> 
> Hmm, though currently StaticField --> Variable, not Field (similarly 
> StaticMethod --> Method).
> So we can have static fields be Variable+Static+ClassScope or 
> Field+Static+ClassScope.
> 
> I can see arguments for either...
I don't have a strong opinion on this one.

Maybe Field+Static+ClassScope, that way clients that use a generic theme (and 
thus do not recognize ClassScope) will color it as Field rather than Variable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77811

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


[clang-tools-extra] c97592c - [clang-tidy] Fix crash in readability-identifier-naming check

2021-02-02 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-02-03T05:11:56Z
New Revision: c97592c5df09850404a9ddbfb614c7df271d1dfe

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

LOG: [clang-tidy] Fix crash in readability-identifier-naming check

`isParamInMainLikeFunction` didn't check if the function had an identifer name 
before calling getName() which could lead to an assert.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index b862efe5f104..57ee992e64ba 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -352,6 +352,10 @@ static bool isParamInMainLikeFunction(const ParmVarDecl 
,
 return false;
   if (FDecl->getAccess() != AS_public && FDecl->getAccess() != AS_none)
 return false;
+  // If the function doesn't have a name thats an identifier, can occur of the
+  // function is an operator overload, bail out early.
+  if (!FDecl->getDeclName().isIdentifier())
+return false;
   enum MainType { None, Main, WMain };
   auto IsCharPtrPtr = [](QualType QType) -> MainType {
 if (QType.isNull())



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


[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-02-02 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 320985.
ahatanak added a comment.

Add a description of the new bundle to LangRef.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenObjC/arc-rv-attr.m
  clang/test/CodeGenObjC/arc-unsafeclaim.m
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/ObjCARCUtil.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/LLVMContext.h
  llvm/lib/Analysis/ObjCARCInstKind.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
  llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARC.h
  llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.h
  llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
  llvm/test/CodeGen/AArch64/call-rv-marker.ll
  llvm/test/Transforms/DeadArgElim/deadretval.ll
  llvm/test/Transforms/Inline/inline-retainRV-call.ll
  llvm/test/Transforms/ObjCARC/contract-marker-funclet.ll
  llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
  llvm/test/Transforms/ObjCARC/contract.ll
  llvm/test/Transforms/ObjCARC/intrinsic-use.ll
  llvm/test/Transforms/ObjCARC/rv.ll
  llvm/test/Transforms/TailCallElim/deopt-bundle.ll
  llvm/test/Transforms/TailCallElim/operand-bundles.ll

Index: llvm/test/Transforms/TailCallElim/operand-bundles.ll
===
--- llvm/test/Transforms/TailCallElim/operand-bundles.ll
+++ llvm/test/Transforms/TailCallElim/operand-bundles.ll
@@ -55,3 +55,13 @@
 exit:
   ret void
 }
+
+; CHECK-LABEL: @test_clang_arc_rv(
+; CHECK: tail call i8* @getObj(
+
+declare i8* @getObj()
+
+define i8* @test_clang_arc_rv() {
+  %r = call i8* @getObj() [ "clang.arc.rv"(i64 0) ]
+  ret i8* %r
+}
Index: llvm/test/Transforms/ObjCARC/rv.ll
===
--- llvm/test/Transforms/ObjCARC/rv.ll
+++ llvm/test/Transforms/ObjCARC/rv.ll
@@ -452,6 +452,29 @@
   ret i8* %v3
 }
 
+; Remove operand bundle "clang.arc.rv" and the autoreleaseRV call if the call
+; is a tail call.
+
+; CHECK-LABEL: define i8* @test31(
+; CHECK: %[[CALL:.*]] = tail call i8* @returner()
+; CHECK: ret i8* %[[CALL]]
+
+define i8* @test31() {
+  %call = tail call i8* @returner() [ "clang.arc.rv"(i64 0) ]
+  %1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %1
+}
+
+; CHECK-LABEL: define i8* @test32(
+; CHECK: %[[CALL:.*]] = call i8* @returner() [ "clang.arc.rv"(i64 0) ]
+; CHECK: call i8* @llvm.objc.autoreleaseReturnValue(i8* %[[CALL]])
+
+define i8* @test32() {
+  %call = call i8* @returner() [ "clang.arc.rv"(i64 0) ]
+  %1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %1
+}
+
 !0 = !{}
 
 ; CHECK: attributes [[NUW]] = { nounwind }
Index: llvm/test/Transforms/ObjCARC/intrinsic-use.ll
===
--- llvm/test/Transforms/ObjCARC/intrinsic-use.ll
+++ llvm/test/Transforms/ObjCARC/intrinsic-use.ll
@@ -8,8 +8,10 @@
 declare i8* @llvm.objc.autorelease(i8*)
 
 declare void @llvm.objc.clang.arc.use(...)
+declare void @llvm.objc.clang.arc.noop.use(...)
 
 declare void @test0_helper(i8*, i8**)
+declare void @can_release(i8*)
 
 ; Ensure that we honor clang.arc.use as a use and don't miscompile
 ; the reduced test case from .
@@ -108,6 +110,21 @@
   ret void
 }
 
+; ARC optimizer should be able to safely remove the retain/release pair as the
+; call to @llvm.objc.clang.arc.noop.use is a no-op.
+
+; CHECK-LABEL: define void @test_arc_noop_use(
+; CHECK-NEXT:call void @can_release(i8* %x)
+; CHECK-NEXT:call void (...) @llvm.objc.clang.arc.noop.use(
+; CHECK-NEXT:ret void
+
+define void @test_arc_noop_use(i8** %out, i8* %x) {
+  call i8* @llvm.objc.retain(i8* %x)
+  call void @can_release(i8* %x)
+  call void (...) @llvm.objc.clang.arc.noop.use(i8* %x)
+  call void @llvm.objc.release(i8* %x), !clang.imprecise_release !0
+  ret void
+}
 
 !0 = !{}
 
Index: llvm/test/Transforms/ObjCARC/contract.ll
===
--- llvm/test/Transforms/ObjCARC/contract.ll
+++ llvm/test/Transforms/ObjCARC/contract.ll
@@ -227,7 +227,15 @@
   ret void
 }
 
+; CHECK-LABEL: define void @test14(
+; CHECK-NOT: clang.arc.noop.use
+; CHECK: ret void
+define void @test14(i8* %a, i8* %b) {
+  call void (...) @llvm.objc.clang.arc.noop.use(i8* %a, i8* %b) nounwind
+  ret void
+}
 
 declare 

[PATCH] D95918: [Coverage] Propogate counter to condition of conditional operator

2021-02-02 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added reviewers: vsk, rnk.
zequanwu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang usually propagates counter mapping region for conditions of `if`, `while`,
`for`, etc from parent counter. We should do the same for condition of 
conditional operator.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95918

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/if.cpp
  clang/test/CoverageMapping/macro-expressions.cpp


Index: clang/test/CoverageMapping/macro-expressions.cpp
===
--- clang/test/CoverageMapping/macro-expressions.cpp
+++ clang/test/CoverageMapping/macro-expressions.cpp
@@ -83,20 +83,23 @@
   // CHECK: File 0, [[@LINE+1]]:42 -> [[@LINE+1]]:44 = #7
   for (DECL(int, j) : ARR(int, 1, 2, 3)) {}
 
+  // CHECK-NEXT: File 0, [[@LINE+4]]:10 -> [[@LINE+4]]:11 = #0
   // CHECK-NEXT: Branch,File 0, [[@LINE+3]]:10 -> [[@LINE+3]]:11 = #8, (#0 - 
#8)
   // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:14 -> [[@LINE+2]]:20 = #0
   // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:23 -> [[@LINE+1]]:29 = #0
   (void)(i ? PRIo64 : PRIu64);
 
+  // CHECK-NEXT: File 0, [[@LINE+6]]:10 -> [[@LINE+6]]:11 = #0
   // CHECK: File 0, [[@LINE+5]]:14 -> [[@LINE+5]]:15 = #9
-  // CHECK-NEXT: Expansion,File 0, [[@LINE+4]]:18 -> [[@LINE+4]]:22 = (#0 - #9)
-  // CHECK-NEXT: File 0, [[@LINE+3]]:22 -> [[@LINE+3]]:33 = (#0 - #9)
+  // CHECK-NEXT: File 0, [[@LINE+4]]:18 -> [[@LINE+4]]:33 = (#0 - #9)
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:18 -> [[@LINE+3]]:22 = (#0 - #9)
   // CHECK: File 0, [[@LINE+2]]:28 -> [[@LINE+2]]:29 = #10
   // CHECK-NEXT: File 0, [[@LINE+1]]:32 -> [[@LINE+1]]:33 = ((#0 - #9) - #10)
   (void)(i ? i : EXPR(i) ? i : 0);
+  // CHECK-NEXT: File 0, [[@LINE+5]]:10 -> [[@LINE+5]]:11 = #0
   // CHECK-NEXT: Branch,File 0, [[@LINE+4]]:10 -> [[@LINE+4]]:11 = #11, (#0 - 
#11)
-  // CHECK-NEXT: Expansion,File 0, [[@LINE+3]]:15 -> [[@LINE+3]]:19 = (#0 - 
#11)
-  // CHECK-NEXT: File 0, [[@LINE+2]]:19 -> [[@LINE+2]]:27 = (#0 - #11)
+  // CHECK-NEXT: File 0, [[@LINE+3]]:15 -> [[@LINE+3]]:27 = (#0 - #11)
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:15 -> [[@LINE+2]]:19 = (#0 - 
#11)
   // CHECK-NEXT: File 0, [[@LINE+1]]:26 -> [[@LINE+1]]:27 = ((#0 - #11) - #12)
   (void)(i ?: EXPR(i) ?: 0);
 }
Index: clang/test/CoverageMapping/if.cpp
===
--- clang/test/CoverageMapping/if.cpp
+++ clang/test/CoverageMapping/if.cpp
@@ -3,7 +3,8 @@
 int nop() { return 0; }
 
 // CHECK-LABEL: _Z3foov:
-// CHECK-NEXT: [[@LINE+2]]:12 -> [[@LINE+7]]:2 
= #0
+// CHECK-NEXT: [[@LINE+3]]:12 -> [[@LINE+8]]:2 
= #0
+// CHECK-NEXT: [[@LINE+3]]:15 -> 
[[@LINE+3]]:19 = #0
 // CHECK-NEXT: Branch,File 0, [[@LINE+2]]:15 
-> [[@LINE+2]]:19 = 0, 0
 void foo() {// CHECK-NEXT: Gap,File 0, [[@LINE+1]]:20 -> 
[[@LINE+1]]:22 = #2
   if (int j = true ? nop()  // CHECK-NEXT: [[@LINE]]:22 -> [[@LINE]]:27 = 
#2
@@ -38,11 +39,13 @@
 i = 3;  // CHECK-NEXT: File 0, [[@LINE-1]]:10 -> 
[[@LINE+1]]:4 = (#0 - #4)
   }
 
+// CHECK-NEXT: File 0, [[@LINE+2]]:7 -> 
[[@LINE+2]]:13 = #0
 // CHECK-NEXT: Branch,File 0, [[@LINE+1]]:7 -> 
[[@LINE+1]]:13 = #5, (#0 - #5)
   i = i == 0?   // CHECK-NEXT: Gap,File 0, [[@LINE]]:13 -> 
[[@LINE+1]]:9 = #5
 i + 1 : // CHECK-NEXT: File 0, [[@LINE]]:9 -> 
[[@LINE]]:14 = #5
 i + 2;  // CHECK-NEXT: File 0, [[@LINE]]:9 -> 
[[@LINE]]:14 = (#0 - #5)
 
+// CHECK-NEXT: File 0, [[@LINE+4]]:7 -> 
[[@LINE+4]]:13 = #0
 // CHECK-NEXT: Branch,File 0, [[@LINE+3]]:7 -> 
[[@LINE+3]]:13 = #6, (#0 - #6)
 // CHECK-NEXT: Gap,File 0, [[@LINE+2]]:13 -> 
[[@LINE+2]]:14 = #6
 // CHECK-NEXT: File 0, [[@LINE+1]]:14 -> 
[[@LINE+1]]:20 = #6
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1462,7 +1462,7 @@
 Counter ParentCount = getRegion().getCounter();
 Counter TrueCount = getRegionCounter(E);
 
-Visit(E->getCond());
+propagateCounts(ParentCount, E->getCond());
 
 if (!isa(E)) {
   // The 'then' count applies to the area immediately after the condition.


Index: clang/test/CoverageMapping/macro-expressions.cpp
===
--- clang/test/CoverageMapping/macro-expressions.cpp
+++ clang/test/CoverageMapping/macro-expressions.cpp
@@ -83,20 

[PATCH] D95911: [Docs] Add some documentation for constructor homing, a debug info optimization (-fuse-ctor-homing)

2021-02-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Sounds alright to me.

(non-action idle thoughts: Might be worth revisiting this documentation to make 
it a bit more direct/clearer that many of these optimizations (at least the 
vtable and ctor homing) rely on the assumption that the class is instantiated 
somewhere in the program (and that somewhere is built with debug info enabled) 
(the wording you've got here "This relies on the additional assumption that all 
classes that are not trivially constructible have a non-trivial constructor 
that is used somewhere." but maybe generalized/massaged a bit))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95911

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


[PATCH] D95915: [clang][driver] Only warn once about invalid -stdlib value

2021-02-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: Hahnfeld, phosek, yaxunl, rsmith.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Since ToolChain::GetCXXStdlibType() is a simple getter that might emit the 
"invalid library name in argument" warning, it can conceivably be called 
several times while initializing the build pipeline.

Before this patch, a simlpe 'clang++ -stdlib=foo ./test.cpp' would print the 
warning twice.

Change this and always only print the warning once. Keep the rest of the 
semantics of the function.

E.g,  before:

  $ clang++ -stdlib=foo ./test.cpp
  clang-10: error: invalid library name in argument '-stdlib=foo'
  clang-10: error: invalid library name in argument '-stdlib=foo'

After:

  $ bin/clang++ -stdlib=foo ./test.cpp
  clang-12: error: invalid library name in argument '-stdlib=foo'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95915

Files:
  clang/lib/Driver/ToolChain.cpp


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -929,8 +929,14 @@
   else if (LibName == "platform")
 return GetDefaultCXXStdlibType();
 
-  if (A)
-getDriver().Diag(diag::err_drv_invalid_stdlib_name) << 
A->getAsString(Args);
+  if (A) {
+static bool InvalidStdlibWarned = false;
+if (!InvalidStdlibWarned) {
+  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
+  << A->getAsString(Args);
+  InvalidStdlibWarned = true;
+}
+  }
 
   return GetDefaultCXXStdlibType();
 }


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -929,8 +929,14 @@
   else if (LibName == "platform")
 return GetDefaultCXXStdlibType();
 
-  if (A)
-getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args);
+  if (A) {
+static bool InvalidStdlibWarned = false;
+if (!InvalidStdlibWarned) {
+  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
+  << A->getAsString(Args);
+  InvalidStdlibWarned = true;
+}
+  }
 
   return GetDefaultCXXStdlibType();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95877: [analyzer] Fix static_cast on pointer-to-member handling

2021-02-02 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp:223
+  auto DelIt = find_first(BaseList.begin(), BaseList.end(), PathBase);
+  assert(DelIt != BaseList.end() && "PTM has insufficient base 
specifiers");
+  BaseList.erase(DelIt);

vsavchenko wrote:
> It's better to be more verbose in the assertions.
> Additionally, I'm not sure that it is clear what it is all about because 
> pointer-to-members do not have base specifiers.
Well, the `PointerToMember` contains a `PointerToMemberData`, which has a list 
of `CXXBaseSpecifier`. Should I put something like: "PointerToMemberData has 
insufficient number of base specifiers"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95877

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


[clang] ad50c86 - [clang-format] Fix MSVC "unsafe use of type 'bool' in operation" warning (NFC)

2021-02-02 Thread Yang Fan via cfe-commits

Author: Yang Fan
Date: 2021-02-03T10:50:59+08:00
New Revision: ad50c8633321a2a76b6e49daf57c7eaea4494536

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

LOG: [clang-format] Fix MSVC "unsafe use of type 'bool' in operation" warning 
(NFC)

MSVC warning:
```
\llvm-project\clang\lib\Format\BreakableToken.cpp(1002): warning C4804: '-': 
unsafe use of type 'bool' in operation
```

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index 4ac97ee2e45a..455904895848 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -999,7 +999,7 @@ void BreakableLineCommentSection::adaptStartOfLine(
 const auto SpacesToAdd = std::max(PrefixSpaceChange[LineIndex], 0);
 Whitespaces.replaceWhitespaceInToken(
 tokenAt(LineIndex), OriginalPrefix[LineIndex].size() - SpacesToRemove,
-/*ReplaceChars=*/SpacesToRemove, "", "", -/*InPPDirective=*/false,
+/*ReplaceChars=*/SpacesToRemove, "", "", /*InPPDirective=*/false,
 /*Newlines=*/0, /*Spaces=*/SpacesToAdd);
   }
 }



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


[PATCH] D95911: [Docs] Add some documentation for constructor homing, a debug info optimization (-fuse-ctor-homing)

2021-02-02 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added reviewers: rnk, dblaikie.
akhuang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adding this, since there's currently no documentation about this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95911

Files:
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2504,6 +2504,18 @@
**-fno-standalone-debug** option can be used to get to turn on the
vtable-based optimization described above.
 
+.. option:: -fuse-ctor-homing
+
+   This optimization is similar to the optimizations that are enabled as part
+   of -fno-standalone-debug. Here, Clang only emits type info for a
+   non-trivial, non-aggregate C++ class in the modules that contain a
+   definition of one of its constructors. This relies on the additional
+   assumption that all classes that are not trivially constructible have a
+   non-trivial constructor that is used somewhere.
+
+   This flag is not enabled by default, and needs to be used with -cc1 or
+   -Xclang.
+
 .. option:: -g
 
   Generate complete debug info.


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2504,6 +2504,18 @@
**-fno-standalone-debug** option can be used to get to turn on the
vtable-based optimization described above.
 
+.. option:: -fuse-ctor-homing
+
+   This optimization is similar to the optimizations that are enabled as part
+   of -fno-standalone-debug. Here, Clang only emits type info for a
+   non-trivial, non-aggregate C++ class in the modules that contain a
+   definition of one of its constructors. This relies on the additional
+   assumption that all classes that are not trivially constructible have a
+   non-trivial constructor that is used somewhere.
+
+   This flag is not enabled by default, and needs to be used with -cc1 or
+   -Xclang.
+
 .. option:: -g
 
   Generate complete debug info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95912: [OpenMP] Attribute target diagnostics properly

2021-02-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, grokos, ABataev, Fznamznon.
Herald added subscribers: guansong, yaxunl.
Herald added a reviewer: bollu.
jdoerfert requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Type errors in function declarations were not (always) diagnosed prior
to this patch. Furthermore, certain remarks did not get associated
properly which caused them to be emitted multiple times.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95912

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/nvptx_unsupported_type_messages.cpp

Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -39,10 +39,12 @@
 };
 
 #ifndef _ARCH_PPC
-// expected-note@+1 {{'boo' defined here}}
+// expected-error@+2 {{'boo' requires 128 bit size '__float128' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+// expected-note@+1 2{{'boo' defined here}}
 void boo(__float128 A) { return; }
 #else
-// expected-note@+1 {{'boo' defined here}}
+// expected-error@+2 {{'boo' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+// expected-note@+1 2{{'boo' defined here}}
 void boo(long double A) { return; }
 #endif
 #pragma omp declare target
@@ -51,10 +53,11 @@
 void foo(T a = T()) {
   a = a + f; // expected-note {{called by 'foo'}}
 #ifndef _ARCH_PPC
-// expected-error@+4 {{'boo' requires 128 bit size '__float128' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+// expected-error@+5 {{'boo' requires 128 bit size '__float128' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 #else
-// expected-error@+2 {{'boo' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+// expected-error@+3 {{'boo' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 #endif
+// expected-note@+1 {{called by 'foo'}}
   boo(0);
   return;
 }
@@ -98,49 +101,71 @@
   a = 
 }
 
-// TODO: We should diagnose the return type and argument type here.
+// expected-note@+2 {{'ld_return1a' defined here}}
+// expected-error@+1 {{'ld_return1a' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 long double ld_return1a() { return 0; }
+// expected-note@+2 {{'ld_arg1a' defined here}}
+// expected-error@+1 {{'ld_arg1a' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 void ld_arg1a(long double ld) {}
 
 // TODO: We should diagnose the return type and argument type here.
 typedef long double ld_ty;
+// expected-note@+2 {{'ld_return1b' defined here}}
+// expected-error@+1 {{'ld_return1b' requires 128 bit size 'ld_ty' (aka 'long double') type support, but device 'nvptx64-unknown-unknown' does not support it}}
 ld_ty ld_return1b() { return 0; }
+// expected-note@+2 {{'ld_arg1b' defined here}}
+// expected-error@+1 {{'ld_arg1b' requires 128 bit size 'ld_ty' (aka 'long double') type support, but device 'nvptx64-unknown-unknown' does not support it}}
 void ld_arg1b(ld_ty ld) {}
 
+// TODO: These errors should not be emitted.
+// expected-note@+2 {{'ld_return1c' defined here}}
+// expected-error@+1 {{'ld_return1c' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 static long double ld_return1c() { return 0; }
+// expected-note@+2 {{'ld_arg1c' defined here}}
+// expected-error@+1 {{'ld_arg1c' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 static void ld_arg1c(long double ld) {}
 
+// TODO: These errors should not be emitted.
+// expected-note@+2 {{'ld_return1d' defined here}}
+// expected-error@+1 {{'ld_return1d' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 inline long double ld_return1d() { return 0; }
+// expected-note@+2 {{'ld_arg1d' defined here}}
+// expected-error@+1 {{'ld_arg1d' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 inline void ld_arg1d(long double ld) {}
 
 #ifndef _ARCH_PPC
-// TODO: We should diagnose the return type and argument type here.
+// expected-note@+2 {{'ld_return2a' defined here}}
+// expected-error@+1 {{'ld_return2a' requires 128 bit size '__float128' type support, but device 'nvptx64-unknown-unknown' does not support it}}
 __float128 ld_return2a() { return 0; }
+// expected-note@+2 {{'ld_arg2a' defined here}}
+// expected-error@+1 

[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-02-02 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 320956.
ahatanak marked 3 inline comments as done.
ahatanak added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenObjC/arc-rv-attr.m
  clang/test/CodeGenObjC/arc-unsafeclaim.m
  llvm/include/llvm/Analysis/ObjCARCUtil.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/LLVMContext.h
  llvm/lib/Analysis/ObjCARCInstKind.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
  llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARC.h
  llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.cpp
  llvm/lib/Transforms/ObjCARC/PtrState.h
  llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Bitcode/operand-bundles-bc-analyzer.ll
  llvm/test/CodeGen/AArch64/call-rv-marker.ll
  llvm/test/Transforms/DeadArgElim/deadretval.ll
  llvm/test/Transforms/Inline/inline-retainRV-call.ll
  llvm/test/Transforms/ObjCARC/contract-marker-funclet.ll
  llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
  llvm/test/Transforms/ObjCARC/contract.ll
  llvm/test/Transforms/ObjCARC/intrinsic-use.ll
  llvm/test/Transforms/ObjCARC/rv.ll
  llvm/test/Transforms/TailCallElim/deopt-bundle.ll
  llvm/test/Transforms/TailCallElim/operand-bundles.ll

Index: llvm/test/Transforms/TailCallElim/operand-bundles.ll
===
--- llvm/test/Transforms/TailCallElim/operand-bundles.ll
+++ llvm/test/Transforms/TailCallElim/operand-bundles.ll
@@ -55,3 +55,13 @@
 exit:
   ret void
 }
+
+; CHECK-LABEL: @test_clang_arc_rv(
+; CHECK: tail call i8* @getObj(
+
+declare i8* @getObj()
+
+define i8* @test_clang_arc_rv() {
+  %r = call i8* @getObj() [ "clang.arc.rv"(i64 0) ]
+  ret i8* %r
+}
Index: llvm/test/Transforms/ObjCARC/rv.ll
===
--- llvm/test/Transforms/ObjCARC/rv.ll
+++ llvm/test/Transforms/ObjCARC/rv.ll
@@ -452,6 +452,29 @@
   ret i8* %v3
 }
 
+; Remove operand bundle "clang.arc.rv" and the autoreleaseRV call if the call
+; is a tail call.
+
+; CHECK-LABEL: define i8* @test31(
+; CHECK: %[[CALL:.*]] = tail call i8* @returner()
+; CHECK: ret i8* %[[CALL]]
+
+define i8* @test31() {
+  %call = tail call i8* @returner() [ "clang.arc.rv"(i64 0) ]
+  %1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %1
+}
+
+; CHECK-LABEL: define i8* @test32(
+; CHECK: %[[CALL:.*]] = call i8* @returner() [ "clang.arc.rv"(i64 0) ]
+; CHECK: call i8* @llvm.objc.autoreleaseReturnValue(i8* %[[CALL]])
+
+define i8* @test32() {
+  %call = call i8* @returner() [ "clang.arc.rv"(i64 0) ]
+  %1 = call i8* @llvm.objc.autoreleaseReturnValue(i8* %call)
+  ret i8* %1
+}
+
 !0 = !{}
 
 ; CHECK: attributes [[NUW]] = { nounwind }
Index: llvm/test/Transforms/ObjCARC/intrinsic-use.ll
===
--- llvm/test/Transforms/ObjCARC/intrinsic-use.ll
+++ llvm/test/Transforms/ObjCARC/intrinsic-use.ll
@@ -8,8 +8,10 @@
 declare i8* @llvm.objc.autorelease(i8*)
 
 declare void @llvm.objc.clang.arc.use(...)
+declare void @llvm.objc.clang.arc.noop.use(...)
 
 declare void @test0_helper(i8*, i8**)
+declare void @can_release(i8*)
 
 ; Ensure that we honor clang.arc.use as a use and don't miscompile
 ; the reduced test case from .
@@ -108,6 +110,21 @@
   ret void
 }
 
+; ARC optimizer should be able to safely remove the retain/release pair as the
+; call to @llvm.objc.clang.arc.noop.use is a no-op.
+
+; CHECK-LABEL: define void @test_arc_noop_use(
+; CHECK-NEXT:call void @can_release(i8* %x)
+; CHECK-NEXT:call void (...) @llvm.objc.clang.arc.noop.use(
+; CHECK-NEXT:ret void
+
+define void @test_arc_noop_use(i8** %out, i8* %x) {
+  call i8* @llvm.objc.retain(i8* %x)
+  call void @can_release(i8* %x)
+  call void (...) @llvm.objc.clang.arc.noop.use(i8* %x)
+  call void @llvm.objc.release(i8* %x), !clang.imprecise_release !0
+  ret void
+}
 
 !0 = !{}
 
Index: llvm/test/Transforms/ObjCARC/contract.ll
===
--- llvm/test/Transforms/ObjCARC/contract.ll
+++ llvm/test/Transforms/ObjCARC/contract.ll
@@ -227,7 +227,15 @@
   ret void
 }
 
+; CHECK-LABEL: define void @test14(
+; CHECK-NOT: clang.arc.noop.use
+; CHECK: ret void
+define void @test14(i8* %a, i8* %b) {
+  call void (...) @llvm.objc.clang.arc.noop.use(i8* %a, i8* %b) nounwind
+  ret void
+}
 
 declare void 

[PATCH] D95910: Fix the guaranteed alignment of memory returned by malloc/new on Darwin

2021-02-02 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, arphaman, ab.
ahatanak added a project: clang.
Herald added subscribers: ributzka, jkorous.
ahatanak requested review of this revision.

The guaranteed alignment is 16-bytes on 64-bit Darwin.

rdar://73431623


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95910

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/test/Preprocessor/init-aarch64.c


Index: clang/test/Preprocessor/init-aarch64.c
===
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -532,6 +532,9 @@
 // AARCH64-DARWIN: #define __WINT_WIDTH__ 32
 // AARCH64-DARWIN: #define __aarch64__ 1
 
+// RUN: %clang_cc1 -E -dM -triple=aarch64-apple-ios7.0 -x c++ < /dev/null | 
FileCheck -match-full-lines -check-prefix AARCH64-DARWIN-CXX %s
+// AARCH64-DARWIN-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < 
/dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
 
 // AARCH64-MSVC: #define _INTEGRAL_MAX_BITS 64
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -67,8 +67,9 @@
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
   // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
-  // This alignment guarantee also applies to Windows and Android.
-  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
+  // This alignment guarantee also applies to Windows, Android, and Darwin.
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid() ||
+  T.isOSDarwin())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
   else
 NewAlign = 0; // Infer from basic type alignment.


Index: clang/test/Preprocessor/init-aarch64.c
===
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -532,6 +532,9 @@
 // AARCH64-DARWIN: #define __WINT_WIDTH__ 32
 // AARCH64-DARWIN: #define __aarch64__ 1
 
+// RUN: %clang_cc1 -E -dM -triple=aarch64-apple-ios7.0 -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-DARWIN-CXX %s
+// AARCH64-DARWIN-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
 
 // AARCH64-MSVC: #define _INTEGRAL_MAX_BITS 64
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -67,8 +67,9 @@
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
   // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
-  // This alignment guarantee also applies to Windows and Android.
-  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
+  // This alignment guarantee also applies to Windows, Android, and Darwin.
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid() ||
+  T.isOSDarwin())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
   else
 NewAlign = 0; // Infer from basic type alignment.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95903: [OpenMP][NFC] Pre-commit test changes regarding PR48933

2021-02-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 320945.
jdoerfert added a comment.

More TODOs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95903

Files:
  clang/test/OpenMP/nvptx_unsupported_type_messages.cpp


Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -77,11 +77,84 @@
 void baz1() {
   T1 t = bar1();
 }
+
+// TODO: We should not emit an error for dead functions we do not emit.
+inline void dead_inline_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, 
but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+// TODO: We should not emit an error for dead functions we do not emit.
+static void dead_static_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, 
but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+template
+void dead_template_declare_target() {
+  long double *a, b = 0;
+  a = 
+}
+
+// TODO: We should diagnose the return type and argument type here.
+long double ld_return1a() { return 0; }
+void ld_arg1a(long double ld) {}
+
+// TODO: We should diagnose the return type and argument type here.
+typedef long double ld_ty;
+ld_ty ld_return1b() { return 0; }
+void ld_arg1b(ld_ty ld) {}
+
+static long double ld_return1c() { return 0; }
+static void ld_arg1c(long double ld) {}
+
+inline long double ld_return1d() { return 0; }
+inline void ld_arg1d(long double ld) {}
+
+#ifndef _ARCH_PPC
+// TODO: We should diagnose the return type and argument type here.
+__float128 ld_return2a() { return 0; }
+void ld_arg2a(__float128 ld) {}
+
+// TODO: We should diagnose the return type and argument type here.
+typedef __float128 fp128_ty;
+fp128_ty ld_return2b() { return 0; }
+void ld_arg2b(fp128_ty ld) {}
+#endif
+
 #pragma omp end declare target
 
+// TODO: There should not be an error here, dead_inline is never emitted.
+// expected-note@+1 3{{'f' defined here}}
+inline long double dead_inline(long double f) {
+#pragma omp target map(f)
+// TODO: We should not emit the same error message 3 times, here and elsewhere 
in this file.
+  // expected-error@+1 3{{'f' requires 128 bit size 'long double' type 
support, but device 'nvptx64-unknown-unknown' does not support it}}
+  f = 1;
+  return f;
+}
+
+// TODO: There should not be an error here, dead_static is never emitted.
+// expected-note@+1 3{{'f' defined here}}
+static long double dead_static(long double f) {
+#pragma omp target map(f)
+  // expected-error@+1 3{{'f' requires 128 bit size 'long double' type 
support, but device 'nvptx64-unknown-unknown' does not support it}}
+  f = 1;
+  return f;
+}
+
+template
+long double dead_template(long double f) {
+#pragma omp target map(f)
+  f = 1;
+  return f;
+}
+
 #ifndef _ARCH_PPC
 // expected-note@+1 3{{'f' defined here}}
-__float128 foo1(__float128 f) {
+__float128 foo2(__float128 f) {
 #pragma omp target map(f)
   // expected-error@+1 3{{'f' requires 128 bit size '__float128' type support, 
but device 'nvptx64-unknown-unknown' does not support it}}
   f = 1;
@@ -89,7 +162,7 @@
 }
 #else
 // expected-note@+1 3{{'f' defined here}}
-long double foo1(long double f) {
+long double foo3(long double f) {
 #pragma omp target map(f)
   // expected-error@+1 3{{'f' requires 128 bit size 'long double' type 
support, but device 'nvptx64-unknown-unknown' does not support it}}
   f = 1;


Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -77,11 +77,84 @@
 void baz1() {
   T1 t = bar1();
 }
+
+// TODO: We should not emit an error for dead functions we do not emit.
+inline void dead_inline_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+// TODO: We should not emit an error for dead functions we do not emit.
+static void dead_static_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+template
+void dead_template_declare_target() {
+  long double *a, b = 0;
+  a = 
+}
+
+// TODO: We should diagnose the return type and argument type here.
+long double ld_return1a() { return 0; }
+void ld_arg1a(long double ld) {}
+
+// TODO: We should 

[PATCH] D95903: [OpenMP][NFC] Pre-commit test changes regarding PR48933

2021-02-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 320944.
jdoerfert added a comment.

Add more examples and TODOs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95903

Files:
  clang/test/OpenMP/nvptx_unsupported_type_messages.cpp


Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -77,11 +77,80 @@
 void baz1() {
   T1 t = bar1();
 }
+
+// TODO: We should not emit an error for dead functions we do not emit.
+inline void dead_inline_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, 
but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+// TODO: We should not emit an error for dead functions we do not emit.
+static void dead_static_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, 
but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+template
+void dead_template_declare_target() {
+  long double *a, b = 0;
+  a = 
+}
+
+long double ld_return1a() { return 0; }
+void ld_arg1a(long double ld) {}
+
+typedef long double ld_ty;
+ld_ty ld_return1b() { return 0; }
+void ld_arg1b(ld_ty ld) {}
+
+static long double ld_return1c() { return 0; }
+static void ld_arg1c(long double ld) {}
+
+inline long double ld_return1d() { return 0; }
+inline void ld_arg1d(long double ld) {}
+
+#ifndef _ARCH_PPC
+__float128 ld_return2a() { return 0; }
+void ld_arg2a(__float128 ld) {}
+
+typedef __float128 fp128_ty;
+fp128_ty ld_return2b() { return 0; }
+void ld_arg2b(fp128_ty ld) {}
+#endif
+
 #pragma omp end declare target
 
+// TODO: There should not be an error here, dead_inline is never emitted.
+// expected-note@+1 3{{'f' defined here}}
+inline long double dead_inline(long double f) {
+#pragma omp target map(f)
+// TODO: We should not emit the same error message 3 times, here and elsewhere 
in this file.
+  // expected-error@+1 3{{'f' requires 128 bit size 'long double' type 
support, but device 'nvptx64-unknown-unknown' does not support it}}
+  f = 1;
+  return f;
+}
+
+// TODO: There should not be an error here, dead_static is never emitted.
+// expected-note@+1 3{{'f' defined here}}
+static long double dead_static(long double f) {
+#pragma omp target map(f)
+  // expected-error@+1 3{{'f' requires 128 bit size 'long double' type 
support, but device 'nvptx64-unknown-unknown' does not support it}}
+  f = 1;
+  return f;
+}
+
+template
+long double dead_template(long double f) {
+#pragma omp target map(f)
+  f = 1;
+  return f;
+}
+
 #ifndef _ARCH_PPC
 // expected-note@+1 3{{'f' defined here}}
-__float128 foo1(__float128 f) {
+__float128 foo2(__float128 f) {
 #pragma omp target map(f)
   // expected-error@+1 3{{'f' requires 128 bit size '__float128' type support, 
but device 'nvptx64-unknown-unknown' does not support it}}
   f = 1;
@@ -89,7 +158,7 @@
 }
 #else
 // expected-note@+1 3{{'f' defined here}}
-long double foo1(long double f) {
+long double foo3(long double f) {
 #pragma omp target map(f)
   // expected-error@+1 3{{'f' requires 128 bit size 'long double' type 
support, but device 'nvptx64-unknown-unknown' does not support it}}
   f = 1;


Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -77,11 +77,80 @@
 void baz1() {
   T1 t = bar1();
 }
+
+// TODO: We should not emit an error for dead functions we do not emit.
+inline void dead_inline_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+// TODO: We should not emit an error for dead functions we do not emit.
+static void dead_static_declare_target() {
+// expected-note@+1 {{'b' defined here}}
+  long double *a, b = 0;
+// expected-error@+1 {{'b' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  a = 
+}
+template
+void dead_template_declare_target() {
+  long double *a, b = 0;
+  a = 
+}
+
+long double ld_return1a() { return 0; }
+void ld_arg1a(long double ld) {}
+
+typedef long double ld_ty;
+ld_ty ld_return1b() { return 0; }
+void ld_arg1b(ld_ty ld) {}
+
+static long double ld_return1c() { return 0; }
+static void ld_arg1c(long double ld) {}
+
+inline long double ld_return1d() { return 0; }
+inline void ld_arg1d(long double ld) {}
+
+#ifndef _ARCH_PPC
+__float128 ld_return2a() { return 0; }
+void 

[PATCH] D95204: [lld-macho] Switch default to new Darwin port

2021-02-02 Thread Jez Ng via Phabricator via cfe-commits
int3 updated this revision to Diff 320940.
int3 retitled this revision from "[lld-macho] switch default to new Darwin 
port" to "[lld-macho] Switch default to new Darwin port".
int3 edited the summary of this revision.
int3 edited reviewers, added: thakis; removed: gkm.
int3 added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95204

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/Inputs/lld/ld64.lld.darwinnew
  clang/test/Driver/Inputs/lld/ld64.lld.darwinold
  clang/test/Driver/darwin-ld-demangle-lld.c
  clang/test/Driver/darwin-ld-platform-version-ios.c
  clang/test/Driver/darwin-ld-platform-version-macos.c
  clang/test/Driver/darwin-ld-platform-version-tvos.c
  clang/test/Driver/darwin-ld-platform-version-watchos.c
  lld/tools/lld/CMakeLists.txt
  lld/tools/lld/lld.cpp
  llvm/utils/gn/build/BUILD.gn
  llvm/utils/gn/secondary/lld/tools/lld/BUILD.gn

Index: llvm/utils/gn/secondary/lld/tools/lld/BUILD.gn
===
--- llvm/utils/gn/secondary/lld/tools/lld/BUILD.gn
+++ llvm/utils/gn/secondary/lld/tools/lld/BUILD.gn
@@ -4,7 +4,7 @@
   "lld-link",
   "ld.lld",
   "ld64.lld",
-  "ld64.lld.darwinnew",
+  "ld64.lld.darwinold",
   "wasm-ld",
 ]
 foreach(target, symlinks) {
Index: llvm/utils/gn/build/BUILD.gn
===
--- llvm/utils/gn/build/BUILD.gn
+++ llvm/utils/gn/build/BUILD.gn
@@ -237,7 +237,7 @@
   # On Windows, the linker is not invoked through the compiler driver.
   if (use_lld && host_os != "win") {
 if (host_os == "mac") {
-  ldflags += [ "-fuse-ld=lld.darwinnew" ]
+  ldflags += [ "-fuse-ld=ld64.lld" ]
 } else {
   ldflags += [ "-fuse-ld=lld" ]
 }
Index: lld/tools/lld/lld.cpp
===
--- lld/tools/lld/lld.cpp
+++ lld/tools/lld/lld.cpp
@@ -56,7 +56,7 @@
   Gnu,   // -flavor gnu
   WinLink,   // -flavor link
   Darwin,// -flavor darwin
-  DarwinNew, // -flavor darwinnew
+  DarwinOld, // -flavor darwinold
   Wasm,  // -flavor wasm
 };
 
@@ -71,7 +71,7 @@
   .CasesLower("wasm", "ld-wasm", Wasm)
   .CaseLower("link", WinLink)
   .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
-  .CasesLower("darwinnew", "ld64.lld.darwinnew", DarwinNew)
+  .CasesLower("darwinold", "ld64.lld.darwinold", DarwinOld)
   .Default(Invalid);
 }
 
@@ -154,9 +154,9 @@
   case WinLink:
 return !coff::link(args, exitEarly, stdoutOS, stderrOS);
   case Darwin:
-return !mach_o::link(args, exitEarly, stdoutOS, stderrOS);
-  case DarwinNew:
 return !macho::link(args, exitEarly, stdoutOS, stderrOS);
+  case DarwinOld:
+return !mach_o::link(args, exitEarly, stdoutOS, stderrOS);
   case Wasm:
 return !lld::wasm::link(args, exitEarly, stdoutOS, stderrOS);
   default:
Index: lld/tools/lld/CMakeLists.txt
===
--- lld/tools/lld/CMakeLists.txt
+++ lld/tools/lld/CMakeLists.txt
@@ -25,7 +25,7 @@
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
   set(LLD_SYMLINKS_TO_CREATE
-  lld-link ld.lld ld64.lld ld64.lld.darwinnew wasm-ld)
+  lld-link ld.lld ld64.lld ld64.lld.darwinold wasm-ld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: clang/test/Driver/darwin-ld-platform-version-watchos.c
===
--- clang/test/Driver/darwin-ld-platform-version-watchos.c
+++ clang/test/Driver/darwin-ld-platform-version-watchos.c
@@ -1,6 +1,6 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld= \
+// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinold \
 // RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
@@ -8,7 +8,7 @@
 // RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinnew \
+// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld \
 // RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
Index: clang/test/Driver/darwin-ld-platform-version-tvos.c
===
--- clang/test/Driver/darwin-ld-platform-version-tvos.c
+++ clang/test/Driver/darwin-ld-platform-version-tvos.c
@@ -1,6 +1,6 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld= \
+// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld=lld.darwinold \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
 // RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
@@ -8,7 +8,7 @@
 // RUN:   

[PATCH] D95903: [OpenMP][NFC] Pre-commit test changes regarding PR48933

2021-02-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, grokos, ABataev, Fznamznon.
Herald added subscribers: guansong, yaxunl.
Herald added a reviewer: bollu.
jdoerfert requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This will highlight the effective changes in subsequent commits.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95903

Files:
  clang/test/OpenMP/nvptx_unsupported_type_messages.cpp


Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -77,8 +77,54 @@
 void baz1() {
   T1 t = bar1();
 }
+
+long double ld_return1a() { return 0; }
+void ld_arg1a(long double ld) {}
+
+typedef long double ld_ty;
+ld_ty ld_return1b() { return 0; }
+void ld_arg1b(ld_ty ld) {}
+
+static long double ld_return1c() { return 0; }
+static void ld_arg1c(long double ld) {}
+
+inline long double ld_return1d() { return 0; }
+inline void ld_arg1d(long double ld) {}
+
+#ifndef _ARCH_PPC
+__float128 ld_return2a() { return 0; }
+void ld_arg2a(__float128 ld) {}
+
+typedef __float128 fp128_ty;
+fp128_ty ld_return2b() { return 0; }
+void ld_arg2b(fp128_ty ld) {}
+#endif
+
 #pragma omp end declare target
 
+// expected-note@+1 3{{'f' defined here}}
+inline long double dead_inline(long double f) {
+#pragma omp target map(f)
+  // expected-error@+1 3{{'f' requires 128 bit size 'long double' type 
support, but device 'nvptx64-unknown-unknown' does not support it}}
+  f = 1;
+  return f;
+}
+
+// expected-note@+1 3{{'f' defined here}}
+static long double dead_static(long double f) {
+#pragma omp target map(f)
+  // expected-error@+1 3{{'f' requires 128 bit size 'long double' type 
support, but device 'nvptx64-unknown-unknown' does not support it}}
+  f = 1;
+  return f;
+}
+
+template
+long double dead_template(long double f) {
+#pragma omp target map(f)
+  f = 1;
+  return f;
+}
+
 #ifndef _ARCH_PPC
 // expected-note@+1 3{{'f' defined here}}
 __float128 foo1(__float128 f) {


Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -77,8 +77,54 @@
 void baz1() {
   T1 t = bar1();
 }
+
+long double ld_return1a() { return 0; }
+void ld_arg1a(long double ld) {}
+
+typedef long double ld_ty;
+ld_ty ld_return1b() { return 0; }
+void ld_arg1b(ld_ty ld) {}
+
+static long double ld_return1c() { return 0; }
+static void ld_arg1c(long double ld) {}
+
+inline long double ld_return1d() { return 0; }
+inline void ld_arg1d(long double ld) {}
+
+#ifndef _ARCH_PPC
+__float128 ld_return2a() { return 0; }
+void ld_arg2a(__float128 ld) {}
+
+typedef __float128 fp128_ty;
+fp128_ty ld_return2b() { return 0; }
+void ld_arg2b(fp128_ty ld) {}
+#endif
+
 #pragma omp end declare target
 
+// expected-note@+1 3{{'f' defined here}}
+inline long double dead_inline(long double f) {
+#pragma omp target map(f)
+  // expected-error@+1 3{{'f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  f = 1;
+  return f;
+}
+
+// expected-note@+1 3{{'f' defined here}}
+static long double dead_static(long double f) {
+#pragma omp target map(f)
+  // expected-error@+1 3{{'f' requires 128 bit size 'long double' type support, but device 'nvptx64-unknown-unknown' does not support it}}
+  f = 1;
+  return f;
+}
+
+template
+long double dead_template(long double f) {
+#pragma omp target map(f)
+  f = 1;
+  return f;
+}
+
 #ifndef _ARCH_PPC
 // expected-note@+1 3{{'f' defined here}}
 __float128 foo1(__float128 f) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95901: [CUDA][HIP] Fix device variable linkage

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

For -fgpu-rdc, shadow variables should not be internalized, otherwise
they cannot be accessed by other TUs. This is necessary because
the shadow variable of external device variables are always
emitted as undefined symbols, which need to resolve to a global
symbols.

Managed variables need to be emitted as undefined symbols
in device compilations.


https://reviews.llvm.org/D95901

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/device-stub.cu
  clang/test/CodeGenCUDA/device-var-linkage.cu
  clang/test/CodeGenCUDA/managed-var.cu

Index: clang/test/CodeGenCUDA/managed-var.cu
===
--- clang/test/CodeGenCUDA/managed-var.cu
+++ clang/test/CodeGenCUDA/managed-var.cu
@@ -10,17 +10,19 @@
 
 // RUN: %clang_cc1 -triple x86_64-gnu-linux -std=c++11 \
 // RUN:   -emit-llvm -o - -x hip %s | FileCheck \
-// RUN:   -check-prefixes=HOST %s
+// RUN:   -check-prefixes=HOST,NORDC %s
 
 // RUN: %clang_cc1 -triple x86_64-gnu-linux -std=c++11 \
 // RUN:   -emit-llvm -fgpu-rdc -o - -x hip %s | FileCheck \
-// RUN:   -check-prefixes=HOST %s
+// RUN:   -check-prefixes=HOST,RDC %s
 
 #include "Inputs/cuda.h"
 
-// DEV-DAG: @x = {{.*}}addrspace(1) externally_initialized global i32 undef
-// HOST-DAG: @x = internal global i32 1
-// HOST-DAG: @x.managed = internal global i32* null
+// DEV-DAG: @x = external addrspace(1) externally_initialized global i32
+// NORDC-DAG: @x = internal global i32 1
+// RDC-DAG: @x = dso_local global i32 1
+// NORDC-DAG: @x.managed = internal global i32* null
+// RDC-DAG: @x.managed = dso_local global i32* null
 // HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"x\00"
 
 struct vec {
@@ -31,11 +33,28 @@
 __managed__ vec v[100];
 __managed__ vec v2[100] = {{1, 1, 1}};
 
+// DEV-DAG: @ex = external addrspace(1) global i32
+// HOST-DAG: @ex = external global i32
+extern __managed__ int ex;
+
+// DEV-DAG: @_ZL2sx = external addrspace(1) externally_initialized global i32
+// HOST-DAG: @_ZL2sx = internal global i32 1
+// HOST-DAG: @_ZL2sx.managed = internal global i32* null
+static __managed__ int sx = 1;
+
+// HOST-NOT: @ex.managed
+
+// Force ex and sx mitted in device compilation.
 __global__ void foo(int *z) {
-  *z = x;
+  *z = x + ex + sx;
   v[1].x = 2;
 }
 
+// Force ex and sx emitted in host compilatioin.
+int foo2() {
+  return ex + sx;
+}
+
 // HOST-LABEL: define {{.*}}@_Z4loadv()
 // HOST:  %ld.managed = load i32*, i32** @x.managed, align 4
 // HOST:  %0 = load i32, i32* %ld.managed, align 4
@@ -97,4 +116,6 @@
 }
 
 // HOST-DAG: __hipRegisterManagedVar({{.*}}@x.managed {{.*}}@x {{.*}}@[[DEVNAMEX]]{{.*}}, i64 4, i32 4)
+// HOST-DAG: __hipRegisterManagedVar({{.*}}@_ZL2sx.managed {{.*}}@_ZL2sx
+// HOST-NOT: __hipRegisterManagedVar({{.*}}@ex.managed {{.*}}@ex
 // HOST-DAG: declare void @__hipRegisterManagedVar(i8**, i8*, i8*, i8*, i64, i32)
Index: clang/test/CodeGenCUDA/device-var-linkage.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/device-var-linkage.cu
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -triple nvptx -fcuda-is-device \
+// RUN:   -emit-llvm -o - -x hip %s \
+// RUN:   | FileCheck -check-prefixes=DEV,NORDC %s
+// RUN: %clang_cc1 -triple nvptx -fcuda-is-device \
+// RUN:   -fgpu-rdc -emit-llvm -o - -x hip %s \
+// RUN:   | FileCheck -check-prefixes=DEV,RDC %s
+// RUN: %clang_cc1 -triple nvptx \
+// RUN:   -emit-llvm -o - -x hip %s \
+// RUN:   | FileCheck -check-prefixes=HOST,NORDC-H %s
+// RUN: %clang_cc1 -triple nvptx \
+// RUN:   -fgpu-rdc -emit-llvm -o - -x hip %s \
+// RUN:   | FileCheck -check-prefixes=HOST,RDC-H %s
+
+#include "Inputs/cuda.h"
+
+// DEV-DAG: @v1 = dso_local addrspace(1) externally_initialized global i32 0
+// NORDC-H-DAG: @v1 = internal global i32 undef
+// RDC-H-DAG: @v1 = dso_local global i32 undef
+__device__ int v1;
+// DEV-DAG: @v2 = dso_local addrspace(4) externally_initialized global i32 0
+// NORDC-H-DAG: @v2 = internal global i32 undef
+// RDC-H-DAG: @v2 = dso_local global i32 undef
+__constant__ int v2;
+// DEV-DAG: @v3 = external addrspace(1) externally_initialized global i32
+// NORDC-H-DAG: @v3 = internal global i32 0
+// RDC-H-DAG: @v3 = dso_local global i32 0
+__managed__ int v3;
+
+// DEV-DAG: @ev1 = external addrspace(1) global i32
+// HOST-DAG: @ev1 = external global i32
+extern __device__ int ev1;
+// DEV-DAG: @ev2 = external addrspace(4) global i32
+// HOST-DAG: @ev2 = external global i32
+extern __constant__ int ev2;
+// DEV-DAG: @ev3 = external addrspace(1) global i32
+// HOST-DAG: @ev3 = external global i32
+extern __managed__ int ev3;
+
+// NORDC-DAG: @_ZL3sv1 = dso_local addrspace(1) externally_initialized global i32 0
+// RDC-DAG: @_ZL3sv1 = internal addrspace(1) global i32 0
+// HOST-DAG: @_ZL3sv1 = internal global i32 undef
+static __device__ 

[PATCH] D95872: [clang][Arm] Fix handling of -Wa,-march=

2021-02-02 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/test/Driver/arm-target-as-march-mcpu.s:42
+/// We use the target CPU for both.
+// RUN: %clang -target arm-linux-gnueabi -### -c -mcpu=cortex-a8 
-Wa,-march=armv8a %s 2>&1 | \
+// RUN: FileCheck -check-prefix=TRIPLE-ARMV8 --check-prefix=CPU-A8 %s

nickdesaulniers wrote:
> Below you have a comment `(cortex-a32 is armv8a)`.  That is very helpful for 
> me.  I assume `cortex-a8` is armv7a?
And if so, would you mind adding a similar comment here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95872

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


[PATCH] D69322: [hip][cuda] Enable extended lambda support on Windows.

2021-02-02 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

PING for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69322

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


[PATCH] D95695: [clang-tblgen] AnnotateAttr::printPretty has spurious comma when no variadic argument is specified

2021-02-02 Thread Félix Cloutier via Phabricator via cfe-commits
fcloutier added inline comments.



Comment at: clang/test/AST/ast-print-attr.c:31
+// CHECK: int fun_annotate() __attribute__((annotate("annotation")))
+int fun_annotate() __attribute__((annotate("annotation")));

aaron.ballman wrote:
> Can you add a second test that shows we properly print the comma? e.g., `int 
> fun_annotate2() __attribute__((annotate("annotation one", "annotation 
> two")));`
I switched this to use `ownership_holds` and `ownership_returns` because 
`annotate` has a `VariadicExprArgument` and it doesn't know how to print 
expressions (it just prints a pointer value). `ownership_holds` and 
`ownership_returns` are the same attribute, and they have the same 
bug-triggering configuration (a fixed argument followed by a possibly-empty 
list):

```c++
int *fun_returns() __attribute__((ownership_returns(fun_returns)));
void fun_holds(int *a) __attribute__((ownership_holds(fun_holds, 1)));
```

In the `ownership_returns` case, without my change, Clang prints 
`__attribute__((ownership_returns(foo, )));`.



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:2252
+  // Helper to print the starting character of an attribute argument. If there
+  // hasn't been an argument yet, it prints an opening parenthese; otherwise it
+  // prints a comma.

aaron.ballman wrote:
> One downside to printing the opening paren is that this can't be used in a 
> generic way for generating any comma-separate list. That said, I think this 
> functionality is clean -- perhaps renaming the function from `Comma` to 
> `PrintAttributeArgListElement` or something would be an improvement?
I went with `DelimitAttributeArgument`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95695

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


[PATCH] D95695: [clang-tblgen] AnnotateAttr::printPretty has spurious comma when no variadic argument is specified

2021-02-02 Thread Félix Cloutier via Phabricator via cfe-commits
fcloutier updated this revision to Diff 320904.
fcloutier added a comment.

Address Aaron's feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95695

Files:
  clang/test/AST/ast-print-attr.c
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -773,10 +773,8 @@
 
 void writeValue(raw_ostream ) const override {
   OS << "\";\n";
-  OS << "  bool isFirst = true;\n"
- << "  for (const auto  : " << RangeName << "()) {\n"
- << "if (isFirst) isFirst = false;\n"
- << "else OS << \", \";\n";
+  OS << "  for (const auto  : " << RangeName << "()) {\n"
+ << "DelimitAttributeArgument(OS, IsFirstArgument);\n";
   writeValueImpl(OS);
   OS << "  }\n";
   OS << "  OS << \"";
@@ -1428,10 +1426,12 @@
 return;
   }
 
-  OS << "  switch (getAttributeSpellingListIndex()) {\n"
-"  default:\n"
-"llvm_unreachable(\"Unknown attribute spelling!\");\n"
-"break;\n";
+  OS << "  bool IsFirstArgument = true; (void)IsFirstArgument;\n"
+ << "  unsigned TrailingOmittedArgs = 0; (void)TrailingOmittedArgs;\n"
+ << "  switch (getAttributeSpellingListIndex()) {\n"
+ << "  default:\n"
+ << "llvm_unreachable(\"Unknown attribute spelling!\");\n"
+ << "break;\n";
 
   for (unsigned I = 0; I < Spellings.size(); ++ I) {
 llvm::SmallString<16> Prefix;
@@ -1476,12 +1476,10 @@
 
 Spelling += Name;
 
-OS <<
-  "  case " << I << " : {\n"
-  "OS << \"" << Prefix << Spelling;
+OS << "  case " << I << " : {\n"
+   << "OS << \"" << Prefix << Spelling << "\";\n";
 
 if (Variety == "Pragma") {
-  OS << "\";\n";
   OS << "printPrettyPragma(OS, Policy);\n";
   OS << "OS << \"\\n\";";
   OS << "break;\n";
@@ -1490,19 +1488,18 @@
 }
 
 if (Spelling == "availability") {
-  OS << "(";
+  OS << "OS << \"(";
   writeAvailabilityValue(OS);
-  OS << ")";
+  OS << ")\";\n";
 } else if (Spelling == "deprecated" || Spelling == "gnu::deprecated") {
-  OS << "(";
+  OS << "OS << \"(";
   writeDeprecatedAttrValue(OS, Variety);
-  OS << ")";
+  OS << ")\";\n";
 } else {
   // To avoid printing parentheses around an empty argument list or
   // printing spurious commas at the end of an argument list, we need to
   // determine where the last provided non-fake argument is.
   unsigned NonFakeArgs = 0;
-  unsigned TrailingOptArgs = 0;
   bool FoundNonOptArg = false;
   for (const auto  : llvm::reverse(Args)) {
 if (arg->isFake())
@@ -1516,61 +1513,33 @@
   FoundNonOptArg = true;
   continue;
 }
-if (!TrailingOptArgs++)
-  OS << "\";\n"
- << "unsigned TrailingOmittedArgs = 0;\n";
 OS << "if (" << arg->getIsOmitted() << ")\n"
<< "  ++TrailingOmittedArgs;\n";
   }
-  if (TrailingOptArgs)
-OS << "OS << \"";
-  if (TrailingOptArgs < NonFakeArgs)
-OS << "(";
-  else if (TrailingOptArgs)
-OS << "\";\n"
-   << "if (TrailingOmittedArgs < " << NonFakeArgs << ")\n"
-   << "   OS << \"(\";\n"
-   << "OS << \"";
   unsigned ArgIndex = 0;
   for (const auto  : Args) {
 if (arg->isFake())
   continue;
-if (ArgIndex) {
-  if (ArgIndex >= NonFakeArgs - TrailingOptArgs)
-OS << "\";\n"
-   << "if (" << ArgIndex << " < " << NonFakeArgs
-   << " - TrailingOmittedArgs)\n"
-   << "  OS << \", \";\n"
-   << "OS << \"";
-  else
-OS << ", ";
-}
 std::string IsOmitted = arg->getIsOmitted();
 if (arg->isOptional() && IsOmitted != "false")
-  OS << "\";\n"
- << "if (!(" << IsOmitted << ")) {\n"
- << "  OS << \"";
+  OS << "if (!(" << IsOmitted << ")) {\n";
+// Variadic arguments print their own leading comma.
+if (!arg->isVariadic())
+  OS << "DelimitAttributeArgument(OS, IsFirstArgument);\n";
+OS << "OS << \"";
 arg->writeValue(OS);
+OS << "\";\n";
 if (arg->isOptional() && IsOmitted != "false")
-  OS << "\";\n"
- << "}\n"
- << "OS << \"";
+  OS << "}\n";
 ++ArgIndex;
   }
-  if (TrailingOptArgs < NonFakeArgs)
-OS << ")";
-  else if (TrailingOptArgs)
-OS << "\";\n"
-   << "if (TrailingOmittedArgs < " << NonFakeArgs << ")\n"
-   << "   OS << \")\";\n"
-   << "OS << 

[PATCH] D95877: [analyzer] Fix static_cast on pointer-to-member handling

2021-02-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Thanks for taking your time and getting to the root cause of it!




Comment at: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp:209
+// thing about Clang AST.
+std::list BaseList;
+for (const auto  : PathList)

`std::list` is like the slowest container, and it should be avoided in almost 
every case.
Considering the semantics of it, you can definitely use `llvm::SmallVector`.



Comment at: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp:222
+for (const auto  : llvm::reverse(PathRange)) {
+  auto DelIt = find_first(BaseList.begin(), BaseList.end(), PathBase);
+  assert(DelIt != BaseList.end() && "PTM has insufficient base 
specifiers");

`llvm::find_if` with a lambda capturing `PathBase`?



Comment at: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp:223
+  auto DelIt = find_first(BaseList.begin(), BaseList.end(), PathBase);
+  assert(DelIt != BaseList.end() && "PTM has insufficient base 
specifiers");
+  BaseList.erase(DelIt);

It's better to be more verbose in the assertions.
Additionally, I'm not sure that it is clear what it is all about because 
pointer-to-members do not have base specifiers.



Comment at: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp:224
+  assert(DelIt != BaseList.end() && "PTM has insufficient base 
specifiers");
+  BaseList.erase(DelIt);
+}

In order to avoid removals from the middle, you can use a more functional 
approach to collections and iterators and use `llvm::make_filter_range` and 
iterate over it in the loop below,



Comment at: clang/test/Analysis/pointer-to-member.cpp:304
+  grandpa.field = 10;
+  int Grandfather::*gpf1 = static_cast(sf);
+  int Grandfather::*gpf2 = static_cast(static_cast(sf));

What about other type of casts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95877

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


[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.

LGTM. I think there would be more concern if the load/store actions were 
previously symmetric, but this patch is actually needed for the symmetry. 
Nevertheless, please wait a bit before committing this (since this is a change 
for other platforms as well).


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

https://reviews.llvm.org/D95822

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


[PATCH] D95746: clang: Exclude efi_main from -Wmissing-prototypes

2021-02-02 Thread Daan De Meyer via Phabricator via cfe-commits
DaanDeMeyer updated this revision to Diff 320899.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95746

Files:
  clang/lib/Sema/SemaDecl.cpp


Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13867,7 +13867,7 @@
   // Don't warn about 'main'.
   if (isa(FD->getDeclContext()->getRedeclContext()))
 if (IdentifierInfo *II = FD->getIdentifier())
-  if (II->isStr("main"))
+  if (II->isStr("main") || II->isStr("efi_main"))
 return false;
 
   // Don't warn about inline functions.


Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13867,7 +13867,7 @@
   // Don't warn about 'main'.
   if (isa(FD->getDeclContext()->getRedeclContext()))
 if (IdentifierInfo *II = FD->getIdentifier())
-  if (II->isStr("main"))
+  if (II->isStr("main") || II->isStr("efi_main"))
 return false;
 
   // Don't warn about inline functions.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2021-02-02 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:448
+  /// Number of collapsed loops as specified by 'collapse' clause.
+  unsigned CollapsedNum = 0;
+

ABataev wrote:
> Meinersbur wrote:
> > Inaccurate for the tile directive.
> We can rename it to something like `NumAssociatedLoops`
Sounds good.



Comment at: clang/include/clang/AST/StmtOpenMP.h:651-677
+  static bool
+  doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
+unsigned NumLoops,
+llvm::function_ref Callback);
+  static bool
+  doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops,
+unsigned NumLoops,

ABataev wrote:
> Meinersbur wrote:
> > Please add doxygen comments.
> > 
> > IMHO, using callbacks makes the callers significantly more complicated. Why 
> > not fill a SmallVectorImpl with the result?
> It just hides all internal representation in the class and the user/caller 
> should not worry about proper implementation of the loops processing. 
> Consider it as a way to encapsulate representation details.
That could also be done by returning and iterator/filling an array with the 
requested data. The latter is one of the primary uses of `SmallVectorImpl`.

coroutines should make returning an iterator much simpler, eventually when we 
are allowed to use C++20.



Comment at: clang/include/clang/AST/StmtOpenMP.h:659
+llvm::function_ref Callback) {
+auto & = [Callback](unsigned Cnt, Stmt *CurStmt) {
+  return Callback(Cnt, CurStmt);

ABataev wrote:
> Meinersbur wrote:
> > I do not see why making this a forwarding reference.
> There is a type mismatch in callback types, `Stmt *` and `const Stmt *`
I understand why the additional lambda is needed, but wondered about why the 
declaration is not
```
auto NewCallback = [Callback](unsigned Cnt, Stmt *CurStmt) { 
```




Comment at: clang/include/clang/AST/StmtOpenMP.h:680-709
+return T->getStmtClass() == OMPSimdDirectiveClass ||
+   T->getStmtClass() == OMPForDirectiveClass ||
+   T->getStmtClass() == OMPTileDirectiveClass ||
+   T->getStmtClass() == OMPForSimdDirectiveClass ||
+   T->getStmtClass() == OMPParallelForDirectiveClass ||
+   T->getStmtClass() == OMPParallelForSimdDirectiveClass ||
+   T->getStmtClass() == OMPTaskLoopDirectiveClass ||

ABataev wrote:
> Meinersbur wrote:
> > Use `isOpenMPLoopDirective()` instead?
> I'll check if it can be used instead, though I just want to be consistent 
> with what we have for other statements/expressions/directives.
It would reduce the maintenance cost of not forgetting to update this list as 
well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76342

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


[PATCH] D95733: [AMDGPU] Set s-memtime-inst feature from clang

2021-02-02 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8e661d3d9c52: [AMDGPU] Set s-memtime-inst feature from clang 
(authored by rampitec).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95733

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl


Index: clang/test/CodeGenOpenCL/amdgpu-features.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -32,30 +32,30 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1032 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1032 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1033 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1033 %s
 
-// GFX600-NOT: "target-features"
-// GFX601-NOT: "target-features"
-// GFX602-NOT: "target-features"
-// GFX700: "target-features"="+ci-insts,+flat-address-space"
-// GFX701: "target-features"="+ci-insts,+flat-address-space"
-// GFX702: "target-features"="+ci-insts,+flat-address-space"
-// GFX703: "target-features"="+ci-insts,+flat-address-space"
-// GFX704: "target-features"="+ci-insts,+flat-address-space"
-// GFX705: "target-features"="+ci-insts,+flat-address-space"
-// GFX801: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime"
-// GFX802: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime"
-// GFX803: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime"
-// GFX805: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime"
-// GFX810: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime"
-// GFX900: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX902: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX904: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX906: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX908: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+mai-insts,+s-memrealtime"
-// GFX909: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX90C: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX1010: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX1011: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX1012: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX600: "target-features"="+s-memtime-inst"
+// GFX601: "target-features"="+s-memtime-inst"
+// GFX602: "target-features"="+s-memtime-inst"
+// GFX700: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst"
+// GFX701: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst"
+// GFX702: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst"
+// GFX703: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst"
+// GFX704: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst"
+// GFX705: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst"
+// GFX801: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime,+s-memtime-inst"
+// GFX802: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime,+s-memtime-inst"
+// GFX803: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime,+s-memtime-inst"
+// GFX805: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime,+s-memtime-inst"
+// GFX810: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime,+s-memtime-inst"
+// GFX900: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst"
+// GFX902: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst"
+// GFX904: 

[PATCH] D95561: [Clang] Introduce Swift async calling convention.

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



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:8106-8115
+  case ParsedAttr::AT_SwiftAsyncCall:
   case ParsedAttr::AT_VectorCall:
   case ParsedAttr::AT_MSABI:
   case ParsedAttr::AT_SysVABI:
   case ParsedAttr::AT_Pcs:
   case ParsedAttr::AT_IntelOclBicc:
   case ParsedAttr::AT_PreserveMost:

varungandhi-apple wrote:
> There seems to be some weirdness here in `handleCallConvAttr` where the 
> codepath to attach the attribute to the decl isn't taken. Instead in my 
> examples, it exits out at this line:
> 
> ```
>   if (hasDeclarator(D)) return;
> ```
> 
> with an `isa` check.
It doesn't need to be attached to the decl; it should be reflected in the type, 
the same as the other calling conventions.  You would need it on the decl for 
something like an ObjC method.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95561

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


[PATCH] D95876: [clang-cl] Remove the /fallback option

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

Probably get a short release notes entry too.




Comment at: clang/lib/Driver/ToolChains/MSVC.cpp:669
 const InputInfoList , const ArgList ,
 const char *LinkingOutput) const {
   ArgStringList CmdArgs;

Doesn't this whole function exist only for /fallback? In what other cases do we 
need to invoke cl.exe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95876

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


[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


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

https://reviews.llvm.org/D95822

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


[PATCH] D93844: [clang-format] Add possibility to be based on parent directory

2021-02-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 320886.
HazardyKnusperkeks marked an inline comment as done.
HazardyKnusperkeks added a comment.

Silence unused variable warnings in release and using `llvm::reverse` with 
range based for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93844

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17923,6 +17923,111 @@
   auto StyleTd = getStyle("file", "x.td", "llvm", "", );
   ASSERT_TRUE((bool)StyleTd);
   ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
+
+  // Test 9.1: overwriting a file style, when parent no file exists with no
+  // fallback style
+  ASSERT_TRUE(FS.addFile(
+  "/e/sub/.clang-format", 0,
+  llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: InheritParentConfig\n"
+   "ColumnLimit: 20")));
+  ASSERT_TRUE(FS.addFile("/e/sub/code.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style9 = getStyle("file", "/e/sub/code.cpp", "none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getNoStyle();
+Style.ColumnLimit = 20;
+return Style;
+  }());
+
+  // Test 9.2: with LLVM fallback style
+  Style9 = getStyle("file", "/e/sub/code.cpp", "LLVM", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getLLVMStyle();
+Style.ColumnLimit = 20;
+return Style;
+  }());
+
+  // Test 9.3: with a parent file
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google\n"
+  "UseTab: Always")));
+  Style9 = getStyle("file", "/e/sub/code.cpp", "none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getGoogleStyle();
+Style.ColumnLimit = 20;
+Style.UseTab = FormatStyle::UT_Always;
+return Style;
+  }());
+
+  // Test 9.4: propagate more than one level
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/code.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer(
+ "BasedOnStyle: InheritParentConfig\n"
+ "WhitespaceSensitiveMacros: ['FOO', 'BAR']")));
+  std::vector NonDefaultWhiteSpaceMacros{"FOO", "BAR"};
+
+  const auto SubSubStyle = [] {
+auto Style = getGoogleStyle();
+Style.ColumnLimit = 20;
+Style.UseTab = FormatStyle::UT_Always;
+Style.WhitespaceSensitiveMacros = NonDefaultWhiteSpaceMacros;
+return Style;
+  }();
+
+  ASSERT_NE(Style9->WhitespaceSensitiveMacros, NonDefaultWhiteSpaceMacros);
+  Style9 = getStyle("file", "/e/sub/sub/code.cpp", "none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.5: use InheritParentConfig as style name
+  Style9 =
+  getStyle("inheritparentconfig", "/e/sub/sub/code.cpp", "none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.6: use command line style with inheritance
+  Style9 = getStyle("{BasedOnStyle: InheritParentConfig}", "/e/sub/code.cpp",
+"none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.7: use command line style with inheritance and own config
+  Style9 = getStyle("{BasedOnStyle: InheritParentConfig, "
+"WhitespaceSensitiveMacros: ['FOO', 'BAR']}",
+"/e/sub/code.cpp", "none", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, SubSubStyle);
+
+  // Test 9.8: use inheritance from a file without BasedOnStyle
+  ASSERT_TRUE(FS.addFile("/e/withoutbase/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("ColumnLimit: 123")));
+  ASSERT_TRUE(
+  FS.addFile("/e/withoutbase/sub/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer(
+ "BasedOnStyle: InheritParentConfig\nIndentWidth: 7")));
+  // Make sure we do not use the fallback style
+  Style9 = getStyle("file", "/e/withoutbase/code.cpp", "google", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getLLVMStyle();
+Style.ColumnLimit = 123;
+return Style;
+  }());
+
+  Style9 = getStyle("file", "/e/withoutbase/sub/code.cpp", "google", "", );
+  ASSERT_TRUE(static_cast(Style9));
+  ASSERT_EQ(*Style9, [] {
+auto Style = getLLVMStyle();
+Style.ColumnLimit = 123;
+

[PATCH] D93844: [clang-format] Add possibility to be based on parent directory

2021-02-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks marked 2 inline comments as done.
HazardyKnusperkeks added a comment.

In D93844#2536354 , @njames93 wrote:

> As a follow up it may be wise to pass a diag handler to parseConfiguration as 
> when we parse it a second time, we probably want to disregard any warnings 
> (like unknown key) detected as they will have been printed on the first pass.

Will try to look into it.




Comment at: clang/lib/Format/Format.cpp:3011-3017
+  std::for_each(
+  ChildFormatTextToApply.rbegin(), ChildFormatTextToApply.rend(),
+  [, AllowUnknownOptions](const auto ) {
+auto Ec = parseConfiguration(*Ptr, , 
AllowUnknownOptions);
+// It was already correctly parsed.
+assert(!Ec);
+  });

njames93 wrote:
> Nit: just use a for loop over a lambda.
Did not know about `llvm::reverse`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93844

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


[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/test/CodeGenCXX/global-init.cpp:84
   // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test41xE
-  // CHECK-NEXT: store i64 1, i64* @_ZGVN5test41xE
+  // CHECK-NEXT: store i8 1, i8* bitcast (i64* @_ZGVN5test41xE to i8*)
   __attribute__((weak)) int x = foo();

hubert.reinterpretcast wrote:
> Xiangling_L wrote:
> > abhina.sreeskantharajan wrote:
> > > nit: the lines above omit the end of the line. It's probably better to be 
> > > consistent
> > > 
> > > 
> > It didn't omit the end of the line. It is because before my patch, there 
> > was no casting.
> Hi @Xiangling_L, I think Abhina meant the lines above in this file. The 
> `load` has a `bitcast` too (and stops after the guard variable name).
I see. Sorry for the misunderstanding. @abhina.sreeskantharajan 


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

https://reviews.llvm.org/D95822

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


[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 320881.
Xiangling_L marked an inline comment as done.
Xiangling_L added a comment.

Addressed the comments related to test formatting;


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

https://reviews.llvm.org/D95822

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  clang/test/CodeGenCXX/cxx11-thread-local.cpp
  clang/test/CodeGenCXX/global-init.cpp
  clang/test/CodeGenCXX/static-data-member.cpp

Index: clang/test/CodeGenCXX/static-data-member.cpp
===
--- clang/test/CodeGenCXX/static-data-member.cpp
+++ clang/test/CodeGenCXX/static-data-member.cpp
@@ -72,7 +72,7 @@
   // CHECK-NEXT: br i1 [[UNINITIALIZED]]
   // CHECK:  [[TMP:%.*]] = call i32 @_ZN5test33fooEv()
   // CHECK-NEXT: store i32 [[TMP]], i32* @_ZN5test31AIiE1xE, align 4
-  // CHECK-NEXT: store i64 1, i64* @_ZGVN5test31AIiE1xE
+  // CHECK-NEXT: store i8 1, i8* bitcast (i64* @_ZGVN5test31AIiE1xE to i8*)
   // CHECK-NEXT: br label
   // CHECK:  ret void
 }
Index: clang/test/CodeGenCXX/global-init.cpp
===
--- clang/test/CodeGenCXX/global-init.cpp
+++ clang/test/CodeGenCXX/global-init.cpp
@@ -78,10 +78,10 @@
   extern int foo();
 
   // This needs an initialization function and guard variables.
-  // CHECK: load i8, i8* bitcast (i64* @_ZGVN5test41xE
+  // CHECK: load i8, i8* bitcast (i64* @_ZGVN5test41xE to i8*)
   // CHECK: [[CALL:%.*]] = call i32 @_ZN5test43fooEv
   // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test41xE
-  // CHECK-NEXT: store i64 1, i64* @_ZGVN5test41xE
+  // CHECK-NEXT: store i8 1, i8* bitcast (i64* @_ZGVN5test41xE to i8*)
   __attribute__((weak)) int x = foo();
 }
 
Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -184,7 +184,7 @@
 // need init:
 // CHECK: call i32 @_Z1gv()
 // CHECK: store i32 %{{.*}}, i32* @_ZN1VIfE1mE, align 4
-// CHECK: store i64 1, i64* @_ZGVN1VIfE1mE
+// CHECK: store i8 1, i8* bitcast (i64* @_ZGVN1VIfE1mE to i8*)
 // CHECK: br label
 
 // LINUX: define internal void @[[XF_M_INIT]]()
@@ -197,7 +197,7 @@
 // need init:
 // LINUX: call {{.*}}__cxa_thread_atexit
 // DARWIN: call {{.*}}_tlv_atexit
-// CHECK: store i64 1, i64* @_ZGVN1XIfE1mE
+// CHECK: store i8 1, i8* bitcast (i64* @_ZGVN1XIfE1mE to i8*)
 // CHECK: br label
 
 // LINUX: declare i32 @__cxa_thread_atexit(void (i8*)*, i8*, i8*)
@@ -285,7 +285,7 @@
 // need init:
 // CHECK: call i32 @_Z1gv()
 // CHECK: store i32 %{{.*}}, i32* @_ZN1VIiE1mE, align 4
-// CHECK: store i64 1, i64* @_ZGVN1VIiE1mE
+// CHECK: store i8 1, i8* bitcast (i64* @_ZGVN1VIiE1mE to i8*)
 // CHECK: br label
 
 // LINUX: define internal void @[[X_M_INIT]]()
@@ -298,7 +298,7 @@
 // need init:
 // LINUX: call {{.*}}__cxa_thread_atexit
 // DARWIN: call {{.*}}_tlv_atexit
-// CHECK: store i64 1, i64* @_ZGVN1XIiE1mE
+// CHECK: store i8 1, i8* bitcast (i64* @_ZGVN1XIiE1mE to i8*)
 // CHECK: br label
 
 // CHECK: define {{.*}}@[[GLOBAL_INIT:.*]]()
Index: clang/test/CodeGenCXX/aix-static-init.cpp
===
--- clang/test/CodeGenCXX/aix-static-init.cpp
+++ clang/test/CodeGenCXX/aix-static-init.cpp
@@ -38,6 +38,7 @@
   }
 } // namespace test4
 
+// CHECK: @_ZGVZN5test41fEvE11staticLocal = internal global i64 0, align 8
 // CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }]
 // CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_a, i8* null }]
 
@@ -135,7 +136,7 @@
 
 // CHECK: define void @_ZN5test41fEv() [[ATTR:#[0-9]+]] {
 // CHECK: entry:
-// CHECK:   %0 = load atomic i8, i8* bitcast (i64* @_ZGVZN5test41fEvE11staticLocal to i8*) acquire
+// CHECK:   %0 = load atomic i8, i8* bitcast (i64* @_ZGVZN5test41fEvE11staticLocal to i8*) acquire, align 8
 // CHECK:   %guard.uninitialized = icmp eq i8 %0, 0
 // CHECK:   br i1 %guard.uninitialized, label %init.check, label %init.end
 
Index: clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
===
--- clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
+++ clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
@@ -44,6 +44,9 @@
 A A::instance = bar();
 } // namespace test2
 
+// CHECK: @_ZGVN5test12t2E = linkonce_odr global i64 0, align 8
+// CHECK: @_ZGVN5test21AIvE8instanceE = weak_odr global i64 0, align 8
+// CHECK: @_ZGVN5test12t1IiEE = linkonce_odr global i64 0, align 8
 // CHECK: @llvm.global_ctors = appending global [4 x { i32, void ()*, i8* 

[PATCH] D95561: [Clang] Introduce Swift async calling convention.

2021-02-02 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:2711
+  Out << 'T';
+  break;
 case CC_PreserveMost: Out << 'U'; break;

rjmccall wrote:
> Please use consistent formatting with the other cases, here and elsewhere.  
> Keeping the switch compact is better for readability than following an 
> abstract style rule.
I'm pretty sure I wrote it the right way originally, but saying yes to the 
clang-tidy prompt by `arc` broke it. :sigh:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95561

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


[PATCH] D95561: [Clang] Introduce Swift async calling convention.

2021-02-02 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:8106-8115
+  case ParsedAttr::AT_SwiftAsyncCall:
   case ParsedAttr::AT_VectorCall:
   case ParsedAttr::AT_MSABI:
   case ParsedAttr::AT_SysVABI:
   case ParsedAttr::AT_Pcs:
   case ParsedAttr::AT_IntelOclBicc:
   case ParsedAttr::AT_PreserveMost:

There seems to be some weirdness here in `handleCallConvAttr` where the 
codepath to attach the attribute to the decl isn't taken. Instead in my 
examples, it exits out at this line:

```
  if (hasDeclarator(D)) return;
```

with an `isa` check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95561

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


[PATCH] D95561: [Clang] Introduce Swift async calling convention.

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

Broadly LGTM




Comment at: clang/include/clang/Basic/AttrDocs.td:4398
+  let Content = [{
+TODO
+  }];

varungandhi-apple wrote:
> I have left this as a TODO for now, so that it can be filled in later when 
> the exact details of the convention are implemented in LLVM.
We don't generally put precise CC details in this kind of documentation; the 
goal is to describe the calling convention at a high level.  Here, you should 
describe it as being compatible with the low-level conventions of Swift async 
functions, provided it declares the right formal arguments.  You should also 
talk about the special-case treatment of tail calls, especially the extension 
which adds `return (void)` to all language modes.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:2711
+  Out << 'T';
+  break;
 case CC_PreserveMost: Out << 'U'; break;

Please use consistent formatting with the other cases, here and elsewhere.  
Keeping the switch compact is better for readability than following an abstract 
style rule.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95561

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


[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 320879.
Xiangling_L marked 2 inline comments as done.
Xiangling_L added a comment.

Remove redundant file;


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

https://reviews.llvm.org/D95822

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  clang/test/CodeGenCXX/cxx11-thread-local.cpp
  clang/test/CodeGenCXX/global-init.cpp
  clang/test/CodeGenCXX/static-data-member.cpp

Index: clang/test/CodeGenCXX/static-data-member.cpp
===
--- clang/test/CodeGenCXX/static-data-member.cpp
+++ clang/test/CodeGenCXX/static-data-member.cpp
@@ -72,7 +72,7 @@
   // CHECK-NEXT: br i1 [[UNINITIALIZED]]
   // CHECK:  [[TMP:%.*]] = call i32 @_ZN5test33fooEv()
   // CHECK-NEXT: store i32 [[TMP]], i32* @_ZN5test31AIiE1xE, align 4
-  // CHECK-NEXT: store i64 1, i64* @_ZGVN5test31AIiE1xE
+  // CHECK-NEXT: store i8 1, i8* bitcast (i64* @_ZGVN5test31AIiE1xE to i8*)
   // CHECK-NEXT: br label
   // CHECK:  ret void
 }
Index: clang/test/CodeGenCXX/global-init.cpp
===
--- clang/test/CodeGenCXX/global-init.cpp
+++ clang/test/CodeGenCXX/global-init.cpp
@@ -81,7 +81,7 @@
   // CHECK: load i8, i8* bitcast (i64* @_ZGVN5test41xE
   // CHECK: [[CALL:%.*]] = call i32 @_ZN5test43fooEv
   // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test41xE
-  // CHECK-NEXT: store i64 1, i64* @_ZGVN5test41xE
+  // CHECK-NEXT: store i8 1, i8* bitcast (i64* @_ZGVN5test41xE to i8*)
   __attribute__((weak)) int x = foo();
 }
 
Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -184,7 +184,7 @@
 // need init:
 // CHECK: call i32 @_Z1gv()
 // CHECK: store i32 %{{.*}}, i32* @_ZN1VIfE1mE, align 4
-// CHECK: store i64 1, i64* @_ZGVN1VIfE1mE
+// CHECK: store i8 1, i8* bitcast (i64* @_ZGVN1VIfE1mE to i8*)
 // CHECK: br label
 
 // LINUX: define internal void @[[XF_M_INIT]]()
@@ -197,7 +197,7 @@
 // need init:
 // LINUX: call {{.*}}__cxa_thread_atexit
 // DARWIN: call {{.*}}_tlv_atexit
-// CHECK: store i64 1, i64* @_ZGVN1XIfE1mE
+// CHECK: store i8 1, i8* bitcast (i64* @_ZGVN1XIfE1mE to i8*)
 // CHECK: br label
 
 // LINUX: declare i32 @__cxa_thread_atexit(void (i8*)*, i8*, i8*)
@@ -285,7 +285,7 @@
 // need init:
 // CHECK: call i32 @_Z1gv()
 // CHECK: store i32 %{{.*}}, i32* @_ZN1VIiE1mE, align 4
-// CHECK: store i64 1, i64* @_ZGVN1VIiE1mE
+// CHECK: store i8 1, i8* bitcast (i64* @_ZGVN1VIiE1mE to i8*)
 // CHECK: br label
 
 // LINUX: define internal void @[[X_M_INIT]]()
@@ -298,7 +298,7 @@
 // need init:
 // LINUX: call {{.*}}__cxa_thread_atexit
 // DARWIN: call {{.*}}_tlv_atexit
-// CHECK: store i64 1, i64* @_ZGVN1XIiE1mE
+// CHECK: store i8 1, i8* bitcast (i64* @_ZGVN1XIiE1mE to i8*)
 // CHECK: br label
 
 // CHECK: define {{.*}}@[[GLOBAL_INIT:.*]]()
Index: clang/test/CodeGenCXX/aix-static-init.cpp
===
--- clang/test/CodeGenCXX/aix-static-init.cpp
+++ clang/test/CodeGenCXX/aix-static-init.cpp
@@ -38,6 +38,7 @@
   }
 } // namespace test4
 
+// CHECK: @_ZGVZN5test41fEvE11staticLocal = internal global i64 0, align 8
 // CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }]
 // CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_a, i8* null }]
 
@@ -135,7 +136,7 @@
 
 // CHECK: define void @_ZN5test41fEv() [[ATTR:#[0-9]+]] {
 // CHECK: entry:
-// CHECK:   %0 = load atomic i8, i8* bitcast (i64* @_ZGVZN5test41fEvE11staticLocal to i8*) acquire
+// CHECK:   %0 = load atomic i8, i8* bitcast (i64* @_ZGVZN5test41fEvE11staticLocal to i8*) acquire, align 8
 // CHECK:   %guard.uninitialized = icmp eq i8 %0, 0
 // CHECK:   br i1 %guard.uninitialized, label %init.check, label %init.end
 
Index: clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
===
--- clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
+++ clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
@@ -44,6 +44,9 @@
 A A::instance = bar();
 } // namespace test2
 
+// CHECK: @_ZGVN5test12t2E = linkonce_odr global i64 0, align 8
+// CHECK: @_ZGVN5test21AIvE8instanceE = weak_odr global i64 0, align 8
+// CHECK: @_ZGVN5test12t1IiEE = linkonce_odr global i64 0, align 8
 // CHECK: @llvm.global_ctors = appending global [4 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__cxx_global_var_init.1, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__cxx_global_var_init.2, i8* null }, { i32, void 

[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGenCXX/global-init.cpp:84
   // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test41xE
-  // CHECK-NEXT: store i64 1, i64* @_ZGVN5test41xE
+  // CHECK-NEXT: store i8 1, i8* bitcast (i64* @_ZGVN5test41xE to i8*)
   __attribute__((weak)) int x = foo();

Xiangling_L wrote:
> abhina.sreeskantharajan wrote:
> > nit: the lines above omit the end of the line. It's probably better to be 
> > consistent
> > 
> > 
> It didn't omit the end of the line. It is because before my patch, there was 
> no casting.
Hi @Xiangling_L, I think Abhina meant the lines above in this file. The `load` 
has a `bitcast` too (and stops after the guard variable name).


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

https://reviews.llvm.org/D95822

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


[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked 2 inline comments as done.
Xiangling_L added inline comments.



Comment at: clang/test/CodeGenCXX/global-init.cpp:84
   // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test41xE
-  // CHECK-NEXT: store i64 1, i64* @_ZGVN5test41xE
+  // CHECK-NEXT: store i8 1, i8* bitcast (i64* @_ZGVN5test41xE to i8*)
   __attribute__((weak)) int x = foo();

abhina.sreeskantharajan wrote:
> nit: the lines above omit the end of the line. It's probably better to be 
> consistent
> 
> 
It didn't omit the end of the line. It is because before my patch, there was no 
casting.



Comment at: guard.patch:1
+From 9c7d0afec1e634cdeaf3a2ca4273f5da07f6f946 Mon Sep 17 00:00:00 2001
+From: Xiangling Liao 

hubert.reinterpretcast wrote:
> Looks like this file got added by accident.
Thanks!


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

https://reviews.llvm.org/D95822

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


[PATCH] D94661: [clang-format] [PR19056] Add support for access modifiers indentation

2021-02-02 Thread Jakub Budiský via Phabricator via cfe-commits
Budovi planned changes to this revision.
Budovi added a comment.

In D94661#2537356 , 
@HazardyKnusperkeks wrote:

> You need to supply a full diff (with context).
> Please also add it to the release notes.

Oh sorry, forgot about the context lines. Will try to fix it tomorrow, along 
with the release notes.


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

https://reviews.llvm.org/D94661

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


[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: guard.patch:1
+From 9c7d0afec1e634cdeaf3a2ca4273f5da07f6f946 Mon Sep 17 00:00:00 2001
+From: Xiangling Liao 

Looks like this file got added by accident.


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

https://reviews.llvm.org/D95822

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


[PATCH] D95822: [FE] Manipulate the first byte of guard variable type in both load and store operation

2021-02-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/test/CodeGenCXX/global-init.cpp:84
   // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test41xE
-  // CHECK-NEXT: store i64 1, i64* @_ZGVN5test41xE
+  // CHECK-NEXT: store i8 1, i8* bitcast (i64* @_ZGVN5test41xE to i8*)
   __attribute__((weak)) int x = foo();

nit: the lines above omit the end of the line. It's probably better to be 
consistent




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

https://reviews.llvm.org/D95822

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-02-02 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In D71726#2537101 , @yaxunl wrote:

> For amdgpu target, we do need diagnose unsupported atomics (not limited to fp 
> atomics) since we do not support libcall due to ISA level linking not 
> supported. This is something we cannot fix in a short time and we would 
> rather diagnose it than confusing the users with missing symbols in lld.

If this is limited simply to not supporting oversized or misaligned atomics, 
I'd find that a lot less objectionable. At that point you just need a single 
boolean variable/accessor for whether the target can support atomic library 
calls. I note that we already have warning messages: warn_atomic_op_misaligned 
and warn_atomic_op_oversized. Maybe those can just be promoted to errors on 
AMDGPU.


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

https://reviews.llvm.org/D71726

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


[PATCH] D93264: [CSSPGO] Introducing distribution factor for pseudo probe.

2021-02-02 Thread Hongtao Yu 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 rG3d89b3cbec23: [CSSPGO] Introducing distribution factor for 
pseudo probe. (authored by hoy).

Changed prior to commit:
  https://reviews.llvm.org/D93264?vs=320844=320873#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93264

Files:
  clang/test/CodeGen/pseudo-probe-emit.c
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/PseudoProbe.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/IR/PseudoProbe.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-update.prof
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-update.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll

Index: llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll
@@ -0,0 +1,77 @@
+; REQUIRES: x86_64-linux
+; RUN: opt < %s -passes='pseudo-probe,loop-unroll-full' -verify-pseudo-probe -S -o %t 2>&1 | FileCheck %s --check-prefix=VERIFY
+; RUN: FileCheck %s < %t
+
+; VERIFY: *** Pseudo Probe Verification After LoopFullUnrollPass ***
+; VERIFY: Function foo:
+; VERIFY-DAG: Probe 6	previous factor 1.00	current factor 5.00
+; VERIFY-DAG: Probe 4	previous factor 1.00	current factor 5.00
+
+declare void @foo2() nounwind
+
+define void @foo(i32 %x) {
+bb:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0, i64 -1)
+  %tmp = alloca [5 x i32*], align 16
+  br label %bb7.preheader
+
+bb3.loopexit:
+  %spec.select.lcssa = phi i32 [ %spec.select, %bb10 ]
+  %tmp5.not = icmp eq i32 %spec.select.lcssa, 0
+  br i1 %tmp5.not, label %bb24, label %bb7.preheader
+
+bb7.preheader:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 3, i32 0, i64 -1)
+  %tmp1.06 = phi i32 [ 5, %bb ], [ %spec.select.lcssa, %bb3.loopexit ]
+  br label %bb10
+
+bb10:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 2, i32 0, i64 -1)
+  %indvars.iv = phi i64 [ 0, %bb7.preheader ], [ %indvars.iv.next, %bb10 ]
+  %tmp1.14 = phi i32 [ %tmp1.06, %bb7.preheader ], [ %spec.select, %bb10 ]
+  %tmp13 = getelementptr inbounds [5 x i32*], [5 x i32*]* %tmp, i64 0, i64 %indvars.iv
+  %tmp14 = load i32*, i32** %tmp13, align 8
+  %tmp15.not = icmp ne i32* %tmp14, null
+  %tmp18 = sext i1 %tmp15.not to i32
+  %spec.select = add nsw i32 %tmp1.14, %tmp18
+  call void @foo2(), !dbg !12
+  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+  %exitcond.not = icmp eq i64 %indvars.iv.next, 5
+  br i1 %exitcond.not, label %bb3.loopexit, label %bb10, !llvm.loop !13
+
+bb24:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 5, i32 0, i64 -1)
+  ret void
+}
+
+;; A discriminator of 186646583 which is 0xb200037 in hexdecimal, stands for a direct call probe
+;; with an index of 6 and a scale of -1%.
+; CHECK: ![[#PROBE6]] = !DILocation(line: 2, column: 20, scope: ![[#SCOPE:]])
+; CHECK: ![[#SCOPE]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 186646583)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!9, !10}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2)
+!1 = !DIFile(filename: "test.c", directory: "")
+!2 = !{}
+!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, retainedNodes: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7}
+!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!9 = 

[clang] 3d89b3c - [CSSPGO] Introducing distribution factor for pseudo probe.

2021-02-02 Thread Hongtao Yu via cfe-commits

Author: Hongtao Yu
Date: 2021-02-02T11:55:01-08:00
New Revision: 3d89b3cbec230633e8228787819b15116c1a1730

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

LOG: [CSSPGO] Introducing distribution factor for pseudo probe.

Sample re-annotation is required in LTO time to achieve a reasonable 
post-inline profile quality. However, we have seen that such LTO-time 
re-annotation degrades profile quality. This is mainly caused by preLTO code 
duplication that is done by passes such as loop unrolling, jump threading, 
indirect call promotion etc, where samples corresponding to a source location 
are aggregated multiple times due to the duplicates. In this change we are 
introducing a concept of distribution factor for pseudo probes so that samples 
can be distributed for duplicated probes scaled by a factor. We hope that 
optimizations duplicating code well-maintain the branch frequency information 
(BFI) based on which probe distribution factors are calculated. Distribution 
factors are updated at the end of preLTO pipeline to reflect an estimated 
portion of the real execution count.

This change also introduces a pseudo probe verifier that can be run after each 
IR passes to detect duplicated pseudo probes.

A saturated distribution factor stands for 1.0. A pesudo probe will carry a 
factor with the value ranged from 0.0 to 1.0. A 64-bit integral distribution 
factor field that represents [0.0, 1.0] is associated to each block probe. 
Unfortunately this cannot be done for callsite probes due to the size 
limitation of a 32-bit Dwarf discriminator. A 7-bit distribution factor is used 
instead.

Changes are also needed to the sample profile inliner to deal with prorated 
callsite counts. Call sites duplicated by PreLTO passes, when later on inlined 
in LTO time, should have the callees’s probe prorated based on the 
Prelink-computed distribution factors. The distribution factors should also be 
taken into account when computing hotness for inline candidates. Also, Indirect 
call promotion results in multiple callisites. The original samples should be 
distributed across them. This is fixed by adjusting the callisites' 
distribution factors.

Reviewed By: wmi

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

Added: 
llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-update.prof
llvm/test/Transforms/SampleProfile/pseudo-probe-update.ll
llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll

Modified: 
clang/test/CodeGen/pseudo-probe-emit.c
llvm/include/llvm/IR/IntrinsicInst.h
llvm/include/llvm/IR/Intrinsics.td
llvm/include/llvm/IR/PseudoProbe.h
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/include/llvm/ProfileData/SampleProf.h
llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
llvm/lib/IR/PseudoProbe.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll
llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll

Removed: 




diff  --git a/clang/test/CodeGen/pseudo-probe-emit.c 
b/clang/test/CodeGen/pseudo-probe-emit.c
index 059673b6992e..fccc8f04844d 100644
--- a/clang/test/CodeGen/pseudo-probe-emit.c
+++ b/clang/test/CodeGen/pseudo-probe-emit.c
@@ -6,12 +6,12 @@ void bar();
 void go();
 
 void foo(int x) {
-  // CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0)
+  // CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0, i64 -1)
   if (x == 0)
-// CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 2, i32 0)
+// CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 2, i32 0, i64 -1)
 bar();
   else
-// CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 3, i32 0)
+// CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 3, i32 0, i64 -1)
 go();
-  // CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 4, i32 0)
+  // CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 4, i32 0, i64 -1)
 }

diff  --git a/llvm/include/llvm/IR/IntrinsicInst.h 
b/llvm/include/llvm/IR/IntrinsicInst.h
index 9d68f3fdde6c..df3a1d568756 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -981,12 +981,16 @@ class PseudoProbeInst : public IntrinsicInst {
 return cast(const_cast(getArgOperand(0)));
   }
 
+  ConstantInt *getIndex() const {
+return cast(const_cast(getArgOperand(1)));
+  }
+
   ConstantInt *getAttributes() const {
 return cast(const_cast(getArgOperand(2)));
   }
 
-  

[PATCH] D94661: [clang-format] [PR19056] Add support for access modifiers indentation

2021-02-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

You need to supply a full diff (with context).
Please also add it to the release notes.


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

https://reviews.llvm.org/D94661

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


[PATCH] D95655: [AArch64] Adding Neon Sm3 & Sm4 Intrinsics

2021-02-02 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic added a comment.

@t.p.northover Could you take a look before I ask for this to be merged?


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

https://reviews.llvm.org/D95655

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


[PATCH] D94627: [PowerPC][PC Rel] Implement option to omit Power10 instructions from stubs

2021-02-02 Thread Albion Fung via Phabricator via cfe-commits
Conanap added a comment.

Added a note on one of the functions




Comment at: lld/ELF/Driver.cpp:765
+// instructions in stubs.
+static bool getP10StubOpt(opt::InputArgList ) {
+

For this function here, I realize we can inline all the ifs into a giant return 
statement - is there any opinions on this? I thought the if statements might 
make this a bit more readable, but if it is preferred that there is only 1 
return statement I can make that change as well.


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

https://reviews.llvm.org/D94627

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


[PATCH] D94627: [PowerPC][PC Rel] Implement option to omit Power10 instructions from stubs

2021-02-02 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 320865.
Conanap marked 10 inline comments as done.
Conanap added a comment.

Addressed comments, fixed an incorrect encoding.


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

https://reviews.llvm.org/D94627

Files:
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/Thunks.cpp
  lld/ELF/Thunks.h
  lld/test/ELF/ppc64-call-reach.s
  lld/test/ELF/ppc64-long-branch-localentry-offset.s
  lld/test/ELF/ppc64-long-branch-pi.s
  lld/test/ELF/ppc64-long-branch-rel14.s
  lld/test/ELF/ppc64-long-branch.s
  lld/test/ELF/ppc64-pcrel-call-to-extern.s
  lld/test/ELF/ppc64-pcrel-call-to-toc.s
  lld/test/ELF/ppc64-plt-stub-compatible.s
  lld/test/ELF/ppc64-tls-pcrel-gd.s
  lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
  lld/test/ELF/ppc64-toc-call-to-pcrel.s
  llvm/include/llvm/Object/ELF.h

Index: llvm/include/llvm/Object/ELF.h
===
--- llvm/include/llvm/Object/ELF.h
+++ llvm/include/llvm/Object/ELF.h
@@ -87,6 +87,9 @@
 
 enum PPCInstrMasks : uint64_t {
   PADDI_R12_NO_DISP = 0x06103980,
+  ADDIS_R12_TO_R2_NO_DISP = 0x3D82,
+  ADDI_R12_TO_R2_NO_DISP = 0x3982,
+  ADDI_R12_TO_R12_NO_DISP = 0x398C,
   PLD_R12_NO_DISP = 0x0410E580,
   MTCTR_R12 = 0x7D8903A6,
   BCTR = 0x4E800420,
Index: lld/test/ELF/ppc64-toc-call-to-pcrel.s
===
--- lld/test/ELF/ppc64-toc-call-to-pcrel.s
+++ lld/test/ELF/ppc64-toc-call-to-pcrel.s
@@ -14,6 +14,12 @@
 # RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
 # RUN: llvm-objdump -d --no-show-raw-insn --mcpu=future %t | FileCheck %s
 
+# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t.o
+# RUN: ld.lld -T %t.script %t.o -o %t --no-power10-stubs
+# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL
+# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=future %t \
+# RUN: | FileCheck %s
+
 # The point of this test is to make sure that when a function with TOC access
 # a local function with st_other=1, a TOC save stub is inserted.
 
Index: lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
===
--- lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
+++ lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s
@@ -11,15 +11,20 @@
 # RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_be | FileCheck %s
 # RUN: llvm-readelf -s %t_be | FileCheck %s --check-prefix=SYM
 
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/asm -o %t.o
+# RUN: ld.lld -T %t/lts %t.o -o %t_le --no-power10-stubs
+# RUN: llvm-objdump --mcpu=pwr10 --no-show-raw-insn -d %t_le | FileCheck %s --check-prefix=NoP10
+# RUN: llvm-readelf -s %t_le | FileCheck %s --check-prefix=SYM
+
 # SYM:  Symbol table '.symtab' contains 9 entries:
 # SYM:  1: 1001 0 NOTYPE  LOCAL  DEFAULT []   1 callee
 # SYM-NEXT: 2: 20020008 0 NOTYPE  LOCAL  DEFAULT []   3 caller
 # SYM-NEXT: 3: 10020008 0 NOTYPE  LOCAL  DEFAULT  2 caller_close
 # SYM-NEXT: 4: 000520020008 0 NOTYPE  LOCAL  DEFAULT  4 caller_far
-# SYM-NEXT: 5: 000520028038 0 NOTYPE  LOCAL  HIDDEN   6 .TOC.
+# SYM-NEXT: 5: 000520028040 0 NOTYPE  LOCAL  HIDDEN   6 .TOC.
 # SYM-NEXT: 6: 10020020 8 FUNCLOCAL  DEFAULT  2 __toc_save_callee
-# SYM-NEXT: 7: 2002002020 FUNCLOCAL  DEFAULT  3 __toc_save_callee
-# SYM-NEXT: 8: 00052002002020 FUNCLOCAL  DEFAULT  4 __toc_save_callee
+# SYM-NEXT: 7: 2002002032 FUNCLOCAL  DEFAULT  3 __toc_save_callee
+# SYM-NEXT: 8: 00052002002032 FUNCLOCAL  DEFAULT  4 __toc_save_callee
 
 #--- lts
 PHDRS {
@@ -72,6 +77,17 @@
 # CHECK-NEXT:paddi 12, 0, -268501028, 1
 # CHECK-NEXT:mtctr 12
 # CHECK-NEXT:bctr
+
+# NoP10-LABEL: :
+# NoP10: bl 0x20020020
+# NoP10-NEXT:ld 2, 24(1)
+# NoP10-NEXT:blr
+# NoP10-LABEL: <__toc_save_callee>:
+# NoP10-NEXT: std 2, 24(1)
+# NoP10-NEXT:addis 12, 2, -4098
+# NoP10-NEXT:addi 12, 12, 32704
+# NoP10-NEXT:mtctr 12
+# NoP10-NEXT:bctr
 .section .text_caller, "ax", %progbits
 .Lfunc_toc2:
   .quad .TOC.-.Lfunc_gep2
Index: lld/test/ELF/ppc64-tls-pcrel-gd.s
===
--- lld/test/ELF/ppc64-tls-pcrel-gd.s
+++ lld/test/ELF/ppc64-tls-pcrel-gd.s
@@ -42,10 +42,10 @@
 #--- asm
 
 # GD-RELOC: Relocation section '.rela.dyn' at offset 0x100b8 contains 4 entries:
-# GD-RELOC: 01001160  00020044 R_PPC64_DTPMOD64    x + 0
-# GD-RELOC: 01001168  0002004e R_PPC64_DTPREL64    x + 0
-# GD-RELOC: 01001170  00030044 R_PPC64_DTPMOD64    y + 0
-# GD-RELOC: 01001178  

[PATCH] D95608: [OpenCL][PR48896] Fix address space in binding of initializer lists to references

2021-02-02 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.

I think idiomatically we normally just use `(void)` instead of spelling it out 
with `static_cast`, since there's only one possible meaning for a cast to 
`void`.  I don't care deeply about it; if you make that change, feel free to 
make it as part of committing.


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

https://reviews.llvm.org/D95608

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

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

In D71726#2537101 , @yaxunl wrote:

> In D71726#2537054 , @tra wrote:
>
>> In D71726#2536966 , @jyknight wrote:
>>
>>> My concern is that this is treating a backend _bug_ as if it were just an 
>>> optional feature. But it's not the case that it might be reasonable to 
>>> either implement or not implement this in a backend -- it should be 
>>> implemented, and those that don't are buggy.
>>>
>>> I'd be happier with just having an ISEL failure when you try to use fp 
>>> atomics on broken targets, rather than adding all this code and 
>>> configuration to Clang in order to avoid that. (And, of course, the target 
>>> maintainers should also fix them)
>>
>> +1. I agree with James.
>>
>> Removing code is often harder than adding it. When you're adding things, 
>> you're the only user. Once things are in, they will start growing 
>> dependencies that will need to be dealt with if you ever want to remove the 
>> code.
>>
>> Clean solution that works for AMDGPU only for now is better than a 
>> potentially permanent workaround.
>
> For amdgpu target, we do need diagnose unsupported atomics (not limited to fp 
> atomics) since we do not support libcall due to ISA level linking not 
> supported. This is something we cannot fix in a short time and we would 
> rather diagnose it than confusing the users with missing symbols in lld.

Diagnosing that you don't support atomics your target can't reasonably support 
is completely fine.  (You could actually actually inline a locking approach if 
you really wanted to, though; Microsoft's `std::atomic` does that in the 
general case, although admittedly that's library code.)  I would like to 
understand whether that's really type-specific or just size-specific, though, 
and I don't think we've gotten a plain answer about that.  Is it true that 
amdgpu simply does not have a generic cmpxchg?

> For other targets, I can make changes to assume fp atomics are supported if 
> width is within max inline atomic width of the target. Basically this will 
> let fp atomics emitted for these targets and assuming middle end or backend 
> will handle them properly.

I think that's reasonable.


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

https://reviews.llvm.org/D71726

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


[PATCH] D95822: [FE][AIX] Use i8 as guard variable type in both load and store operation

2021-02-02 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked 2 inline comments as done.
Xiangling_L added inline comments.



Comment at: 
clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp:193
 // CHECK:   %1 = call i32 @atexit(void ()* @__dtor__ZN5test12t1IiEE)
-// CHECK:   store i64 1, i64* @_ZGVN5test12t1IiEE
 // CHECK:   br label %init.end

hubert.reinterpretcast wrote:
> Okay, so the store here is wrong, but it's got nothing to do with AIX.
> 
> The ABI doc (http://itanium-cxx-abi.github.io/cxx-abi/abi.html#once-ctor) 
> says:
> > the first byte (i.e., the byte with lowest address)
> 
> So the bug here seems to be that the Itanium ABI implementation in Clang is 
> incorrect for big-endian systems.
That makes sense to me. I will update the patch accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95822

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


[PATCH] D95558: [NFC][CUDA] Refactor registering device variable

2021-02-02 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

LGTM.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4270-4271
 } else {
-  // Host-side shadows of external declarations of device-side
-  // global variables become internal definitions. These have to
-  // be internal in order to prevent name conflicts with global
-  // host variables with the same name in a different TUs.
-  if (D->hasAttr() || D->hasAttr()) {
-Linkage = llvm::GlobalValue::InternalLinkage;
-// Shadow variables and their properties must be registered with CUDA
-// runtime. Skip Extern global variables, which will be registered in
-// the TU where they are defined.
-//
-// Don't register a C++17 inline variable. The local symbol can be
-// discarded and referencing a discarded local symbol from outside the
-// comdat (__cuda_register_globals) is disallowed by the ELF spec.
-// TODO: Reject __device__ constexpr and __device__ inline in Sema.
-if (!D->hasExternalStorage() && !D->isInline())
-  getCUDARuntime().registerDeviceVar(D, *GV, !D->hasDefinition(),
- D->hasAttr());
-  } else if (D->hasAttr()) {
-// __shared__ variables are odd. Shadows do get created, but
-// they are not registered with the CUDA runtime, so they
-// can't really be used to access their device-side
-// counterparts. It's not clear yet whether it's nvcc's bug or
-// a feature, but we've got to do the same for compatibility.
-Linkage = llvm::GlobalValue::InternalLinkage;
-  } else if (D->getType()->isCUDADeviceBuiltinSurfaceType() ||
- D->getType()->isCUDADeviceBuiltinTextureType()) {
-// Builtin surfaces and textures and their template arguments are
-// also registered with CUDA runtime.
-Linkage = llvm::GlobalValue::InternalLinkage;
-const ClassTemplateSpecializationDecl *TD =
-cast(
-D->getType()->getAs()->getDecl());
-const TemplateArgumentList  = TD->getTemplateArgs();
-if (TD->hasAttr()) {
-  assert(Args.size() == 2 &&
- "Unexpected number of template arguments of CUDA device "
- "builtin surface type.");
-  auto SurfType = Args[1].getAsIntegral();
-  if (!D->hasExternalStorage())
-getCUDARuntime().registerDeviceSurf(D, *GV, !D->hasDefinition(),
-SurfType.getSExtValue());
-} else {
-  assert(Args.size() == 3 &&
- "Unexpected number of template arguments of CUDA device "
- "builtin texture type.");
-  auto TexType = Args[1].getAsIntegral();
-  auto Normalized = Args[2].getAsIntegral();
-  if (!D->hasExternalStorage())
-getCUDARuntime().registerDeviceTex(D, *GV, !D->hasDefinition(),
-   TexType.getSExtValue(),
-   Normalized.getZExtValue());
-}
-  }
+  getCUDARuntime().internalizeDeviceSideVars(D, Linkage);
+  getCUDARuntime().handleVarRegistration(D, *GV);
 }

yaxunl wrote:
> tra wrote:
> > yaxunl wrote:
> > > tra wrote:
> > > > Should we fold `internalizeDeviceSideVar` into `handleVarRegistration` 
> > > > or call it from there?
> > > > I don't think we'll have any independent use for it in CGM.  It seems 
> > > > to be an implementation detail for `handleVarRegistration` and may not 
> > > > even need to be virtual.
> > > > 
> > > For function scope static variable, I only need to call 
> > > handleVarRegistration since the variable already has internal linkage. If 
> > > internalizeDeviceSideVars is absorbed into handleVarRegistration, there 
> > > be useless work and I also need to define a useless automatic variable 
> > > `Linkage` and pass it to handleVarRegistration.
> > `internalizeDeviceSideVars` is nearly trivial. I doubt that it will have 
> > any measureable impact, either way.
> > 
> > At the moment `handleVarRegistration()` is called only from here. Are you 
> > saying that separate internalization and registration will be needed in the 
> > future changes? If that's the case I'm fine keeping them separate.
> > 
> > As things are in the patch, I do not see why `internalizeDeviceSideVars` 
> > needs to be a base class interface. It's always used along with 
> > `handleVarRegistration` and we have no need to be able to override it 
> > independently of it. Folding it into or calling it from 
> > `handleVarRegistration` looks like a natural fit. 
> > 
> > 
> It is used differently in https://reviews.llvm.org/D95560, where only 
> handleVarRegistration is called.
Got it.


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

https://reviews.llvm.org/D95558

___
cfe-commits mailing 

[PATCH] D95840: [CUDA][HIP] Fix checking dependent initalizer

2021-02-02 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Sema/SemaCUDA.cpp:538
   AllowedInit =
-  ((VD->getType()->isDependentType() || Init->isValueDependent()) &&
-   VD->isConstexpr()) ||
+  (VD->getType()->isDependentType() || Init->isValueDependent()) ||
   Init->isConstantInitializer(Context,

Nit, no need for `()` any more, as all parts of the expression ar `||`-ed 
together.



Comment at: clang/test/SemaCUDA/dependent-device-var.cu:8
+__device__ int fun1(T x) {
+  static __device__ int a = sizeof(x);
+  static __device__ int b = x;

So, the patch now allows using type-dependent constant expressions now. 
I'd add a comment highlighting this. It's not always obvious that the test's 
purpose is to verify the absence of an error.


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

https://reviews.llvm.org/D95840

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


[clang] 74c94b5 - [test] Default clang/test to FileCheck --allow-unused-prefixes=false

2021-02-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-02-02T11:22:46-08:00
New Revision: 74c94b5d9c2b19333b43684c9d60decd41543d50

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

LOG: [test] Default clang/test to FileCheck --allow-unused-prefixes=false

Added: 
clang/test/OpenMP/lit.local.cfg

Modified: 
clang/test/Analysis/lit.local.cfg
clang/test/Driver/lit.local.cfg
clang/test/lit.cfg.py

Removed: 
clang/test/CodeGen/lit.local.cfg
clang/test/CodeGenCXX/lit.local.cfg



diff  --git a/clang/test/Analysis/lit.local.cfg 
b/clang/test/Analysis/lit.local.cfg
index 1560848b1f756..1e8cf4c3b7c4b 100644
--- a/clang/test/Analysis/lit.local.cfg
+++ b/clang/test/Analysis/lit.local.cfg
@@ -26,9 +26,3 @@ config.substitutions.append(('%normalize_sarif',
 
 if not config.root.clang_staticanalyzer:
 config.unsupported = True
-
-fc = ToolSubst('FileCheck', unresolved='fatal')
-# Insert this first. Then, we'll first update the blank FileCheck command; 
then,
-# the default substitution of FileCheck will replace it to its full path.
-config.substitutions.insert(0, (fc.regex,
-'FileCheck --allow-unused-prefixes=false'))

diff  --git a/clang/test/CodeGen/lit.local.cfg 
b/clang/test/CodeGen/lit.local.cfg
deleted file mode 100644
index c5bb8b60a52a3..0
--- a/clang/test/CodeGen/lit.local.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
-from lit.llvm.subst import ToolSubst
-
-fc = ToolSubst('FileCheck', unresolved='fatal')
-# Insert this first. Then, we'll first update the blank FileCheck command; 
then,
-# the default substitution of FileCheck will replace it to its full path.
-config.substitutions.insert(0, (fc.regex,
-'FileCheck --allow-unused-prefixes=false'))
-

diff  --git a/clang/test/CodeGenCXX/lit.local.cfg 
b/clang/test/CodeGenCXX/lit.local.cfg
deleted file mode 100644
index c5bb8b60a52a3..0
--- a/clang/test/CodeGenCXX/lit.local.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
-from lit.llvm.subst import ToolSubst
-
-fc = ToolSubst('FileCheck', unresolved='fatal')
-# Insert this first. Then, we'll first update the blank FileCheck command; 
then,
-# the default substitution of FileCheck will replace it to its full path.
-config.substitutions.insert(0, (fc.regex,
-'FileCheck --allow-unused-prefixes=false'))
-

diff  --git a/clang/test/Driver/lit.local.cfg b/clang/test/Driver/lit.local.cfg
index 7dbadaeed12fe..ad3f0e92cacdd 100644
--- a/clang/test/Driver/lit.local.cfg
+++ b/clang/test/Driver/lit.local.cfg
@@ -1,11 +1,3 @@
-from lit.llvm.subst import ToolSubst
-
-fc = ToolSubst('FileCheck', unresolved='fatal')
-# Insert this first. Then, we'll first update the blank FileCheck command; 
then,
-# the default substitution of FileCheck will replace it to its full path.
-config.substitutions.insert(0, (fc.regex,
-'FileCheck --allow-unused-prefixes=false'))
-
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', 
'.F90', '.f95',
'.cu', '.rs', '.cl', '.hip']
 config.substitutions = list(config.substitutions)

diff  --git a/clang/test/OpenMP/lit.local.cfg b/clang/test/OpenMP/lit.local.cfg
new file mode 100644
index 0..ac72c2de97773
--- /dev/null
+++ b/clang/test/OpenMP/lit.local.cfg
@@ -0,0 +1,10 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# the parent introduced the opposite rule, so we replace it if we see it.
+if len(config.substitutions) > 0 and config.substitutions[0] == (fc.regex, 
'FileCheck --allow-unused-prefixes=false'):
+config.substitutions[0] = (
+fc.regex, 'FileCheck --allow-unused-prefixes=true')
+else:
+config.substitutions.insert(0, (fc.regex, 'FileCheck 
--allow-unused-prefixes=true'))

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 863ab444fb023..a47ebe74ddbae 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -43,6 +43,14 @@
 
 llvm_config.use_clang()
 
+# FIXME: remove this when we flip the default value for --allow-unused-prefixes
+# to false.
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; 
then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+
 config.substitutions.append(
 ('%src_include_dir', config.clang_src_dir + '/include'))
 



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


[PATCH] D95560: [CUDA][HIP] Fix function scope static variable

2021-02-02 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:7247-7250
+  // CUDA/HIP: Function-scope static variables in device or global functions
+  // have implicit device or constant attribute. Function-scope static 
variables
+  // in host device functions have implicit device or constant attribute in
+  // device compilation only.

yaxunl wrote:
> tra wrote:
> > This is somewhat confusing. I guess the issue is that we're conflating all 
> > the functionality implied by the `__device__` attribute and the `accessible 
> > on device` which is a subset of it. For the static vars in D functions you 
> > only need for it to be accessible on device, IMO. For HD functions, you do 
> > need the full `__device__` functionality, with host shadow and runtime 
> > registration.
> > 
> > While adding implicit `__device__` works for statics in the device-only 
> > functions, it's a bit of an overkill. It also gives us a somewhat different 
> > AST between host/device compilations.
> > 
> > Perhaps we can handle statics in device-only functions w/o adding implicit 
> > `__device__`. Can we check the parent of the variable instead when we check 
> > whether we're allowed to reference the variable? 
> Before we consider a function scope static variable without explicit device 
> attribute, let's consider the difference between a static variable with 
> explicit device attribute and a global device variable. They are both emitted 
> in device compilation and have shadow variables in host compilation. The only 
> difference is the linkage. A global device variable is supposed to be visible 
> to other compilation units, whereas a static device variable is supposed to 
> be visible to the same compilation unit only. A function scope static 
> variable with device attribute has similar traits: It needs to be emitted in 
> device compilation, and it needs a shadow variable in host compilation in 
> case it needs to be accessed in host code. The only difference is that it is 
> only visible inside the function.
> 
> Now let's consider a static var without device attribute in a device 
> function. From sema and codegen point of view, it should have difference from 
> a function scope static var with device attribute. Adding an implicit device 
> attribute would simplify its handling.
> 
> Now let's consider a static var without device attribute in a host device 
> function. The following code is valid for both nvcc and cuda-clang:
> 
> ```
> int __device__ __host__ func(int x) {
>   static int a = 1;
>   return a + x;
> }
> ```
> This requires the static variable is directly accessible in both device and 
> host compilation. This requires that in device compilation, the static var 
> behaves like a static var with explicit device attribute, whereas in host 
> compilation, the static var behaves like a normal host static var. By adding 
> implicit device attribute, we can clearly distinguish these situations and 
> reuse the sema and codegen logic of device attribute.
> A function scope static variable with device attribute has similar traits: It 
> needs to be emitted in device compilation, and it needs a shadow variable in 
> host compilation in case it needs to be accessed in host code. 

This is the part I don't agree with. Can you give me an example how a local 
variable in a `__device__` function can be accessed from the host code?

One can't refer to local static vars from outside of the function and even if 
the function returns the address, it will make no sense on the host side, 
because there's no reverse `device-address to host shadow` registration. I do 
not think we need host shadow or registration for device-side local statics. 
What do I miss?

> Now let's consider a static var without device attribute in a device 
> function. From sema and codegen point of view, it should have difference from 
> a function scope static var with device attribute. Adding an implicit device 
> attribute would simplify its handling.

I agree that it makes things simpler. What I'm saying is that the simple 
solution comes with an overhead that's not needed. 

>
> ```
> int __device__ __host__ func(int x) {
>   static int a = 1;
>   return a + x;
>}
>```
> 
> This requires the static variable is directly accessible in both device and 
> host compilation. 
> This requires that in device compilation, the static var behaves like a 
> static var with explicit device attribute, 
> whereas in host compilation, the static var behaves like a normal host static 
> var. 

I'm not sure I follow your reasoning. `directly accessible in both device and 
host compilation.` would need an equivalent of `__managed__` attribute. Regular 
`__device__` variables only allow the variable to have an address on the host 
side which can then be translated into device-side address by the runtime. The 
variable is only directly accessible from device.

> By adding implicit device attribute, we can clearly distinguish 

[PATCH] D95793: [clang][cli] Generate and round-trip language options

2021-02-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM, since I don't think the parallel error paths are too bad in this specific 
patch, but see my longer comment inline.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1196
 const std::vector ,
 DiagnosticsEngine , SanitizerSet ) {
+  bool Success = true;

jansvoboda11 wrote:
> dexonsmith wrote:
> > Can the caller use `Diags.hasErrorOccurred()` to avoid this change?
> Not really, because the caller might have `Diags` that already contains some 
> errors. We could compare the number of errors in `Diags` before and after 
> calling this function. `DiagnosticsEngine` doesn't have API for that, but 
> that could be added without much issues.
> 
> Do you have any specific reason for avoiding this change beyond minimizing 
> the diff?
> Not really, because the caller might have Diags that already contains some 
> errors. We could compare the number of errors in Diags before and after 
> calling this function. DiagnosticsEngine doesn't have API for that, but that 
> could be added without much issues.

Why not just return "failure" at the top level if any error has occurred? Why 
do we need to know if a specific parse routine failed?

If we have top-level callers that send in a DiagnosticEngine that has already 
been called, maybe we can change them to call `Reset` before entering.

> Do you have any specific reason for avoiding this change beyond minimizing 
> the diff? 

It's just fragile; it's a manual step to update Success every time an error is 
reported. Having two paths to give the same information is awkward and 
error-prone.

It'd be nice to have a hook that did both, so you could do something like:
```
reportError(diag::err_drv_invalid_value) << FlagName << Sanitizer;
```
and `reportError` would be something like:
```
auto reportError = [,](OptSpecifier Opt) {
  Success = false;
  return Diags.Report(Opt);
};
```
or to ensure warnings in the same interface, maybe could have:
```
auto reportDiag = [,](OptSpecifier Opt) {
  Success &= Diags.getDiagnosticLevel() >= DiagnosticsEngine::Error;
  return Diags.Report(Opt);
};
```
Not necessarily worth it for this patch (you can commit as-is), but if we're 
going to have to update swaths of code in this way it would be good to 
encapsulate the pattern somehow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95793

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


[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain for AMDGPU

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

fine with me, assuming this doesn't disturb anything outside the AMD pipeline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

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


[PATCH] D95558: [NFC][CUDA] Refactor registering device variable

2021-02-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4270-4271
 } else {
-  // Host-side shadows of external declarations of device-side
-  // global variables become internal definitions. These have to
-  // be internal in order to prevent name conflicts with global
-  // host variables with the same name in a different TUs.
-  if (D->hasAttr() || D->hasAttr()) {
-Linkage = llvm::GlobalValue::InternalLinkage;
-// Shadow variables and their properties must be registered with CUDA
-// runtime. Skip Extern global variables, which will be registered in
-// the TU where they are defined.
-//
-// Don't register a C++17 inline variable. The local symbol can be
-// discarded and referencing a discarded local symbol from outside the
-// comdat (__cuda_register_globals) is disallowed by the ELF spec.
-// TODO: Reject __device__ constexpr and __device__ inline in Sema.
-if (!D->hasExternalStorage() && !D->isInline())
-  getCUDARuntime().registerDeviceVar(D, *GV, !D->hasDefinition(),
- D->hasAttr());
-  } else if (D->hasAttr()) {
-// __shared__ variables are odd. Shadows do get created, but
-// they are not registered with the CUDA runtime, so they
-// can't really be used to access their device-side
-// counterparts. It's not clear yet whether it's nvcc's bug or
-// a feature, but we've got to do the same for compatibility.
-Linkage = llvm::GlobalValue::InternalLinkage;
-  } else if (D->getType()->isCUDADeviceBuiltinSurfaceType() ||
- D->getType()->isCUDADeviceBuiltinTextureType()) {
-// Builtin surfaces and textures and their template arguments are
-// also registered with CUDA runtime.
-Linkage = llvm::GlobalValue::InternalLinkage;
-const ClassTemplateSpecializationDecl *TD =
-cast(
-D->getType()->getAs()->getDecl());
-const TemplateArgumentList  = TD->getTemplateArgs();
-if (TD->hasAttr()) {
-  assert(Args.size() == 2 &&
- "Unexpected number of template arguments of CUDA device "
- "builtin surface type.");
-  auto SurfType = Args[1].getAsIntegral();
-  if (!D->hasExternalStorage())
-getCUDARuntime().registerDeviceSurf(D, *GV, !D->hasDefinition(),
-SurfType.getSExtValue());
-} else {
-  assert(Args.size() == 3 &&
- "Unexpected number of template arguments of CUDA device "
- "builtin texture type.");
-  auto TexType = Args[1].getAsIntegral();
-  auto Normalized = Args[2].getAsIntegral();
-  if (!D->hasExternalStorage())
-getCUDARuntime().registerDeviceTex(D, *GV, !D->hasDefinition(),
-   TexType.getSExtValue(),
-   Normalized.getZExtValue());
-}
-  }
+  getCUDARuntime().internalizeDeviceSideVars(D, Linkage);
+  getCUDARuntime().handleVarRegistration(D, *GV);
 }

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > Should we fold `internalizeDeviceSideVar` into `handleVarRegistration` or 
> > > call it from there?
> > > I don't think we'll have any independent use for it in CGM.  It seems to 
> > > be an implementation detail for `handleVarRegistration` and may not even 
> > > need to be virtual.
> > > 
> > For function scope static variable, I only need to call 
> > handleVarRegistration since the variable already has internal linkage. If 
> > internalizeDeviceSideVars is absorbed into handleVarRegistration, there be 
> > useless work and I also need to define a useless automatic variable 
> > `Linkage` and pass it to handleVarRegistration.
> `internalizeDeviceSideVars` is nearly trivial. I doubt that it will have any 
> measureable impact, either way.
> 
> At the moment `handleVarRegistration()` is called only from here. Are you 
> saying that separate internalization and registration will be needed in the 
> future changes? If that's the case I'm fine keeping them separate.
> 
> As things are in the patch, I do not see why `internalizeDeviceSideVars` 
> needs to be a base class interface. It's always used along with 
> `handleVarRegistration` and we have no need to be able to override it 
> independently of it. Folding it into or calling it from 
> `handleVarRegistration` looks like a natural fit. 
> 
> 
It is used differently in https://reviews.llvm.org/D95560, where only 
handleVarRegistration is called.


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

https://reviews.llvm.org/D95558

___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D95879: [clang][index] Mark file as C++ in parse-all-comments test

2021-02-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith 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/D95879/new/

https://reviews.llvm.org/D95879

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


[PATCH] D95886: [OpenCL][Docs] Link page explaining tooling for offline compilation

2021-02-02 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: svenvh.
Herald added subscribers: ebevhan, yaxunl.
Anastasia requested review of this revision.

https://reviews.llvm.org/D95886

Files:
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2832,8 +2832,10 @@
 portable IR is produced that can be used with various vendor
 tools as well as open source tools such as `SPIRV-LLVM Translator
 `_
-to produce SPIR-V binary.
-
+to produce SPIR-V binary. More detail are provided in the following
+online resource - `the offline compilation from OpenCL kernel sources into
+SPIR-V using open source tools
+`_.
 
 Clang currently supports OpenCL C language standards up to v2.0. Clang mainly
 supports full profile. There is only very limited support of the embedded


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2832,8 +2832,10 @@
 portable IR is produced that can be used with various vendor
 tools as well as open source tools such as `SPIRV-LLVM Translator
 `_
-to produce SPIR-V binary.
-
+to produce SPIR-V binary. More detail are provided in the following
+online resource - `the offline compilation from OpenCL kernel sources into
+SPIR-V using open source tools
+`_.
 
 Clang currently supports OpenCL C language standards up to v2.0. Clang mainly
 supports full profile. There is only very limited support of the embedded
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95558: [NFC][CUDA] Refactor registering device variable

2021-02-02 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4270-4271
 } else {
-  // Host-side shadows of external declarations of device-side
-  // global variables become internal definitions. These have to
-  // be internal in order to prevent name conflicts with global
-  // host variables with the same name in a different TUs.
-  if (D->hasAttr() || D->hasAttr()) {
-Linkage = llvm::GlobalValue::InternalLinkage;
-// Shadow variables and their properties must be registered with CUDA
-// runtime. Skip Extern global variables, which will be registered in
-// the TU where they are defined.
-//
-// Don't register a C++17 inline variable. The local symbol can be
-// discarded and referencing a discarded local symbol from outside the
-// comdat (__cuda_register_globals) is disallowed by the ELF spec.
-// TODO: Reject __device__ constexpr and __device__ inline in Sema.
-if (!D->hasExternalStorage() && !D->isInline())
-  getCUDARuntime().registerDeviceVar(D, *GV, !D->hasDefinition(),
- D->hasAttr());
-  } else if (D->hasAttr()) {
-// __shared__ variables are odd. Shadows do get created, but
-// they are not registered with the CUDA runtime, so they
-// can't really be used to access their device-side
-// counterparts. It's not clear yet whether it's nvcc's bug or
-// a feature, but we've got to do the same for compatibility.
-Linkage = llvm::GlobalValue::InternalLinkage;
-  } else if (D->getType()->isCUDADeviceBuiltinSurfaceType() ||
- D->getType()->isCUDADeviceBuiltinTextureType()) {
-// Builtin surfaces and textures and their template arguments are
-// also registered with CUDA runtime.
-Linkage = llvm::GlobalValue::InternalLinkage;
-const ClassTemplateSpecializationDecl *TD =
-cast(
-D->getType()->getAs()->getDecl());
-const TemplateArgumentList  = TD->getTemplateArgs();
-if (TD->hasAttr()) {
-  assert(Args.size() == 2 &&
- "Unexpected number of template arguments of CUDA device "
- "builtin surface type.");
-  auto SurfType = Args[1].getAsIntegral();
-  if (!D->hasExternalStorage())
-getCUDARuntime().registerDeviceSurf(D, *GV, !D->hasDefinition(),
-SurfType.getSExtValue());
-} else {
-  assert(Args.size() == 3 &&
- "Unexpected number of template arguments of CUDA device "
- "builtin texture type.");
-  auto TexType = Args[1].getAsIntegral();
-  auto Normalized = Args[2].getAsIntegral();
-  if (!D->hasExternalStorage())
-getCUDARuntime().registerDeviceTex(D, *GV, !D->hasDefinition(),
-   TexType.getSExtValue(),
-   Normalized.getZExtValue());
-}
-  }
+  getCUDARuntime().internalizeDeviceSideVars(D, Linkage);
+  getCUDARuntime().handleVarRegistration(D, *GV);
 }

yaxunl wrote:
> tra wrote:
> > Should we fold `internalizeDeviceSideVar` into `handleVarRegistration` or 
> > call it from there?
> > I don't think we'll have any independent use for it in CGM.  It seems to be 
> > an implementation detail for `handleVarRegistration` and may not even need 
> > to be virtual.
> > 
> For function scope static variable, I only need to call handleVarRegistration 
> since the variable already has internal linkage. If internalizeDeviceSideVars 
> is absorbed into handleVarRegistration, there be useless work and I also need 
> to define a useless automatic variable `Linkage` and pass it to 
> handleVarRegistration.
`internalizeDeviceSideVars` is nearly trivial. I doubt that it will have any 
measureable impact, either way.

At the moment `handleVarRegistration()` is called only from here. Are you 
saying that separate internalization and registration will be needed in the 
future changes? If that's the case I'm fine keeping them separate.

As things are in the patch, I do not see why `internalizeDeviceSideVars` needs 
to be a base class interface. It's always used along with 
`handleVarRegistration` and we have no need to be able to override it 
independently of it. Folding it into or calling it from `handleVarRegistration` 
looks like a natural fit. 




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

https://reviews.llvm.org/D95558

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


[PATCH] D94533: [clang] Add AddClang.cmake to the list of the CMake modules that are installed

2021-02-02 Thread Justin Bogner via Phabricator via cfe-commits
bogner accepted this revision.
bogner added a comment.
This revision is now accepted and ready to land.

This seems reasonable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94533

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


[PATCH] D93264: [CSSPGO] Introducing distribution factor for pseudo probe.

2021-02-02 Thread Hongtao Yu via Phabricator via cfe-commits
hoy updated this revision to Diff 320844.
hoy added a comment.

Rebasing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93264

Files:
  clang/test/CodeGen/pseudo-probe-emit.c
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/PseudoProbe.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/IR/PseudoProbe.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-update.prof
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-update.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll

Index: llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll
@@ -0,0 +1,77 @@
+; REQUIRES: x86_64-linux
+; RUN: opt < %s -passes='pseudo-probe,loop-unroll-full' -verify-pseudo-probe -S -o %t 2>&1 | FileCheck %s --check-prefix=VERIFY
+; RUN: FileCheck %s < %t
+
+; VERIFY: *** Pseudo Probe Verification After LoopFullUnrollPass ***
+; VERIFY: Function foo:
+; VERIFY: Probe 6	previous factor 1.00	current factor 5.00
+; VERIFY: Probe 4	previous factor 1.00	current factor 5.00
+
+declare void @foo2() nounwind
+
+define void @foo(i32 %x) {
+bb:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0, i64 -1)
+  %tmp = alloca [5 x i32*], align 16
+  br label %bb7.preheader
+
+bb3.loopexit:
+  %spec.select.lcssa = phi i32 [ %spec.select, %bb10 ]
+  %tmp5.not = icmp eq i32 %spec.select.lcssa, 0
+  br i1 %tmp5.not, label %bb24, label %bb7.preheader
+
+bb7.preheader:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 3, i32 0, i64 -1)
+  %tmp1.06 = phi i32 [ 5, %bb ], [ %spec.select.lcssa, %bb3.loopexit ]
+  br label %bb10
+
+bb10:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 2, i32 0, i64 -1)
+  %indvars.iv = phi i64 [ 0, %bb7.preheader ], [ %indvars.iv.next, %bb10 ]
+  %tmp1.14 = phi i32 [ %tmp1.06, %bb7.preheader ], [ %spec.select, %bb10 ]
+  %tmp13 = getelementptr inbounds [5 x i32*], [5 x i32*]* %tmp, i64 0, i64 %indvars.iv
+  %tmp14 = load i32*, i32** %tmp13, align 8
+  %tmp15.not = icmp ne i32* %tmp14, null
+  %tmp18 = sext i1 %tmp15.not to i32
+  %spec.select = add nsw i32 %tmp1.14, %tmp18
+  call void @foo2(), !dbg !12
+  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+  %exitcond.not = icmp eq i64 %indvars.iv.next, 5
+  br i1 %exitcond.not, label %bb3.loopexit, label %bb10, !llvm.loop !13
+
+bb24:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 5, i32 0, i64 -1)
+  ret void
+}
+
+;; A discriminator of 186646583 which is 0xb200037 in hexdecimal, stands for a direct call probe
+;; with an index of 6 and a scale of -1%.
+; CHECK: ![[#PROBE6]] = !DILocation(line: 2, column: 20, scope: ![[#SCOPE:]])
+; CHECK: ![[#SCOPE]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 186646583)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!9, !10}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2)
+!1 = !DIFile(filename: "test.c", directory: "")
+!2 = !{}
+!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, retainedNodes: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7}
+!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!9 = !{i32 2, !"Dwarf Version", i32 4}
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+!11 = !{!"clang version 3.9.0"}
+!12 = !DILocation(line: 2, column: 20, scope: !4)
+!13 = distinct !{!13, !14}
+!14 = !{!"llvm.loop.unroll.full"}
Index: 

[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

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

In D71726#2537054 , @tra wrote:

> In D71726#2536966 , @jyknight wrote:
>
>> My concern is that this is treating a backend _bug_ as if it were just an 
>> optional feature. But it's not the case that it might be reasonable to 
>> either implement or not implement this in a backend -- it should be 
>> implemented, and those that don't are buggy.
>>
>> I'd be happier with just having an ISEL failure when you try to use fp 
>> atomics on broken targets, rather than adding all this code and 
>> configuration to Clang in order to avoid that. (And, of course, the target 
>> maintainers should also fix them)
>
> +1. I agree with James.
>
> Removing code is often harder than adding it. When you're adding things, 
> you're the only user. Once things are in, they will start growing 
> dependencies that will need to be dealt with if you ever want to remove the 
> code.
>
> Clean solution that works for AMDGPU only for now is better than a 
> potentially permanent workaround.

For amdgpu target, we do need diagnose unsupported atomics (not limited to fp 
atomics) since we do not support libcall due to ISA level linking not 
supported. This is something we cannot fix in a short time and we would rather 
diagnose it than confusing the users with missing symbols in lld.

For other targets, I can make changes to assume fp atomics are supported if 
width is within max inline atomic width of the target. Basically this will let 
fp atomics emitted for these targets and assuming middle end or backend will 
handle them properly.


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

https://reviews.llvm.org/D71726

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


[PATCH] D95834: [OpenMP] Fix iterations calculation for dependent counters

2021-02-02 Thread Mike Rice via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca98c15f2335: [OpenMP] Fix iterations calculation for 
dependent counters. (authored by mikerice).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95834

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_codegen.cpp
  clang/test/OpenMP/for_loop_messages.cpp


Index: clang/test/OpenMP/for_loop_messages.cpp
===
--- clang/test/OpenMP/for_loop_messages.cpp
+++ clang/test/OpenMP/for_loop_messages.cpp
@@ -653,9 +653,10 @@
 ;
 
 #pragma omp parallel
-// expected-error@+5 2 {{expected loop invariant expression or ' * 
ii + ' kind of expression}}
-// expected-error@+4 {{expected loop invariant expression or ' * 
TC::ii + ' kind of expression}}
-// expected-error@+4 {{expected loop invariant expression or ' * 
TC::ii + ' kind of expression}}
+// expected-error@+6 {{expected loop invariant expression or ' * 
TC::ii + ' kind of expression}}
+// expected-error@+6 {{expected loop invariant expression or ' * 
TC::ii + ' kind of expression}}
+// expected-error@+4 2 {{expected loop invariant expression or ' * 
ii + ' kind of expression}}
+// expected-error@+4 2 {{expected loop invariant expression or ' * 
ii + ' kind of expression}}
 #pragma omp for collapse(3)
 for (ii = 10 + 25; ii < 1000; ii += 1)
   for (iii = ii * 10 + 25; iii < ii / ii - 23; iii += 1)
Index: clang/test/OpenMP/for_codegen.cpp
===
--- clang/test/OpenMP/for_codegen.cpp
+++ clang/test/OpenMP/for_codegen.cpp
@@ -198,6 +198,28 @@
 }
   }
 }
+
+// CHECK-LABEL: loop_with_counter_collapse4
+void loop_with_counter_collapse4() {
+
+  // Check bounds calculation when collapse > 2
+  // CHECK: store i32 0, i32* [[I_TMP:%.+]],
+  // CHECK: [[VAL:%.+]] = load i32, i32* [[I_TMP]],
+  // CHECK: store i32 [[VAL]], i32* [[K_LB_MIN:%.+]],
+  // CHECK: store i32 6, i32* [[I_TMP]],
+  // CHECK: [[VAL:%.+]] = load i32, i32* [[I_TMP]],
+  // CHECK: store i32 [[VAL]], i32* [[K_LB_MAX:%.+]],
+  #pragma omp for collapse(4)
+  for (int i = 0; i < 7; i++) {
+for (int j = 0; j < 11; j++) {
+  for (int k = i; k < 7; k++) {
+for (int l = 0; l < 11; l++) {
+}
+  }
+}
+  }
+}
+
 // CHECK-LABEL: define {{.*void}} @{{.*}}without_schedule_clause{{.*}}(float* 
{{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
 void without_schedule_clause(float *a, float *b, float *c, float *d) {
 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* 
[[DEFAULT_LOC:[@%].+]])
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -7413,10 +7413,7 @@
   // LB = TestIsLessOp.getValue() ? min(LB(MinVal), LB(MaxVal)) :
   // max(LB(MinVal), LB(MaxVal))
   if (InitDependOnLC) {
-const LoopIterationSpace  =
-ResultIterSpaces[ResultIterSpaces.size() - 1 -
- InitDependOnLC.getValueOr(
- CondDependOnLC.getValueOr(0))];
+const LoopIterationSpace  = ResultIterSpaces[*InitDependOnLC - 1];
 if (!IS.MinValue || !IS.MaxValue)
   return nullptr;
 // OuterVar = Min
@@ -7493,10 +7490,7 @@
   // UB = TestIsLessOp.getValue() ? max(UB(MinVal), UB(MaxVal)) :
   // min(UB(MinVal), UB(MaxVal))
   if (CondDependOnLC) {
-const LoopIterationSpace  =
-ResultIterSpaces[ResultIterSpaces.size() - 1 -
- InitDependOnLC.getValueOr(
- CondDependOnLC.getValueOr(0))];
+const LoopIterationSpace  = ResultIterSpaces[*CondDependOnLC - 1];
 if (!IS.MinValue || !IS.MaxValue)
   return nullptr;
 // OuterVar = Min


Index: clang/test/OpenMP/for_loop_messages.cpp
===
--- clang/test/OpenMP/for_loop_messages.cpp
+++ clang/test/OpenMP/for_loop_messages.cpp
@@ -653,9 +653,10 @@
 ;
 
 #pragma omp parallel
-// expected-error@+5 2 {{expected loop invariant expression or ' * ii + ' kind of expression}}
-// expected-error@+4 {{expected loop invariant expression or ' * TC::ii + ' kind of expression}}
-// expected-error@+4 {{expected loop invariant expression or ' * TC::ii + ' kind of expression}}
+// expected-error@+6 {{expected loop invariant expression or ' * TC::ii + ' kind of expression}}
+// expected-error@+6 {{expected loop invariant expression or ' * TC::ii + ' kind of expression}}
+// expected-error@+4 2 {{expected loop invariant expression or ' * ii + ' kind of expression}}
+// expected-error@+4 2 {{expected loop invariant expression or ' * ii + ' kind of expression}}
 #pragma omp for collapse(3)
 for (ii = 10 + 25; ii < 1000; ii += 1)
   

[clang] ca98c15 - [OpenMP] Fix iterations calculation for dependent counters.

2021-02-02 Thread Mike Rice via cfe-commits

Author: Mike Rice
Date: 2021-02-02T10:09:37-08:00
New Revision: ca98c15f23354520bf689bd5feb333a716159d2c

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

LOG: [OpenMP] Fix iterations calculation for dependent counters.

The number of iterations calculation was failing in some cases with more
than two collpased loops. Now the LoopIterationSpace selected matches
InitDependOnLC and CondDependOnLC.

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/for_codegen.cpp
clang/test/OpenMP/for_loop_messages.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index df42767f6ce4..b9315d287e6d 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -7413,10 +7413,7 @@ Expr *OpenMPIterationSpaceChecker::buildNumIterations(
   // LB = TestIsLessOp.getValue() ? min(LB(MinVal), LB(MaxVal)) :
   // max(LB(MinVal), LB(MaxVal))
   if (InitDependOnLC) {
-const LoopIterationSpace  =
-ResultIterSpaces[ResultIterSpaces.size() - 1 -
- InitDependOnLC.getValueOr(
- CondDependOnLC.getValueOr(0))];
+const LoopIterationSpace  = ResultIterSpaces[*InitDependOnLC - 1];
 if (!IS.MinValue || !IS.MaxValue)
   return nullptr;
 // OuterVar = Min
@@ -7493,10 +7490,7 @@ Expr *OpenMPIterationSpaceChecker::buildNumIterations(
   // UB = TestIsLessOp.getValue() ? max(UB(MinVal), UB(MaxVal)) :
   // min(UB(MinVal), UB(MaxVal))
   if (CondDependOnLC) {
-const LoopIterationSpace  =
-ResultIterSpaces[ResultIterSpaces.size() - 1 -
- InitDependOnLC.getValueOr(
- CondDependOnLC.getValueOr(0))];
+const LoopIterationSpace  = ResultIterSpaces[*CondDependOnLC - 1];
 if (!IS.MinValue || !IS.MaxValue)
   return nullptr;
 // OuterVar = Min

diff  --git a/clang/test/OpenMP/for_codegen.cpp 
b/clang/test/OpenMP/for_codegen.cpp
index 5a8402ee1702..64652e530f6a 100644
--- a/clang/test/OpenMP/for_codegen.cpp
+++ b/clang/test/OpenMP/for_codegen.cpp
@@ -198,6 +198,28 @@ void loop_with_counter_collapse() {
 }
   }
 }
+
+// CHECK-LABEL: loop_with_counter_collapse4
+void loop_with_counter_collapse4() {
+
+  // Check bounds calculation when collapse > 2
+  // CHECK: store i32 0, i32* [[I_TMP:%.+]],
+  // CHECK: [[VAL:%.+]] = load i32, i32* [[I_TMP]],
+  // CHECK: store i32 [[VAL]], i32* [[K_LB_MIN:%.+]],
+  // CHECK: store i32 6, i32* [[I_TMP]],
+  // CHECK: [[VAL:%.+]] = load i32, i32* [[I_TMP]],
+  // CHECK: store i32 [[VAL]], i32* [[K_LB_MAX:%.+]],
+  #pragma omp for collapse(4)
+  for (int i = 0; i < 7; i++) {
+for (int j = 0; j < 11; j++) {
+  for (int k = i; k < 7; k++) {
+for (int l = 0; l < 11; l++) {
+}
+  }
+}
+  }
+}
+
 // CHECK-LABEL: define {{.*void}} @{{.*}}without_schedule_clause{{.*}}(float* 
{{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
 void without_schedule_clause(float *a, float *b, float *c, float *d) {
 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* 
[[DEFAULT_LOC:[@%].+]])

diff  --git a/clang/test/OpenMP/for_loop_messages.cpp 
b/clang/test/OpenMP/for_loop_messages.cpp
index a1bc9bd3e045..e62ec07acc04 100644
--- a/clang/test/OpenMP/for_loop_messages.cpp
+++ b/clang/test/OpenMP/for_loop_messages.cpp
@@ -653,9 +653,10 @@ class TC {
 ;
 
 #pragma omp parallel
-// expected-error@+5 2 {{expected loop invariant expression or ' * 
ii + ' kind of expression}}
-// expected-error@+4 {{expected loop invariant expression or ' * 
TC::ii + ' kind of expression}}
-// expected-error@+4 {{expected loop invariant expression or ' * 
TC::ii + ' kind of expression}}
+// expected-error@+6 {{expected loop invariant expression or ' * 
TC::ii + ' kind of expression}}
+// expected-error@+6 {{expected loop invariant expression or ' * 
TC::ii + ' kind of expression}}
+// expected-error@+4 2 {{expected loop invariant expression or ' * 
ii + ' kind of expression}}
+// expected-error@+4 2 {{expected loop invariant expression or ' * 
ii + ' kind of expression}}
 #pragma omp for collapse(3)
 for (ii = 10 + 25; ii < 1000; ii += 1)
   for (iii = ii * 10 + 25; iii < ii / ii - 23; iii += 1)



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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-02-02 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D71726#2536966 , @jyknight wrote:

> My concern is that this is treating a backend _bug_ as if it were just an 
> optional feature. But it's not the case that it might be reasonable to either 
> implement or not implement this in a backend -- it should be implemented, and 
> those that don't are buggy.
>
> I'd be happier with just having an ISEL failure when you try to use fp 
> atomics on broken targets, rather than adding all this code and configuration 
> to Clang in order to avoid that. (And, of course, the target maintainers 
> should also fix them)

+1. I agree with James.

Removing code is often harder than adding it. When you're adding things, you're 
the only user. Once things are in, they will start growing dependencies that 
will need to be dealt with if you ever want to remove the code.

Clean solution that works for AMDGPU only for now is better than a potentially 
permanent workaround.


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

https://reviews.llvm.org/D71726

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


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2021-02-02 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

I managed to get this to fail in the debugger (for the cross-module-sm-pic-a.ll 
test):

01655e9d001e()  Unknown
01655e9d0019()  Unknown
017e5eb6b410()  Unknown
017c5eb63810()  Unknown
017e5eb6b410()  Unknown
017e5eb6b410()  Unknown
016f5eb65b58()  Unknown
  > lli.exe!llvm::MCJIT::runFunction(llvm::Function * F, 
llvm::ArrayRef ArgValues) Line 578 C++
lli.exe!llvm::ExecutionEngine::runFunctionAsMain(llvm::Function * Fn, 
const std::vector> & argv, const char * 
const * envp) Line 467C++
lli.exe!main(int argc, char * * argv, char * const * envp) Line 646 
C++
[Inline Frame] lli.exe!invoke_main() Line 78C++
lli.exe!__scrt_common_main_seh() Line 288   C++
kernel32.dll!7ffd145a7034() Unknown
ntdll.dll!7ffd1657d0d1()Unknown

It appears to be failing within the interpreted code. Maybe this is a problem 
between the memory allocator and the Memory Manager.

I tried running these tests repeatedly with scudo (sanitizer) on Linux but 
didn't see it fail. I also tried repeating these tests with rpmalloc on Windows 
and didn't see the failures so it does appear to be specific to scudo on 
Windows. I'll keep investigating.


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

https://reviews.llvm.org/D86694

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


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2021-02-02 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop updated this revision to Diff 320806.
russell.gallop added a comment.

Remove -fsanitize=scudo support for Windows in LLVM cmake, using 
LLVM_INTEGRATED_CRT_ALLOC instead.
Remove scudo_cxx from LLVM_INTEGRATED_CRT_ALLOC.


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

https://reviews.llvm.org/D86694

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
  compiler-rt/lib/scudo/CMakeLists.txt
  compiler-rt/lib/scudo/scudo_allocator.cpp
  compiler-rt/lib/scudo/scudo_crc32.cpp
  compiler-rt/lib/scudo/scudo_new_delete.cpp
  compiler-rt/lib/scudo/scudo_platform.h
  compiler-rt/lib/scudo/scudo_tsd.h
  compiler-rt/lib/scudo/scudo_tsd_shared.cpp
  compiler-rt/lib/scudo/scudo_tsd_shared.inc
  compiler-rt/test/scudo/cxx_threads.cpp
  compiler-rt/test/scudo/dealloc-race.c
  compiler-rt/test/scudo/fsanitize.c
  compiler-rt/test/scudo/interface.cpp
  compiler-rt/test/scudo/lit.cfg.py
  compiler-rt/test/scudo/malloc.cpp
  compiler-rt/test/scudo/memalign.c
  compiler-rt/test/scudo/mismatch.cpp
  compiler-rt/test/scudo/overflow.c
  compiler-rt/test/scudo/preload.cpp
  compiler-rt/test/scudo/rss.c
  compiler-rt/test/scudo/secondary.c
  compiler-rt/test/scudo/symbols.test
  compiler-rt/test/scudo/threads.c
  compiler-rt/test/scudo/tsd_destruction.c
  compiler-rt/test/scudo/valloc.c
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/lib/Support/CMakeLists.txt

Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -58,7 +58,7 @@
   string(REGEX REPLACE "(/|)$" "" LLVM_INTEGRATED_CRT_ALLOC "${LLVM_INTEGRATED_CRT_ALLOC}")
 
   if(NOT EXISTS "${LLVM_INTEGRATED_CRT_ALLOC}")
-message(FATAL_ERROR "Cannot find the path to `git clone` for the CRT allocator! (${LLVM_INTEGRATED_CRT_ALLOC}). Currently, rpmalloc, snmalloc and mimalloc are supported.")
+message(FATAL_ERROR "Cannot find the path to `git clone` for the CRT allocator! (${LLVM_INTEGRATED_CRT_ALLOC}). Currently, rpmalloc, snmalloc, mimalloc and scudo are supported.")
   endif()
 
   if(LLVM_INTEGRATED_CRT_ALLOC MATCHES "rpmalloc$")
@@ -73,6 +73,8 @@
 	  message(FATAL_ERROR "Cannot find the mimalloc static library. To build it, first apply the patch from https://github.com/microsoft/mimalloc/issues/268 then build the Release x64 target through ${LLVM_INTEGRATED_CRT_ALLOC}\\ide\\vs2019\\mimalloc.sln")
 endif()
 set(system_libs ${system_libs} "${MIMALLOC_LIB}" "-INCLUDE:malloc")
+  elseif(LLVM_INTEGRATED_CRT_ALLOC MATCHES "scudo")
+set(system_libs ${system_libs} "${LLVM_INTEGRATED_CRT_ALLOC}" "-INCLUDE:malloc")
   endif()
 endif()
 
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -790,6 +790,9 @@
 elseif (LLVM_USE_SANITIZER STREQUAL "Leaks")
   append_common_sanitizer_flags()
   append("-fsanitize=leak" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+elseif (LLVM_USE_SANITIZER STREQUAL "Scudo")
+  append_common_sanitizer_flags()
+  append("-fsanitize=scudo" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
 else()
   message(FATAL_ERROR "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
 endif()
Index: compiler-rt/test/scudo/valloc.c
===
--- compiler-rt/test/scudo/valloc.c
+++ compiler-rt/test/scudo/valloc.c
@@ -2,7 +2,7 @@
 // RUN: %run %t valid   2>&1
 // RUN: not %run %t invalid 2>&1 | FileCheck %s
 // RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t invalid 2>&1
-// UNSUPPORTED: android
+// UNSUPPORTED: android, windows
 
 // Tests that valloc and pvalloc work as intended.
 
Index: compiler-rt/test/scudo/tsd_destruction.c
===
--- compiler-rt/test/scudo/tsd_destruction.c
+++ compiler-rt/test/scudo/tsd_destruction.c
@@ -1,5 +1,6 @@
 // RUN: %clang_scudo %s -o %t
 // RUN: %run %t 2>&1
+// UNSUPPORTED: windows
 
 #include 
 #include 
Index: compiler-rt/test/scudo/threads.c
===
--- compiler-rt/test/scudo/threads.c
+++ compiler-rt/test/scudo/threads.c
@@ -1,6 +1,7 @@
 // RUN: %clang_scudo %s -o %t
 // RUN: %env_scudo_opts="QuarantineSizeKb=0:ThreadLocalQuarantineSizeKb=0" %run %t 5 100 2>&1
 // RUN: %env_scudo_opts="QuarantineSizeKb=1024:ThreadLocalQuarantineSizeKb=64" %run %t 5 100 2>&1
+// UNSUPPORTED: windows
 
 // Tests parallel allocations and deallocations of memory chunks from a number
 // of concurrent threads, with and without quarantine.
Index: compiler-rt/test/scudo/symbols.test

[PATCH] D95849: [FileCheck] Default --allow-unused-prefixes to false

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

In D95849#2536559 , @nikic wrote:

> Just to be clear here: Only the small handful where a spelling mistake was 
> fixed were actually bugs. All other unused check prefixes were there for 
> convenience, and are now casualties of this unnecessary crusade. I regret not 
> speaking out against this at the time.

Hi, I think the situation is the converse: most are code smell, only a small 
handful of tests leverage this property. So far the most convincing usage is 
something like (a) `--check-prefix=%something` where `%something` can expand to 
multiple prefixes and (b) a customized tool integrating FileCheck feature which 
expands to multiple prefixes, some prefixes may be omitted.

Issues include (a) misspelled prefixes (b) bitrot prefixes due to refactoring 
(c) omitted `-NOT` patterns (e.g. some tests use --check-prefixes=CHECK,CHECK-C 
for C specific UB and --check-prefixes=CHECK,CHECK-CPP. `CHECK-CPP` was absent 
but was intended to be a `CHECK-CPP-NOT:`)

I think the good uses of --allow-unused-prefixes=true are much fewer than the 
opposite.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95849

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


[PATCH] D95271: [CSSPGO] Passing the clang driver switch -fpseudo-probe-for-profiling to the linker.

2021-02-02 Thread Hongtao Yu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
hoy marked an inline comment as done.
Closed by commit rGd3e2e3740d07: [CSSPGO] Passing the clang driver switch 
-fpseudo-probe-for-profiling to the… (authored by hoy).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95271

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/pseudo-probe-lto.c


Index: clang/test/Driver/pseudo-probe-lto.c
===
--- /dev/null
+++ clang/test/Driver/pseudo-probe-lto.c
@@ -0,0 +1,10 @@
+// RUN: touch %t.o
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 
-fpseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=PROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto=thin 
-fpseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=PROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 
-fno-pseudo-probe-for-profiling -fpseudo-probe-for-profiling 2>&1 | FileCheck 
%s --check-prefix=PROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 2>&1 | FileCheck 
%s --check-prefix=NOPROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 
-fno-pseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=NOPROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 
-fpseudo-probe-for-profiling -fno-pseudo-probe-for-profiling 2>&1 | FileCheck 
%s --check-prefix=NOPROBE
+
+// PROBE: -plugin-opt=pseudo-probe-for-profiling
+// NOPROBE-NOT: -plugin-opt=pseudo-probe-for-profiling
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -605,6 +605,11 @@
   CmdArgs.push_back("-plugin-opt=new-pass-manager");
   }
 
+  // Pass an option to enable pseudo probe emission.
+  if (Args.hasFlag(options::OPT_fpseudo_probe_for_profiling,
+   options::OPT_fno_pseudo_probe_for_profiling, false))
+CmdArgs.push_back("-plugin-opt=pseudo-probe-for-profiling");
+
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
   if (!StatsFile.empty())
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1155,7 +1155,7 @@
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag, NegFlag,
-  BothFlags<[NoXarchOption, CC1Option], " pseudo probes for sample profiler">>;
+  BothFlags<[NoXarchOption, CC1Option], " pseudo probes for sample 
profiling">>;
 def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">,
 Group, Flags<[CC1Option, CoreOption]>,
 HelpText<"Generate instrumented code to collect order file into 
default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env 
var)">;


Index: clang/test/Driver/pseudo-probe-lto.c
===
--- /dev/null
+++ clang/test/Driver/pseudo-probe-lto.c
@@ -0,0 +1,10 @@
+// RUN: touch %t.o
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto -fpseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=PROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto=thin -fpseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=PROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto -fno-pseudo-probe-for-profiling -fpseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=PROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 2>&1 | FileCheck %s --check-prefix=NOPROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto -fno-pseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=NOPROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto -fpseudo-probe-for-profiling -fno-pseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=NOPROBE
+
+// PROBE: -plugin-opt=pseudo-probe-for-profiling
+// NOPROBE-NOT: -plugin-opt=pseudo-probe-for-profiling
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -605,6 +605,11 @@
   CmdArgs.push_back("-plugin-opt=new-pass-manager");
   }
 
+  // Pass an option to enable pseudo probe emission.
+  if (Args.hasFlag(options::OPT_fpseudo_probe_for_profiling,
+   options::OPT_fno_pseudo_probe_for_profiling, false))
+CmdArgs.push_back("-plugin-opt=pseudo-probe-for-profiling");
+
   // Setup statistics file output.
   SmallString<128> 

[clang] d3e2e37 - [CSSPGO] Passing the clang driver switch -fpseudo-probe-for-profiling to the linker.

2021-02-02 Thread Hongtao Yu via cfe-commits

Author: Hongtao Yu
Date: 2021-02-02T09:43:57-08:00
New Revision: d3e2e3740d0730cb6788c771bb01a8f3e935bf2e

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

LOG: [CSSPGO] Passing the clang driver switch -fpseudo-probe-for-profiling to 
the linker.

As titled.

Reviewed By: wmi, wenlei

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

Added: 
clang/test/Driver/pseudo-probe-lto.c

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index aee312ea8e8a..edaa42741062 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1155,7 +1155,7 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag, NegFlag,
-  BothFlags<[NoXarchOption, CC1Option], " pseudo probes for sample profiler">>;
+  BothFlags<[NoXarchOption, CC1Option], " pseudo probes for sample 
profiling">>;
 def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">,
 Group, Flags<[CC1Option, CoreOption]>,
 HelpText<"Generate instrumented code to collect order file into 
default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env 
var)">;

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6a95aa5ec628..bcaea71dca94 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -605,6 +605,11 @@ void tools::addLTOOptions(const ToolChain , 
const ArgList ,
   CmdArgs.push_back("-plugin-opt=new-pass-manager");
   }
 
+  // Pass an option to enable pseudo probe emission.
+  if (Args.hasFlag(options::OPT_fpseudo_probe_for_profiling,
+   options::OPT_fno_pseudo_probe_for_profiling, false))
+CmdArgs.push_back("-plugin-opt=pseudo-probe-for-profiling");
+
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
   if (!StatsFile.empty())

diff  --git a/clang/test/Driver/pseudo-probe-lto.c 
b/clang/test/Driver/pseudo-probe-lto.c
new file mode 100644
index ..e319b8c0098b
--- /dev/null
+++ b/clang/test/Driver/pseudo-probe-lto.c
@@ -0,0 +1,10 @@
+// RUN: touch %t.o
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 
-fpseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=PROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto=thin 
-fpseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=PROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 
-fno-pseudo-probe-for-profiling -fpseudo-probe-for-profiling 2>&1 | FileCheck 
%s --check-prefix=PROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 2>&1 | FileCheck 
%s --check-prefix=NOPROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 
-fno-pseudo-probe-for-profiling 2>&1 | FileCheck %s --check-prefix=NOPROBE
+// RUN: %clang -### %t.o -target x86_64-unknown-linux -flto 
-fpseudo-probe-for-profiling -fno-pseudo-probe-for-profiling 2>&1 | FileCheck 
%s --check-prefix=NOPROBE
+
+// PROBE: -plugin-opt=pseudo-probe-for-profiling
+// NOPROBE-NOT: -plugin-opt=pseudo-probe-for-profiling



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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-02-02 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

My concern is that this is treating a backend _bug_ as if it were just an 
optional feature. But it's not the case that it might be reasonable to either 
implement or not implement this in a backend -- it should be implemented, and 
those that don't are buggy.

I'd be happier with just having an ISEL failure when you try to use fp atomics 
on broken targets, rather than adding all this code and configuration to Clang 
in order to avoid that. (And, of course, the target maintainers should also fix 
them)


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

https://reviews.llvm.org/D71726

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


[PATCH] D95793: [clang][cli] Generate and round-trip language options

2021-02-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1196
 const std::vector ,
 DiagnosticsEngine , SanitizerSet ) {
+  bool Success = true;

dexonsmith wrote:
> Can the caller use `Diags.hasErrorOccurred()` to avoid this change?
Not really, because the caller might have `Diags` that already contains some 
errors. We could compare the number of errors in `Diags` before and after 
calling this function. `DiagnosticsEngine` doesn't have API for that, but that 
could be added without much issues.

Do you have any specific reason for avoiding this change beyond minimizing the 
diff?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95793

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


[PATCH] D95872: [clang][Arm] Fix handling of -Wa,-march=

2021-02-02 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Wow, thank you so much for the work that went into this patch! Very thorough 
tests.  Just minor questions about yet more test cases.  Patch LGTM.




Comment at: clang/test/Driver/arm-target-as-march-mcpu.s:42
+/// We use the target CPU for both.
+// RUN: %clang -target arm-linux-gnueabi -### -c -mcpu=cortex-a8 
-Wa,-march=armv8a %s 2>&1 | \
+// RUN: FileCheck -check-prefix=TRIPLE-ARMV8 --check-prefix=CPU-A8 %s

Below you have a comment `(cortex-a32 is armv8a)`.  That is very helpful for 
me.  I assume `cortex-a8` is armv7a?



Comment at: clang/test/Driver/arm-target-as-march-mcpu.s:43
+// RUN: %clang -target arm-linux-gnueabi -### -c -mcpu=cortex-a8 
-Wa,-march=armv8a %s 2>&1 | \
+// RUN: FileCheck -check-prefix=TRIPLE-ARMV8 --check-prefix=CPU-A8 %s
+// RUN: %clang -target arm-linux-gnueabi -### -c -mcpu=cortex-a8 
-Wa,-march=armv8-a \

I guess `-check-prefix` is accepted with one or two leading hyphens.  Let's 
pick one style to use consistently in this test.



Comment at: clang/test/Driver/arm-target-as-march-mcpu.s:82
+/// Last mcpu to compiler wins
+// RUN: %clang -target arm-linux-gnueabi -### -c -mcpu=cortex-a32 
-mcpu=cortex-a8 %s 2>&1 | \
+// RUN: FileCheck -check-prefix=TRIPLE-ARMV7 -check-prefix=CPU-A8 %s

add a `-mcpu=foo,bar` test for `-mcpu`? (Comma separated)



Comment at: clang/test/Driver/arm-target-as-march-mcpu.s:94
+/// Last march to compiler wins
+// RUN: %clang -target arm-linux-gnueabi -### -c -march=armv8-a -march=armv7-a 
%s 2>&1 | \
+// RUN: FileCheck -check-prefix=TRIPLE-ARMV7 %s

add a comma separated test? (`-march=armv8-a,armv7-a`)



Comment at: clang/test/Driver/arm-target-as-mthumb.s:9-17
+// RUN: %clang -target armv7a-linux-gnueabi -### -c 
-Wa,-mcpu=cortex-a8,-mthumb \
+// RUN: %S/Inputs/wildcard1.c 2>&1 | FileCheck -check-prefix=TRIPLE-ARM %s
 
 // TRIPLE-ARM: "-triple" "armv7-unknown-linux-gnueabi"
 
 // RUN: %clang -target armv7a-linux-gnueabi -### -c -Wa,-mthumb %s 2>&1 | \
 // RUN: FileCheck -check-prefix=TRIPLE-THUMB %s

Should we add space separated tests for these? `-Wa,-mcpu=cortex-a8 
-Wa,-mthumb`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95872

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


[PATCH] D93264: [CSSPGO] Introducing distribution factor for pseudo probe.

2021-02-02 Thread Hongtao Yu via Phabricator via cfe-commits
hoy updated this revision to Diff 320822.
hoy added a comment.

Rebasing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93264

Files:
  clang/test/CodeGen/pseudo-probe-emit.c
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/PseudoProbe.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/IR/PseudoProbe.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-update.prof
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-update.ll
  llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll

Index: llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/pseudo-probe-verify.ll
@@ -0,0 +1,77 @@
+; REQUIRES: x86_64-linux
+; RUN: opt < %s -passes='pseudo-probe,loop-unroll-full' -verify-pseudo-probe -S -o %t 2>&1 | FileCheck %s --check-prefix=VERIFY
+; RUN: FileCheck %s < %t
+
+; VERIFY: *** Pseudo Probe Verification After LoopFullUnrollPass ***
+; VERIFY: Function foo:
+; VERIFY: Probe 6	previous factor 1.00	current factor 5.00
+; VERIFY: Probe 4	previous factor 1.00	current factor 5.00
+
+declare void @foo2() nounwind
+
+define void @foo(i32 %x) {
+bb:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0, i64 -1)
+  %tmp = alloca [5 x i32*], align 16
+  br label %bb7.preheader
+
+bb3.loopexit:
+  %spec.select.lcssa = phi i32 [ %spec.select, %bb10 ]
+  %tmp5.not = icmp eq i32 %spec.select.lcssa, 0
+  br i1 %tmp5.not, label %bb24, label %bb7.preheader
+
+bb7.preheader:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 3, i32 0, i64 -1)
+  %tmp1.06 = phi i32 [ 5, %bb ], [ %spec.select.lcssa, %bb3.loopexit ]
+  br label %bb10
+
+bb10:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -1)
+; CHECK: call void @foo2(), !dbg ![[#PROBE6:]] 
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 2, i32 0, i64 -1)
+  %indvars.iv = phi i64 [ 0, %bb7.preheader ], [ %indvars.iv.next, %bb10 ]
+  %tmp1.14 = phi i32 [ %tmp1.06, %bb7.preheader ], [ %spec.select, %bb10 ]
+  %tmp13 = getelementptr inbounds [5 x i32*], [5 x i32*]* %tmp, i64 0, i64 %indvars.iv
+  %tmp14 = load i32*, i32** %tmp13, align 8
+  %tmp15.not = icmp ne i32* %tmp14, null
+  %tmp18 = sext i1 %tmp15.not to i32
+  %spec.select = add nsw i32 %tmp1.14, %tmp18
+  call void @foo2(), !dbg !12
+  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+  %exitcond.not = icmp eq i64 %indvars.iv.next, 5
+  br i1 %exitcond.not, label %bb3.loopexit, label %bb10, !llvm.loop !13
+
+bb24:
+; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 5, i32 0, i64 -1)
+  ret void
+}
+
+;; A discriminator of 186646583 which is 0xb200037 in hexdecimal, stands for a direct call probe
+;; with an index of 6 and a scale of -1%.
+; CHECK: ![[#PROBE6]] = !DILocation(line: 2, column: 20, scope: ![[#SCOPE:]])
+; CHECK: ![[#SCOPE]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 186646583)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!9, !10}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2)
+!1 = !DIFile(filename: "test.c", directory: "")
+!2 = !{}
+!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, retainedNodes: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7}
+!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!9 = !{i32 2, !"Dwarf Version", i32 4}
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+!11 = !{!"clang version 3.9.0"}
+!12 = !DILocation(line: 2, column: 20, scope: !4)
+!13 = distinct !{!13, !14}
+!14 = !{!"llvm.loop.unroll.full"}
Index: 

[PATCH] D95879: [clang][index] Mark file as C++ in parse-all-comments test

2021-02-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: dexonsmith, Bigcheese.
Herald added a subscriber: arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`CompilerInvocation::CreateFromArgs` doesn't always report command line parsing 
failures through the return value. Sometimes, errors are only reported via 
diagnostics.

Some clients like `c-index-test` only check the return value and don't check 
the state of `DiagnosticsEngine`.

If we were to start returning the correct return value from `CreateFromArgs`, 
this index test starts to fail, because it specifies `-std=c++11` for a C 
input, which is invalid.

This patch fixes that issue by adding forgotten `-x c++` argument.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95879

Files:
  clang/test/Index/parse-all-comments.c


Index: clang/test/Index/parse-all-comments.c
===
--- clang/test/Index/parse-all-comments.c
+++ clang/test/Index/parse-all-comments.c
@@ -75,7 +75,7 @@
 
 // RUN: c-index-test -write-pch %t/out.pch -fparse-all-comments -x c++ 
-std=c++11 %s
 
-// RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s -std=c++11 
-fparse-all-comments > %t/out.c-index-direct
+// RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -x c++ 
-std=c++11 %s -fparse-all-comments > %t/out.c-index-direct
 // RUN: c-index-test -test-load-tu %t/out.pch all > %t/out.c-index-pch
 
 // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-direct


Index: clang/test/Index/parse-all-comments.c
===
--- clang/test/Index/parse-all-comments.c
+++ clang/test/Index/parse-all-comments.c
@@ -75,7 +75,7 @@
 
 // RUN: c-index-test -write-pch %t/out.pch -fparse-all-comments -x c++ -std=c++11 %s
 
-// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s -std=c++11 -fparse-all-comments > %t/out.c-index-direct
+// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -x c++ -std=c++11 %s -fparse-all-comments > %t/out.c-index-direct
 // RUN: c-index-test -test-load-tu %t/out.pch all > %t/out.c-index-pch
 
 // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-direct
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94661: [clang-format] [PR19056] Add support for access modifiers indentation

2021-02-02 Thread Jakub Budiský via Phabricator via cfe-commits
Budovi updated this revision to Diff 320818.
Budovi added a comment.

Updated the tests after checking the issues were not caused by the patch and 
they are reported / fixed.

Rebased the changes to the newest version.


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

https://reviews.llvm.org/D94661

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15453,6 +15453,7 @@
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
   CHECK_PARSE_BOOL(DisableFormat);
+  CHECK_PARSE_BOOL(IndentAccessModifiers);
   CHECK_PARSE_BOOL(IndentCaseLabels);
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
@@ -19050,6 +19051,52 @@
 "}",
 format(Source, Style));
 }
+
+TEST_F(FormatTest, IndentAccessModifiers) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortEnumsOnASingleLine = false;
+  Style.IndentAccessModifiers = true;
+  verifyFormat("class C {\n"
+   "int i;\n"
+   "};\n",
+   Style);
+  verifyFormat("class C {\n"
+   "  public:\n"
+   "int i;\n"
+   "};\n",
+   Style);
+  verifyFormat("struct S {\n"
+   "  private:\n"
+   "class C {\n"
+   "int j;\n"
+   "\n"
+   "  public:\n"
+   "C();\n"
+   "};\n"
+   "\n"
+   "  public:\n"
+   "int i;\n"
+   "};\n",
+   Style);
+  verifyFormat("union C {\n"
+   "int i;\n"
+   "unsigned u;\n"
+   "};\n",
+   Style);
+  verifyFormat("enum class E\n"
+   "{\n"
+   "  A,\n"
+   "  B\n"
+   "};\n",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  class C {\n"
+   "  int i;\n"
+   "  };\n"
+   "  return;\n"
+   "}\n",
+   Style);
+}
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -85,7 +85,7 @@
   void reset();
   void parseFile();
   void parseLevel(bool HasOpeningBrace);
-  void parseBlock(bool MustBeDeclaration, bool AddLevel = true,
+  void parseBlock(bool MustBeDeclaration, unsigned AddLevels = 1u,
   bool MunchSemi = true);
   void parseChildBlock();
   void parsePPDirective();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -579,7 +579,7 @@
   return h;
 }
 
-void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
+void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, unsigned AddLevels,
  bool MunchSemi) {
   assert(FormatTok->isOneOf(tok::l_brace, TT_MacroBlockBegin) &&
  "'{' or macro block token expected");
@@ -589,7 +589,7 @@
   size_t PPStartHash = computePPHash();
 
   unsigned InitialLevel = Line->Level;
-  nextToken(/*LevelDifference=*/AddLevel ? 1 : 0);
+  nextToken(/*LevelDifference=*/AddLevels);
 
   if (MacroBlock && FormatTok->is(tok::l_paren))
 parseParens();
@@ -604,8 +604,7 @@
 
   ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
   MustBeDeclaration);
-  if (AddLevel)
-++Line->Level;
+  Line->Level += AddLevels;
   parseLevel(/*HasOpeningBrace=*/true);
 
   if (eof())
@@ -621,7 +620,7 @@
   size_t PPEndHash = computePPHash();
 
   // Munch the closing brace.
-  nextToken(/*LevelDifference=*/AddLevel ? -1 : 0);
+  nextToken(/*LevelDifference=*/-AddLevels);
 
   if (MacroBlock && FormatTok->is(tok::l_paren))
 parseParens();
@@ -1125,12 +1124,12 @@
   if (Style.BraceWrapping.AfterExternBlock) {
 addUnwrappedLine();
   }
-  parseBlock(/*MustBeDeclaration=*/true,
- /*AddLevel=*/Style.BraceWrapping.AfterExternBlock);
+  unsigned AddLevels = Style.BraceWrapping.AfterExternBlock ? 1u : 0u;
+  parseBlock(/*MustBeDeclaration=*/true, AddLevels);
 } else {
-  parseBlock(/*MustBeDeclaration=*/true,
- 

[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

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

If the concern is that diagnose fp atomics as unsupported hinders middle end 
and backend work for fixing fp atomic issues, how about adding a 
-fenable-fp-atomics to clang which can override target info about fp atomics 
support.


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

https://reviews.llvm.org/D71726

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


[PATCH] D95271: [CSSPGO] Passing the clang driver switch -fpseudo-probe-for-profiling to the linker.

2021-02-02 Thread Wei Mi via Phabricator via cfe-commits
wmi accepted this revision.
wmi added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95271

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


[PATCH] D95778: [OpenCL] Introduce new language options for OpenCL keywords.

2021-02-02 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D95778#2536598 , @azabaznov wrote:

> In D95778#2536266 , @Anastasia wrote:
>
>>> LGTM, but perhaps you can add a test that has each keyword disabled?
>>
>> FYI we currently already test that `pipe` and `generic` are valid for OpenCL 
>> 2.0 and invalid for OpenCL < 2.0. Or do you mean different kind of tests? In 
>> OpenCL 3.0 we will have to set the new `LangOpts` fields based on the values 
>> of `OpenCLOptions`  but my guess is that is going to be added in the 
>> subsequent patches...
>
> Yes, I believe there are tests already for earlier versions. Should I mark 
> this change as NFC?

I am not sure since we are adding a new `LangOpts` entries it's not entirely 
NFC. I would just live as is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95778

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


[PATCH] D94661: [clang-format] [PR19056] Add support for access modifiers indentation

2021-02-02 Thread Jakub Budiský via Phabricator via cfe-commits
Budovi planned changes to this revision.
Budovi added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:17868
+  FormatStyle Style = getLLVMStyle();
+  Style.AccessModifierOffset = 4;
+  Style.AllowShortEnumsOnASingleLine = false;

Budovi wrote:
> curdeius wrote:
> > Why are those non-related style options here?
> `AccessModifierOffset` tests whether it has an influence, even thought now 
> realizing that the default value (-2) is non-zero and is probably good enough 
> as arbitrary 4. So I actually want a non-zero value for it, and this was not 
> obvious at first.
> 
> `AllowShortEnumsOnASingleLine` is needed unless I want to make the enum more 
> complex.
> 
> `BreakBeforeBraces` along with `BraceWrapping` deals with the chosen enum 
> test below, which had surprising defaults for me in the LLVMStyle. I've added 
> them as a preliminary way of "resolving" the issue with the unit test but it 
> still fails. I agree that the unit test should not try to cover the other 
> features and I will remove them and fix the test as soon as I get into it and 
> confirm that the failing test is not a bug introduced with this change and 
> open up a bug report for it.
Confirmed that the bug is present without this patch.
Related bug report: https://bugs.llvm.org/show_bug.cgi?id=46927



Comment at: clang/unittests/Format/FormatTest.cpp:17874
+  verifyFormat("class C {\n"
+   "int i;\n"
+   "};\n",

MyDeveloperDay wrote:
> So this is indented 4 because the Access modifier is 4? when the IndentWidth 
> is 2? 
> 
> but public below is indented 2.. so now I'm really confused?
The indentation is 2 levels below the class since the single level is reserved 
for access modifiers.

Access modifier does not influence the behaviour at all. The value was chosen 
arbitrarily, see my previous comment. Will reflect this in an updated patch.



Comment at: clang/unittests/Format/FormatTest.cpp:17882-17908
+  {
+const char *Expected = "struct S {\n"
+   "  private:\n"
+   "class C {\n"
+   "int j;\n"
+   "\n"
+   "  public:\n"

MyDeveloperDay wrote:
> Budovi wrote:
> > When you re-create this test using `verifyFormat`, you get a weird results, 
> > i.e. if you keep the newlines before access modifiers, the test fails 
> > because it thinks they should not be there, but if you remove them, test 
> > fails again, because the formatter includes them instead.
> > 
> > It's a good question whether it is a side-effect of `test::messUp` or a 
> > different bug, I'm not sure.
> As a drive by comment, its my experience when verifyFormat fails its often a 
> sign that there is a bug which means clang-format cannot always format from 
> arbitrary text, which really it should.
> 
> Ultimately this bug will get logged by someone who doesn't understand your 
> change as well as you do. That fix will also subtly end up creating a 
> different bug in another corner case you you haven't covered in your original 
> tests
> 
> We spiral down from there...my 2c worth.
This issue was caused by an inconsistency with access modifiers and unrelated 
to this patch. After the `test::messUp` all the newlines are stripped from the 
code, and clang-format behaved differently in a case there was no newline 
before access modifier (inserted a single one) and all the other cases (it 
inserted an additional empty line before the modifier).

The issue was fixed along with a new feature introduced 
https://reviews.llvm.org/D93846 and thus does not need reporting. The new patch 
will revert back to using `verifyFormat`.



Comment at: clang/unittests/Format/FormatTest.cpp:17914-17918
+  verifyFormat("enum class E {\n"
+   "  A,\n"
+   "  B\n"
+   "};\n",
+   Style);

Budovi wrote:
> This unit test currently fails, I believe it is a non-related bug in the 
> formatter. Nevertheless I wanted to add a check that enums (non-records) are 
> preserved.
As mentioned above, this is the bug https://bugs.llvm.org/show_bug.cgi?id=46927.
The unrelated style options will be removed in the future patch and the 
"default LLVM behaviour" tested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94661

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


  1   2   3   >