[clang] 68050c2 - Revert "[CMake][Fuchsia] Use libunwind as the default unwinder"

2022-07-01 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-07-02T04:51:16Z
New Revision: 68050c235432eeb5cfe9b58609cecc3efd13f567

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

LOG: Revert "[CMake][Fuchsia] Use libunwind as the default unwinder"

This reverts commit 6213dba19fc0d65ab8b366b6d78c56cbd63c9d7d since
this broke Fuchsia builders.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 3c6cfdaa1c1cc..4e3ed6086dec5 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,7 +32,6 @@ set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
-set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
@@ -120,6 +119,7 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
@@ -130,6 +130,9 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX "libc++" CACHE STRING "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_TEST_COMPILER_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
+set(RUNTIMES_${target}_SANITIZER_COMMON_TEST_TARGET_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
+set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind 
-static-libgcc" CACHE STRING "")
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
@@ -180,10 +183,13 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
+set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
+
set(RUNTIMES_${target}_LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")

diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index 83232b776ad9e..7b534e61f9520 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -26,7 +26,6 @@ set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
-set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")



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


[clang] 40d2ef8 - [clang-format][NFC] Replace an EXPECT_EQ with a verifyFormat

2022-07-01 Thread via cfe-commits

Author: owenca
Date: 2022-07-01T21:20:54-07:00
New Revision: 40d2ef841b68f6b493ce88bd750a92105a2b567d

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

LOG: [clang-format][NFC] Replace an EXPECT_EQ with a verifyFormat

Added: 


Modified: 
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index d6deafe1093c..c4066253fd1a 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7129,13 +7129,10 @@ TEST_F(FormatTest, 
BreakConstructorInitializersAfterColon) {
"(b) {}",
OnePerLine);
 
-  EXPECT_EQ("Constructor() :\n"
-"// Comment forcing unwanted break.\n"
-"() {}",
-format("Constructor() :\n"
-   "// Comment forcing unwanted break.\n"
-   "() {}",
-   Style));
+  verifyFormat("Constructor() :\n"
+   "// Comment forcing unwanted break.\n"
+   "() {}",
+   Style);
 
   Style.ColumnLimit = 0;
   verifyFormat("SomeClass::Constructor() :\n"



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


[PATCH] D129033: [Clang] Use metadata to make identifying embedded objects easier

2022-07-01 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, ABataev, MaskRay, 
tianshilei1992.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Currently we use the `embedBufferInModule` function to store binary
strings containing device offloading data inside the host object to
create a fatbinary. In the case of LTO, we need to extract this object
from the LLVM-IR. This patch adds a metadata node for the embedded
objects containing the embedded pointers and the sections they were
stored at. This should create a cleaner interface for identifying these
values.

In the future it may be worthwhile to also encode an `ID` in the
metadata corresponding to the object's special section type if relevant.
This would allow us to extract the data from an object file and LLVM-IR
using the same ID.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129033

Files:
  clang/test/Frontend/embed-object.c
  clang/test/Frontend/embed-object.ll
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  llvm/include/llvm/Transforms/Utils/ModuleUtils.h
  llvm/lib/Transforms/Utils/ModuleUtils.cpp


Index: llvm/lib/Transforms/Utils/ModuleUtils.cpp
===
--- llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -275,5 +275,12 @@
   GV->setSection(SectionName);
   GV->setAlignment(Alignment);
 
+  LLVMContext  = M.getContext();
+  NamedMDNode *MD = M.getOrInsertNamedMetadata("llvm.embedded.object");
+  Metadata *MDVals[] = {ConstantAsMetadata::get(GV),
+MDString::get(Ctx, SectionName)};
+
+  MD->addOperand(llvm::MDNode::get(Ctx, MDVals));
+
   appendToCompilerUsed(M, GV);
 }
Index: llvm/include/llvm/Transforms/Utils/ModuleUtils.h
===
--- llvm/include/llvm/Transforms/Utils/ModuleUtils.h
+++ llvm/include/llvm/Transforms/Utils/ModuleUtils.h
@@ -109,7 +109,8 @@
 std::string getUniqueModuleId(Module *M);
 
 /// Embed the memory buffer \p Buf into the module \p M as a global using the
-/// specified section name.
+/// specified section name. Also provide metadata entry to identify it in the
+/// module using the same section name.
 void embedBufferInModule(Module , MemoryBufferRef Buf, StringRef SectionName,
  Align Alignment = Align(1));
 
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -366,12 +366,23 @@
 return createStringError(inconvertibleErrorCode(),
  "Failed to create module");
 
-  // Extract offloading data from globals with the `.llvm.offloading` section.
-  for (GlobalVariable  : M->globals()) {
-if (!GV.hasSection() || !GV.getSection().equals(OFFLOAD_SECTION_MAGIC_STR))
+  // Extract offloading data from globals referenced by the
+  // `llvm.embedded.object` metadata with the `.llvm.offloading` section.
+  auto MD = M->getNamedMetadata("llvm.embedded.object");
+  for (const MDNode *Op : MD->operands()) {
+if (Op->getNumOperands() < 2)
   continue;
 
-auto *CDS = dyn_cast(GV.getInitializer());
+MDString *SectionID = dyn_cast(Op->getOperand(1));
+if (!SectionID || SectionID->getString() != OFFLOAD_SECTION_MAGIC_STR)
+  continue;
+
+GlobalVariable *GV =
+mdconst::dyn_extract_or_null(Op->getOperand(0));
+if (!GV)
+  continue;
+
+auto *CDS = dyn_cast(GV->getInitializer());
 if (!CDS)
   continue;
 
Index: clang/test/Frontend/embed-object.ll
===
--- clang/test/Frontend/embed-object.ll
+++ clang/test/Frontend/embed-object.ll
@@ -13,3 +13,7 @@
 define i32 @foo() {
   ret i32 0
 }
+
+; CHECK: !llvm.embedded.object = !{![[METADATA_1:[0-9]+]], 
![[METADATA_2:[0-9]+]]}
+; CHECK: ![[METADATA_1]] = !{ptr @[[OBJECT_1]], !".llvm.offloading"}
+; CHECK: ![[METADATA_2]] = !{ptr @[[OBJECT_2]], !".llvm.offloading"}
Index: clang/test/Frontend/embed-object.c
===
--- clang/test/Frontend/embed-object.c
+++ clang/test/Frontend/embed-object.c
@@ -4,3 +4,6 @@
 // CHECK: @llvm.compiler.used = appending global [1 x ptr] [ptr @[[OBJECT]]], 
section "llvm.metadata"
 
 void foo(void) {}
+
+// CHECK: !llvm.embedded.object = !{![[METADATA:[0-9]+]]}
+// CHECK: ![[METADATA]] = !{ptr @[[OBJECT]], !".llvm.offloading"}


Index: llvm/lib/Transforms/Utils/ModuleUtils.cpp
===
--- llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -275,5 

[PATCH] D128686: [OpenMP][NFC] Reuse check lines for Clang/OpenMP tests

2022-07-01 Thread Johannes Doerfert 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 rGb52d33e6de55: [OpenMP][NFC] Reuse check lines for 
Clang/OpenMP tests (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128686

Files:
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/ordered_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_aligned_codegen.cpp
  clang/test/OpenMP/parallel_if_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_private_codegen.cpp
  clang/test/OpenMP/parallel_reduction_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/sections_private_codegen.cpp
  clang/test/OpenMP/sections_reduction_codegen.cpp
  clang/test/OpenMP/sections_reduction_task_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/single_private_codegen.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  

[PATCH] D129014: rewording static_assert to more generic static assertion

2022-07-01 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Running check-clang after applying the patch, results into 36 failed test 
cases. Please update them all. 
Also add a description of patch motivation(via the Edit Revision option on the 
top) for why you are making the changes (like any wrong behavior you are seeing 
etc).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129014

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


[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441850.
SchrodingerZhu added a comment.

- adjust comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/test/LTO/Resolution/X86/alias-indirect-function-lto.ll


Index: llvm/test/LTO/Resolution/X86/alias-indirect-function-lto.ll
===
--- /dev/null
+++ llvm/test/LTO/Resolution/X86/alias-indirect-function-lto.ll
@@ -0,0 +1,16 @@
+; RUN: opt -module-summary -o %t.bc %s
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = ifunc i32 (i32), i32 (i32)* ()* @foo_resolver
+
+define internal i32 (i32)* @foo_resolver() {
+entry:
+  ret i32 (i32)* null
+}
+
+@bar = alias i32 (i32), i32 (i32)* @foo
+
+@baz = weak alias i32 (i32), i32 (i32)* @foo
+; no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+// IFunc function and Nameless function don't have an entry in the
+// summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,20 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+
+  // Skip summary for indirect function aliases as summary for aliasee will not
+  // be emitted.
+  if (isa(Aliasee))
+return;
+
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&


Index: llvm/test/LTO/Resolution/X86/alias-indirect-function-lto.ll
===
--- /dev/null
+++ llvm/test/LTO/Resolution/X86/alias-indirect-function-lto.ll
@@ -0,0 +1,16 @@
+; RUN: opt -module-summary -o %t.bc %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = ifunc i32 (i32), i32 (i32)* ()* @foo_resolver
+
+define internal i32 (i32)* @foo_resolver() {
+entry:
+  ret i32 (i32)* null
+}
+
+@bar = alias i32 (i32), i32 (i32)* @foo
+
+@baz = weak alias i32 (i32), i32 (i32)* @foo
+; no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+// IFunc function and Nameless function don't have an entry in the
+// summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,20 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+
+  // Skip summary for indirect function aliases as summary for aliasee will not
+  // be emitted.
+  if (isa(Aliasee))
+return;
+
   bool NonRenamableLocal = 

[PATCH] D123450: [clang-format] Parse Verilog if statements

2022-07-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

`clang/docs/ClangFormatStyleOptions.rst` was out of sync because 
`dump_format_style.py` had not been run. Fixed in cc55d97 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123450

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


[clang] cc55d97 - [clang-format] Run dump_format_style.py for LK_Verilog

2022-07-01 Thread via cfe-commits

Author: owenca
Date: 2022-07-01T19:01:09-07:00
New Revision: cc55d97cebf22994663c514d0b909df63bfbac43

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

LOG: [clang-format] Run dump_format_style.py for LK_Verilog

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 90fef542205ad..a65382729da4a 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3196,6 +3196,11 @@ the configuration (without a prefix: ``Auto``).
 Should be used for Protocol Buffer messages in text format
 (https://developers.google.com/protocol-buffers/).
 
+  * ``LK_Verilog`` (in configuration: ``Verilog``)
+Should be used for Verilog and SystemVerilog.
+https://standards.ieee.org/ieee/1800/6700/
+https://sci-hub.st/10.1109/IEEESTD.2018.8299595
+
 
 
 **MacroBlockBegin** (``String``) :versionbadge:`clang-format 3.7`



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


[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441849.
SchrodingerZhu added a comment.

- move to proper place


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/test/LTO/Resolution/X86/alias-indirect-function-lto.ll


Index: llvm/test/LTO/Resolution/X86/alias-indirect-function-lto.ll
===
--- /dev/null
+++ llvm/test/LTO/Resolution/X86/alias-indirect-function-lto.ll
@@ -0,0 +1,16 @@
+; RUN: opt -module-summary -o %t.bc %s
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = ifunc i32 (i32), i32 (i32)* ()* @foo_resolver
+
+define internal i32 (i32)* @foo_resolver() {
+entry:
+  ret i32 (i32)* null
+}
+
+@bar = alias i32 (i32), i32 (i32)* @foo
+
+@baz = weak alias i32 (i32), i32 (i32)* @foo
+; no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,20 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+
+  if (isa(Aliasee))
+// Skip summary for indirect function aliases as
+// summary for aliasee will not be emitted.
+return;
+
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&


Index: llvm/test/LTO/Resolution/X86/alias-indirect-function-lto.ll
===
--- /dev/null
+++ llvm/test/LTO/Resolution/X86/alias-indirect-function-lto.ll
@@ -0,0 +1,16 @@
+; RUN: opt -module-summary -o %t.bc %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = ifunc i32 (i32), i32 (i32)* ()* @foo_resolver
+
+define internal i32 (i32)* @foo_resolver() {
+entry:
+  ret i32 (i32)* null
+}
+
+@bar = alias i32 (i32), i32 (i32)* @foo
+
+@baz = weak alias i32 (i32), i32 (i32)* @foo
+; no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,20 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+
+  if (isa(Aliasee))
+// Skip summary for indirect function aliases as
+// summary for aliasee will not be emitted.
+return;
+
   bool 

[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441848.
SchrodingerZhu added a comment.

- address cr: use IR instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/test/LTO/alias-indirect-function-lto.ll


Index: llvm/test/LTO/alias-indirect-function-lto.ll
===
--- /dev/null
+++ llvm/test/LTO/alias-indirect-function-lto.ll
@@ -0,0 +1,16 @@
+; RUN: opt -module-summary -o %t.bc %s
+
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = ifunc i32 (i32), i32 (i32)* ()* @foo_resolver
+
+define internal i32 (i32)* @foo_resolver() {
+entry:
+  ret i32 (i32)* null
+}
+
+@bar = alias i32 (i32), i32 (i32)* @foo
+
+@baz = weak alias i32 (i32), i32 (i32)* @foo
+; no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,20 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+
+  if (isa(Aliasee))
+// Skip summary for indirect function aliases as
+// summary for aliasee will not be emitted.
+return;
+
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&


Index: llvm/test/LTO/alias-indirect-function-lto.ll
===
--- /dev/null
+++ llvm/test/LTO/alias-indirect-function-lto.ll
@@ -0,0 +1,16 @@
+; RUN: opt -module-summary -o %t.bc %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = ifunc i32 (i32), i32 (i32)* ()* @foo_resolver
+
+define internal i32 (i32)* @foo_resolver() {
+entry:
+  ret i32 (i32)* null
+}
+
+@bar = alias i32 (i32), i32 (i32)* @foo
+
+@baz = weak alias i32 (i32), i32 (i32)* @foo
+; no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,20 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+
+  if (isa(Aliasee))
+// Skip summary for indirect function aliases as
+// summary for aliasee will not be emitted.
+return;
+
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
  

[PATCH] D126694: [C++20][Modules] Implementation of GMF decl elision.

2022-07-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:2275-2276
 
+  llvm::SmallPtrSet SeenDecls;
+  llvm::SmallPtrSet SeenTypes;
+

These names seem too general to live directly in `Sema`.



Comment at: clang/include/clang/Sema/Sema.h:2278
+
+  /// Examine a type, unwrapping ay decls that might be in the GMF.
+  void findGMFReachableDeclsForType(const Type *T);





Comment at: clang/lib/Sema/SemaModule.cpp:916-920
+markGMFDeclsReachableFrom(Target, /*MakeVisible*/ true);
+  }
+} else {
+  markGMFDeclsReachableFrom(Child, /*MakeVisible*/ true);
+}

Do we need the special `MakeVisible` handling here? I would have thought that 
it would be sufficient for `Child` itself to be visible. Making the target of a 
using declaration visible seems like it would do the wrong thing for a case 
like:

```
module;
int f();
export module M;
namespace N { export using ::f; }
```

```
import M;
int a = f(); // should be an error, ::f should not be visible
int b = N::f(); // should be OK, UsingShadowDecl is visible
```

I wonder if we need any special handling here at all -- if the GMF decls are 
referenced by something in an `export` block, then I'd have expected they'll 
already be marked as used and that marking would have marked them as reachable.



Comment at: clang/lib/Sema/SemaModule.cpp:1024-1036
+  // Only visit each Decl once.
+  if (!SeenDecls.insert(Orig).second)
+return;
+
+  // Do not alter the ownership unless it is ModuleDiscardable.
+  if (Orig->isModuleDiscardable()) {
+assert(Orig->getOwningModule() &&

Instead of storing a `SeenDecls` set and checking it here, is it feasible to 
check whether we're transitioning this declaration from discardable to 
retained, and only doing the work below if so?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126694

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


[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441846.
SchrodingerZhu added a comment.

- address cr: code brace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/test/LTO/alias-indirect-function-lto.c


Index: llvm/test/LTO/alias-indirect-function-lto.c
===
--- /dev/null
+++ llvm/test/LTO/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: clang -flto %s -c -o %t1 -target x86_64-unknown-linux-gnu
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,20 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+
+  if (isa(Aliasee))
+// Skip summary for indirect function aliases as
+// summary for aliasee will not be emitted.
+return;
+
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&


Index: llvm/test/LTO/alias-indirect-function-lto.c
===
--- /dev/null
+++ llvm/test/LTO/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: clang -flto %s -c -o %t1 -target x86_64-unknown-linux-gnu
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,20 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+
+  if (isa(Aliasee))
+// Skip summary for indirect function aliases as
+// summary for aliasee will not be emitted.
+return;
+
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&
___
cfe-commits mailing 

[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added inline comments.
This revision now requires changes to proceed.



Comment at: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp:655
+  if (isa(Aliasee)) {
+return;
+  }

https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements



Comment at: llvm/test/LTO/alias-indirect-function-lto.c:1
+// RUN: clang -flto %s -c -o %t1
+void f() __attribute__((ifunc("g")));

llvm/test/ tests cannot use clang. You need to use tools like llvm-lto2. See 
existing tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

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


[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441844.
SchrodingerZhu added a comment.

- specify target


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/test/LTO/alias-indirect-function-lto.c


Index: llvm/test/LTO/alias-indirect-function-lto.c
===
--- /dev/null
+++ llvm/test/LTO/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: clang -flto %s -c -o %t1 -target x86_64-unknown-linux-gnu
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,19 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+  // Skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (isa(Aliasee)) {
+return;
+  }
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&


Index: llvm/test/LTO/alias-indirect-function-lto.c
===
--- /dev/null
+++ llvm/test/LTO/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: clang -flto %s -c -o %t1 -target x86_64-unknown-linux-gnu
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,19 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+  // Skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (isa(Aliasee)) {
+return;
+  }
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&
___
cfe-commits mailing list

[PATCH] D128314: [Clang-tidy] Fixing a bug in clang-tidy infinite-loop checker

2022-07-01 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment.

In D128314#3605588 , @NoQ wrote:

> Nice!
>
> There's usually some bureaucracy when creating new matchers, i.e. there 
> should be documentation and unittests covering them.

I have added a unit test and auto-generated document for it.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:5099
+/// matches a FunctionType if the type includes the GNU no return attribute
+AST_MATCHER(FunctionType, typeHasNoReturnAttr) {
+  return Node.getNoReturnAttr();

NoQ wrote:
> Can we make a polymorphic matcher `hasNoReturnAttr` that can accept either 
> decl or type?
I've moved these two matchers, which seems are specific to the infinite loop 
checker, to `InfiniteLoopCheck.cpp`.  Maybe they no longer need to be 
generalized by polymorphism. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128314

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


[PATCH] D128314: [Clang-tidy] Fixing a bug in clang-tidy infinite-loop checker

2022-07-01 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 441832.
ziqingluo-90 added a comment.

adding a unit test for the ASTMatcher `objcMessageCallee` added in ASTMatcher.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128314

Files:
  clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/infinite-loop-noreturn.mm
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -2352,6 +2352,37 @@
argumentCountIs(0;
 }
 
+TEST(ASTMatchersTestObjC, ObjCMessageCallee) {
+  //  Will NOT match function callee:
+  EXPECT_TRUE(notMatchesObjC("void f() {"
+ "  f(); "
+ "}",
+ objcMessageExpr(objcMessageCallee(hasName("f");
+
+  StringRef Objc1String = "@interface I "
+  " - (void)instanceMethod;"
+  " + (void)classMethod;"
+  " + (void)uncalledMethod;"
+  "@end\n"
+  "int main(void) {\n"
+  "  [I classMethod];"
+  "  I *i = [[I alloc] init];"
+  "  [i instanceMethod];"
+  "}";
+  // Should find the two method declarations through the message expressions:
+  EXPECT_TRUE(
+  matchesObjC(Objc1String, objcMessageExpr(objcMessageCallee(
+   objcMethodDecl(hasName("classMethod"));
+  EXPECT_TRUE(matchesObjC(Objc1String,
+  objcMessageExpr(objcMessageCallee(
+  objcMethodDecl(hasName("instanceMethod"));
+  // Will NOT match a method declaration through `objcMessageCallee` if there is
+  // no such message expression:
+  EXPECT_FALSE(matchesObjC(Objc1String,
+   objcMessageExpr(objcMessageCallee(
+   objcMethodDecl(hasName("uncalledMethod"));
+}
+
 TEST(ASTMatchersTestObjC, ObjCStringLiteral) {
 
   StringRef Objc1String = "@interface NSObject "
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -501,6 +501,7 @@
   REGISTER_MATCHER(objcIvarDecl);
   REGISTER_MATCHER(objcIvarRefExpr);
   REGISTER_MATCHER(objcMessageExpr);
+  REGISTER_MATCHER(objcMessageCallee);
   REGISTER_MATCHER(objcMethodDecl);
   REGISTER_MATCHER(objcObjectPointerType);
   REGISTER_MATCHER(objcPropertyDecl);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3838,6 +3838,25 @@
   InnerMatcher.matches(*ExprNode, Finder, Builder));
 }
 
+/// matches if ObjCMessageExpr's callee declaration matches
+///
+/// Given
+/// \code
+///   @interface I: NSObject
+///   +(void)foo;
+///   @end
+///   ...
+///   [I foo]
+/// \endcode
+/// The example above matches \code [I foo] \endcode with
+/// objcMessageExpr(objcMessageCallee(objcMethodDecl(hasName("foo"
+AST_MATCHER_P(ObjCMessageExpr, objcMessageCallee,
+  internal::Matcher, InnerMatcher) {
+  const ObjCMethodDecl *msgDecl = Node.getMethodDecl();
+  return (msgDecl != nullptr &&
+  InnerMatcher.matches(*msgDecl, Finder, Builder));
+}
+
 /// Matches if the call expression's callee's declaration matches the
 /// given matcher.
 ///
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -8867,6 +8867,20 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprobjcMessageCalleeMatcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDecl InnerMatcher
+matches if ObjCMessageExpr's callee declaration matches
+
+Given
+  @interface I: NSObject
+  +(void)foo;
+  @end
+  ...
+  [I foo]
+The example above matches [I foo] with
+objcMessageExpr(objcMessageCallee(objcMethodDecl(hasName("foo"
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclhasAnyParameterMatcherhttps://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDecl InnerMatcher
 Matches any parameter of a function or an ObjC method 

[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu added a comment.

Sorry for the noise during the process. I am really new to LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

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


[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441830.
SchrodingerZhu added a comment.

- adjust run arg


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/test/LTO/alias-indirect-function-lto.c


Index: llvm/test/LTO/alias-indirect-function-lto.c
===
--- /dev/null
+++ llvm/test/LTO/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: clang -flto %s -c -o %t1
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,19 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+  // Skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (isa(Aliasee)) {
+return;
+  }
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&


Index: llvm/test/LTO/alias-indirect-function-lto.c
===
--- /dev/null
+++ llvm/test/LTO/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: clang -flto %s -c -o %t1
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,19 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+  // Skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (isa(Aliasee)) {
+return;
+  }
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441829.
SchrodingerZhu added a comment.

address CR


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/test/LTO/alias-indirect-function-lto.c


Index: llvm/test/LTO/alias-indirect-function-lto.c
===
--- /dev/null
+++ llvm/test/LTO/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: clang -flto %s
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,19 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+  // Skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (isa(Aliasee)) {
+return;
+  }
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&


Index: llvm/test/LTO/alias-indirect-function-lto.c
===
--- /dev/null
+++ llvm/test/LTO/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: clang -flto %s
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,19 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+  // Skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (isa(Aliasee)) {
+return;
+  }
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441828.
SchrodingerZhu edited the summary of this revision.
SchrodingerZhu added a comment.

address CR


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  clang/test/Analysis/alias-indirect-function-lto.c
  llvm/test/LTO/alias-indirect-function-lto.c


Index: llvm/test/LTO/alias-indirect-function-lto.c
===
--- llvm/test/LTO/alias-indirect-function-lto.c
+++ llvm/test/LTO/alias-indirect-function-lto.c
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -flto %s
+// RUN: clang -flto %s
 void f() __attribute__((ifunc("g")));
 static void *g() { return 0; };
 void h() __attribute__((alias("f")));
-// no crash
\ No newline at end of file
+// no crash


Index: llvm/test/LTO/alias-indirect-function-lto.c
===
--- llvm/test/LTO/alias-indirect-function-lto.c
+++ llvm/test/LTO/alias-indirect-function-lto.c
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -flto %s
+// RUN: clang -flto %s
 void f() __attribute__((ifunc("g")));
 static void *g() { return 0; };
 void h() __attribute__((alias("f")));
-// no crash
\ No newline at end of file
+// no crash
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-07-01 Thread Jennifer 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 rG927156a67445: Generate the capture for the field when the 
field is used in openmp (authored by jyu2).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127803

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/OpenMP/default_firstprivate_ast_print.cpp
  clang/test/OpenMP/default_private_ast_print.cpp

Index: clang/test/OpenMP/default_private_ast_print.cpp
===
--- clang/test/OpenMP/default_private_ast_print.cpp
+++ clang/test/OpenMP/default_private_ast_print.cpp
@@ -96,4 +96,57 @@
   // DUMP-NEXT:  -DeclRefExpr {{.*}} 'a'
   // DUMP-NEXT:  -DeclRefExpr {{.*}} 'yy'
 }
+
+void zoo(int);
+struct A {
+  int z;
+  int f;
+  A();
+  ~A();
+  void foo() {
+#pragma omp parallel private(z) default(private)
+{
+  z++;
+  f++;
+  zoo(z + f);
+  f++;
+}
+  }
+  // PRINT:#pragma omp parallel private(this->z) default(private)
+  // DUMP: -OMPParallelDirective
+  // DUMP-NEXT:  -OMPPrivateClause
+  // DUMP-NEXT:-DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:  -OMPDefaultClause
+  // DUMP-NEXT:  -OMPPrivateClause
+  // DUMP-NEXT:-DeclRefExpr {{.*}} 'f'
+  // DUMP: -CXXThisExpr {{.*}} 'A *' implicit this
+  void bar() {
+#pragma omp parallel private(z) default(private)
+{
+#pragma omp parallel private(z) default(private)
+  {
+z++;
+f++;
+zoo(z + f);
+f++;
+  }
+}
+  }
+  // PRINT:#pragma omp parallel private(this->z) default(private)
+  // PRINT:  #pragma omp parallel private(this->z) default(private)
+  // DUMP: -OMPParallelDirective
+  // DUMP-NEXT:  -OMPPrivateClause
+  // DUMP-NEXT:-DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:  -OMPDefaultClause
+  // DUMP:   -OMPParallelDirective
+  // DUMP-NEXT:-OMPPrivateClause
+  // DUMP-NEXT:   -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:-OMPDefaultClause
+  // DUMP-NEXT:-OMPPrivateClause {{.*}} 
+  // DUMP-NEXT:   -DeclRefExpr {{.*}} 'f'
+  // DUMP: -CXXThisExpr
+  // DUMP: -MemberExpr
+  // DUMP-NEXT:   -CXXThisExpr
+  // DUMP: -CXXThisExpr
+};
 #endif // HEADER
Index: clang/test/OpenMP/default_firstprivate_ast_print.cpp
===
--- clang/test/OpenMP/default_firstprivate_ast_print.cpp
+++ clang/test/OpenMP/default_firstprivate_ast_print.cpp
@@ -38,22 +38,31 @@
   void apply() {
 #pragma omp parallel default(firstprivate)
 {
-  targetDev++;
+  [=]() -> int {
+return targetDev++;
+  }();
 }
 // PRINT: #pragma omp parallel default(firstprivate)
 // PRINT-NEXT: {
-// PRINT-NEXT:  this->targetDev++;
-// CHECK-NEXT: }
+// PRINT-NEXT:  [=]() -> int {
+// PRINT-NEXT: return this->targetDev++;
+// PRINT-NEXT:  }();
+// PRINT-NEXT: }
 // DUMP: -OMPParallelDirective
-// DUMP->NEXT: -OMPDefaultClause
+// DUMP-NEXT: -OMPDefaultClause
+// DUMP-NOT:   -OMPFirstprivateClause
   }
   // PRINT: template<> void apply<32U>()
   // PRINT: #pragma omp parallel default(firstprivate)
   // PRINT-NEXT: {
-  // PRINT-NEXT:  this->targetDev++;
+  // PRINT-NEXT:  [=]() -> int {
+  // PRINT-NEXT: return this->targetDev++;
+  // PRINT-NEXT:  }();
   // CHECK-NEXT: }
   // DUMP: -OMPParallelDirective
   // DUMP-NEXT: -OMPDefaultClause
+  // DUMP-NEXT: -OMPFirstprivateClause
+  // DUMP-NEXT:   -DeclRefExpr {{.*}} 'targetDev'
 };
 
 void use_template() {
@@ -99,4 +108,60 @@
   // DUMP-NEXT: -DeclRefExpr {{.*}} 'yy'
   // DUMP-NEXT: -DeclRefExpr {{.*}} 'y'
 }
+void zoo(int);
+struct A {
+  int z;
+  int f;
+  A();
+  ~A();
+  void foo() {
+#pragma omp parallel firstprivate(z) default(firstprivate)
+{
+  z++;
+  f++;
+  zoo(z + f);
+  f++;
+}
+  }
+  // PRINT:  #pragma omp parallel firstprivate(this->z) default(firstprivate)
+  // DUMP:   -OMPParallelDirective
+  // DUMP-NEXT: -OMPFirstprivateClause
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT: -OMPDefaultClause
+  // DUMP-NEXT: -OMPFirstprivateClause {{.*}} 
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
+  // DUMP:  -CXXThisExpr {{.*}} 'A *' implicit this
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
+  void bar() {
+#pragma omp parallel firstprivate(z) default(firstprivate)
+{
+#pragma omp parallel private(z) default(firstprivate)
+  {
+z++;
+f++;
+zoo(z + f);
+f++;
+  }
+}
+  }
+  // PRINT:  #pragma omp parallel firstprivate(this->z) default(firstprivate)
+  // PRINT:#pragma omp parallel private(this->z) default(firstprivate)
+  // DUMP: 

[clang] 927156a - Generate the capture for the field when the field is used in openmp

2022-07-01 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2022-07-01T17:09:01-07:00
New Revision: 927156a67445a6edb1b09e3d6246b0e5a9cf8a16

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

LOG: Generate the capture for the field when the field is used in openmp
region with implicit default inside the member function.

This is to fix assert when field is referenced in OpenMP region with
default (first|private) clause inside member function.

The problem of assert is that the capture is not generated for the field.

This patch is to generate capture when the field is used with implicit
default, use it in the code, and save the capture off to make sure it is
considered from that point and add first/private clauses.

1> Add new field ImplicitDefaultFirstprivateFDs in SharingMapTy, used to
   store generated capture fields info.
2> In function isOpenMPCaptureDecl: the caputer is generated and saved
   in ImplicitDefaultFirstprivateFDs.
3> Add new help functions:
   getImplicitFDCapExprDecl
   isImplicitDefaultFirstprivateFD
   addImplicitDefaultFirstprivateFD
4> Add addition argument in hasDSA to check default attribute for
   default(first|private).
5> The isImplicitDefaultFirstprivateFD is used in VisitDeclRefExpr to
   build the implicit clause.
6> Add new parameter "Context" for buildCaptureDecl, due to when capture
   field, the parent context is needed to be used.
7> Change in isOpenMPPrivateDecl where stop propagate the capture from
   the enclosing region for private variable.
8> In ActOnOpenMPFirstprivate/ActOnOpenMPPrivate, using captured info
   to generate first|private clause.
9> Add new function isOpenMPRebuildMemberExpr: use to determine if field
   needs to be rebuild during template instantiation.

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/test/OpenMP/default_firstprivate_ast_print.cpp
clang/test/OpenMP/default_private_ast_print.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 17c9b1c2a5d32..ac241cf0515d4 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10725,6 +10725,13 @@ class Sema final {
   /// constructs.
   VarDecl *isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo = false,
 unsigned StopAt = 0);
+
+  /// The member expression(this->fd) needs to be rebuilt in the template
+  /// instantiation to generate private copy for OpenMP when default
+  /// clause is used. The function will return true if default
+  /// cluse is used.
+  bool isOpenMPRebuildMemberExpr(ValueDecl *D);
+
   ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK,
ExprObjectKind OK, SourceLocation Loc);
 

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 3b8f22201d824..117fec4c54194 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -196,6 +196,22 @@ class DSAStackTy {
 llvm::DenseSet> UsedInScanDirective;
 llvm::DenseMap, UsesAllocatorsDeclKind>
 UsesAllocatorsDecls;
+/// Data is required on creating capture fields for implicit
+/// default first|private clause.
+struct ImplicitDefaultFDInfoTy {
+  /// Field decl.
+  const FieldDecl *FD = nullptr;
+  /// Nesting stack level
+  size_t StackLevel = 0;
+  /// Capture variable decl.
+  VarDecl *VD = nullptr;
+  ImplicitDefaultFDInfoTy(const FieldDecl *FD, size_t StackLevel,
+  VarDecl *VD)
+  : FD(FD), StackLevel(StackLevel), VD(VD) {}
+};
+/// List of captured fields
+llvm::SmallVector
+ImplicitDefaultFirstprivateFDs;
 Expr *DeclareMapperVar = nullptr;
 SharingMapTy(OpenMPDirectiveKind DKind, DeclarationNameInfo Name,
  Scope *CurScope, SourceLocation Loc)
@@ -577,7 +593,9 @@ class DSAStackTy {
   /// predicate.
   const DSAVarData
   hasDSA(ValueDecl *D,
- const llvm::function_ref CPred,
+ const llvm::function_ref
+ CPred,
  const llvm::function_ref DPred,
  bool FromParent) const;
   /// Checks if the specified variables has data-sharing attributes which
@@ -1120,6 +1138,52 @@ class DSAStackTy {
 const SharingMapTy *Top = getTopOfStackOrNull();
 return Top ? Top->DeclareMapperVar : nullptr;
   }
+  /// get captured field from ImplicitDefaultFirstprivateFDs
+  VarDecl *getImplicitFDCapExprDecl(const FieldDecl *FD) const {
+const_iterator I = begin();
+const_iterator EndI = end();
+size_t StackLevel = getStackSize();
+for (; I != EndI; ++I) {
+  if (I->DefaultAttr == 

[PATCH] D128402: [clang-tidy] Don't treat invalid branches as identical

2022-07-01 Thread Ishaan Gandhi via Phabricator via cfe-commits
ishaangandhi added a comment.

Sure!

Ishaan Gandhi
ishaangandhi AT gmail DOT com


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

https://reviews.llvm.org/D128402

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


[PATCH] D129030: [Driver] Ignore the clang modules validation-related flags if clang modules are not enabled

2022-07-01 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi created this revision.
Herald added a project: All.
akyrtzi requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

If clang modules are not enabled it becomes unnecessary to read the session 
timestamp file in order
to pass `-fbuild-session-timestamp` to the `cc1` invocation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129030

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/modules.m

Index: clang/test/Driver/modules.m
===
--- clang/test/Driver/modules.m
+++ clang/test/Driver/modules.m
@@ -4,27 +4,27 @@
 // RUN: %clang -fmodules -fno-modules -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
 // CHECK-HAS-MODULES: -fmodules
 
-// RUN: %clang -fbuild-session-file=doesntexist -### %s 2>&1 | FileCheck -check-prefix=NOFILE %s
+// RUN: %clang -fmodules -fbuild-session-file=doesntexist -### %s 2>&1 | FileCheck -check-prefix=NOFILE %s
 // NOFILE: no such file or directory: 'doesntexist'
 
 // RUN: touch -m -a -t 201008011501 %t.build-session-file
-// RUN: %clang -fbuild-session-file=%t.build-session-file -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
+// RUN: %clang -fmodules -fbuild-session-file=%t.build-session-file -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
 
-// RUN: %clang -fbuild-session-timestamp=1280703457 -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
+// RUN: %clang -fmodules -fbuild-session-timestamp=1280703457 -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
 // TIMESTAMP_ONLY: -fbuild-session-timestamp=128{{([[:digit:]]{7})[^[:digit:]]}}
 
-// RUN: %clang -fbuild-session-file=%t.build-session-file -fbuild-session-timestamp=123 -### %s 2>&1 | FileCheck -check-prefix=CONFLICT %s
+// RUN: %clang -fmodules -fbuild-session-file=%t.build-session-file -fbuild-session-timestamp=123 -### %s 2>&1 | FileCheck -check-prefix=CONFLICT %s
 // CONFLICT: error: invalid argument '-fbuild-session-file={{.*}}.build-session-file' not allowed with '-fbuild-session-timestamp'
 
-// RUN: %clang -fbuild-session-timestamp=123 -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE %s
+// RUN: %clang -fmodules -fbuild-session-timestamp=123 -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE %s
 // MODULES_VALIDATE_ONCE: -fbuild-session-timestamp=123
 // MODULES_VALIDATE_ONCE: -fmodules-validate-once-per-build-session
 
-// RUN: %clang -fbuild-session-file=%t.build-session-file -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_FILE %s
+// RUN: %clang -fmodules -fbuild-session-file=%t.build-session-file -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_FILE %s
 // MODULES_VALIDATE_ONCE_FILE: -fbuild-session-timestamp=128{{([[:digit:]]{7})[^[:digit:]]}}
 // MODULES_VALIDATE_ONCE_FILE: -fmodules-validate-once-per-build-session
 
-// RUN: %clang -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_ERR %s
+// RUN: %clang -fmodules -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_ERR %s
 // MODULES_VALIDATE_ONCE_ERR: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=' or '-fbuild-session-file='
 
 // RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT %s
@@ -33,16 +33,16 @@
 // RUN: %clang -fmodules -fsyntax-only -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT_MOD %s
 // MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT_MOD: -fmodules-validate-system-headers
 
-// RUN: %clang -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
+// RUN: %clang -fmodules -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
 // MODULES_VALIDATE_SYSTEM_HEADERS: -fmodules-validate-system-headers
 
-// RUN: %clang -fno-modules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_NOSYSVALID %s
+// RUN: %clang -fmodules -fno-modules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_NOSYSVALID %s
 // MODULES_VALIDATE_SYSTEM_HEADERS_NOSYSVALID-NOT: -fmodules-validate-system-headers
 
 // RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT %s
 // MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT-NOT: -fmodules-disable-diagnostic-validation
 
-// RUN: %clang -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION %s
+// RUN: %clang -fmodules -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck 

[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441821.
SchrodingerZhu added a comment.

undo wrong patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  clang/test/Analysis/alias-indirect-function-lto.c
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,19 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+  // Skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (isa(Aliasee)) {
+return;
+  }
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&
Index: clang/test/Analysis/alias-indirect-function-lto.c
===
--- /dev/null
+++ clang/test/Analysis/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: %clang_analyze_cc1 -flto %s
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
\ No newline at end of file


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,9 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() || isa(Aliasee))
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,15 +646,19 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
+DenseSet ) {
+  auto *Aliasee = A.getAliaseeObject();
+  // Skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (isa(Aliasee)) {
+return;
+  }
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(
   A.getLinkage(), A.getVisibility(), NonRenamableLocal,
   /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
   auto AS = std::make_unique(Flags);
-  auto *Aliasee = A.getAliaseeObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
   assert(AliaseeVI && "Alias expects aliasee summary to be available");
   assert(AliaseeVI.getSummaryList().size() == 1 &&
Index: clang/test/Analysis/alias-indirect-function-lto.c
===
--- /dev/null
+++ clang/test/Analysis/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: %clang_analyze_cc1 -flto %s
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
\ No newline at end of file
___

[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441820.
SchrodingerZhu added a comment.

address CR


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,7 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName() ||
-Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+if (!Aliasee->hasName() || isa(Aliasee))
   // IFunc function and Nameless function don't have an entry in the
   // summary, skip it.
   continue;
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -649,23 +649,24 @@
 static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
 DenseSet ) {
   auto *Aliasee = A.getAliaseeObject();
-  // Currently, skip summary for indirect function aliases as
+  // Skip summary for indirect function aliases as
   // summary for aliasee will not be emitted.
-  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
-bool NonRenamableLocal = isNonRenamableLocal(A);
-GlobalValueSummary::GVFlags Flags(
-A.getLinkage(), A.getVisibility(), NonRenamableLocal,
-/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
-auto AS = std::make_unique(Flags);
-auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
-assert(AliaseeVI && "Alias expects aliasee summary to be available");
-assert(AliaseeVI.getSummaryList().size() == 1 &&
-   "Expected a single entry per aliasee in per-module index");
-AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
-if (NonRenamableLocal)
-  CantBePromoted.insert(A.getGUID());
-Index.addGlobalValueSummary(A, std::move(AS));
+  if (isa(Aliasee)) {
+return;
   }
+  bool NonRenamableLocal = isNonRenamableLocal(A);
+  GlobalValueSummary::GVFlags Flags(
+  A.getLinkage(), A.getVisibility(), NonRenamableLocal,
+  /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
+  auto AS = std::make_unique(Flags);
+  auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
+  assert(AliaseeVI && "Alias expects aliasee summary to be available");
+  assert(AliaseeVI.getSummaryList().size() == 1 &&
+ "Expected a single entry per aliasee in per-module index");
+  AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
+  if (NonRenamableLocal)
+CantBePromoted.insert(A.getGUID());
+  Index.addGlobalValueSummary(A, std::move(AS));
 }
 
 // Set LiveRoot flag on entries matching the given value name.


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,7 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName() ||
-Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+if (!Aliasee->hasName() || isa(Aliasee))
   // IFunc function and Nameless function don't have an entry in the
   // summary, skip it.
   continue;
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -649,23 +649,24 @@
 static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
 DenseSet ) {
   auto *Aliasee = A.getAliaseeObject();
-  // Currently, skip summary for indirect function aliases as
+  // Skip summary for indirect function aliases as
   // summary for aliasee will not be emitted.
-  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
-bool NonRenamableLocal = isNonRenamableLocal(A);
-GlobalValueSummary::GVFlags Flags(
-A.getLinkage(), A.getVisibility(), NonRenamableLocal,
-/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
-auto AS = std::make_unique(Flags);
-auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
-assert(AliaseeVI && "Alias expects aliasee summary to be available");
-assert(AliaseeVI.getSummaryList().size() == 1 &&
-   "Expected a single entry per aliasee in per-module index");
-AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
-if (NonRenamableLocal)
-  CantBePromoted.insert(A.getGUID());
-

[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441819.
SchrodingerZhu added a comment.

address CR


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,7 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName() ||
-Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+if (!Aliasee->hasName() || isa(Aliasee))
   // IFunc function and Nameless function don't have an entry in the
   // summary, skip it.
   continue;
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -649,23 +649,24 @@
 static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
 DenseSet ) {
   auto *Aliasee = A.getAliaseeObject();
-  // Currently, skip summary for indirect function aliases as
+  // Skip summary for indirect function aliases as
   // summary for aliasee will not be emitted.
-  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
-bool NonRenamableLocal = isNonRenamableLocal(A);
-GlobalValueSummary::GVFlags Flags(
-A.getLinkage(), A.getVisibility(), NonRenamableLocal,
-/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
-auto AS = std::make_unique(Flags);
-auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
-assert(AliaseeVI && "Alias expects aliasee summary to be available");
-assert(AliaseeVI.getSummaryList().size() == 1 &&
-   "Expected a single entry per aliasee in per-module index");
-AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
-if (NonRenamableLocal)
-  CantBePromoted.insert(A.getGUID());
-Index.addGlobalValueSummary(A, std::move(AS));
+  if (isa(Aliasee)) {
+return;
   }
+  bool NonRenamableLocal = isNonRenamableLocal(A);
+  GlobalValueSummary::GVFlags Flags(
+  A.getLinkage(), A.getVisibility(), NonRenamableLocal,
+  /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
+  auto AS = std::make_unique(Flags);
+  auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
+  assert(AliaseeVI && "Alias expects aliasee summary to be available");
+  assert(AliaseeVI.getSummaryList().size() == 1 &&
+ "Expected a single entry per aliasee in per-module index");
+  AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
+  if (NonRenamableLocal)
+CantBePromoted.insert(A.getGUID());
+  Index.addGlobalValueSummary(A, std::move(AS));
 }
 
 // Set LiveRoot flag on entries matching the given value name.


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,7 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName() ||
-Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+if (!Aliasee->hasName() || isa(Aliasee))
   // IFunc function and Nameless function don't have an entry in the
   // summary, skip it.
   continue;
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -649,23 +649,24 @@
 static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
 DenseSet ) {
   auto *Aliasee = A.getAliaseeObject();
-  // Currently, skip summary for indirect function aliases as
+  // Skip summary for indirect function aliases as
   // summary for aliasee will not be emitted.
-  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
-bool NonRenamableLocal = isNonRenamableLocal(A);
-GlobalValueSummary::GVFlags Flags(
-A.getLinkage(), A.getVisibility(), NonRenamableLocal,
-/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
-auto AS = std::make_unique(Flags);
-auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
-assert(AliaseeVI && "Alias expects aliasee summary to be available");
-assert(AliaseeVI.getSummaryList().size() == 1 &&
-   "Expected a single entry per aliasee in per-module index");
-AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
-if (NonRenamableLocal)
-  CantBePromoted.insert(A.getGUID());
-

[PATCH] D128314: [Clang-tidy] Fixing a bug in clang-tidy infinite-loop checker

2022-07-01 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 441816.
ziqingluo-90 added a comment.

I saw @aaron.ballman 's comment "//We typically don't add AST matchers until we 
have a need for them to be used in-tree (ASTMatchers.h is already really 
expensive to parse; adding matchers for everything possible with AST nodes 
would be prohibitively expensive).//" in this patch 
.   So I think the matchers for testing 
`noreturn` attributes is too specific to be in the `ASTMatcher.h`.  Moving them 
to where they are used.   While the `objcMessageCallee` is sort of the Obj-C 
counterpart of the `callee` matcher, so I think it is general enough to stay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128314

Files:
  clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/infinite-loop-noreturn.mm
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp

Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -501,6 +501,7 @@
   REGISTER_MATCHER(objcIvarDecl);
   REGISTER_MATCHER(objcIvarRefExpr);
   REGISTER_MATCHER(objcMessageExpr);
+  REGISTER_MATCHER(objcMessageCallee);
   REGISTER_MATCHER(objcMethodDecl);
   REGISTER_MATCHER(objcObjectPointerType);
   REGISTER_MATCHER(objcPropertyDecl);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3838,6 +3838,25 @@
   InnerMatcher.matches(*ExprNode, Finder, Builder));
 }
 
+/// matches if ObjCMessageExpr's callee declaration matches
+///
+/// Given
+/// \code
+///   @interface I: NSObject
+///   +(void)foo;
+///   @end
+///   ...
+///   [I foo]
+/// \endcode
+/// The example above matches \code [I foo] \endcode with
+/// objcMessageExpr(objcMessageCallee(objcMethodDecl(hasName("foo"
+AST_MATCHER_P(ObjCMessageExpr, objcMessageCallee,
+  internal::Matcher, InnerMatcher) {
+  const ObjCMethodDecl *msgDecl = Node.getMethodDecl();
+  return (msgDecl != nullptr &&
+  InnerMatcher.matches(*msgDecl, Finder, Builder));
+}
+
 /// Matches if the call expression's callee's declaration matches the
 /// given matcher.
 ///
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -8867,6 +8867,20 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprobjcMessageCalleeMatcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDecl InnerMatcher
+matches if ObjCMessageExpr's callee declaration matches
+
+Given
+  @interface I: NSObject
+  +(void)foo;
+  @end
+  ...
+  [I foo]
+The example above matches [I foo] with
+objcMessageExpr(objcMessageCallee(objcMethodDecl(hasName("foo"
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclhasAnyParameterMatcherhttps://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDecl InnerMatcher
 Matches any parameter of a function or an ObjC method declaration or a
 block.
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/infinite-loop-noreturn.mm
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/infinite-loop-noreturn.mm
@@ -0,0 +1,62 @@
+// RUN: %check_clang_tidy %s bugprone-infinite-loop %t -- -- -fblocks -fexceptions
+// RUN: %check_clang_tidy %s bugprone-infinite-loop %t -- -- -fblocks -fobjc-arc -fexceptions
+
+@interface I
++ (void)foo;
++ (void)bar;
++ (void)baz __attribute__((noreturn));
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+_Noreturn void term();
+
+void plainCFunction() {
+  int i = 0;
+  int j = 0;
+  int a[10];
+
+  while (i < 10) {
+// no warning, function term has C noreturn attribute
+term();
+  }
+  while (i < 10) {
+// no warning, class method baz has noreturn attribute
+[I baz];
+  }
+  while (i + j < 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i, j) are updated in the loop body [bugprone-infinite-loop]
+[I foo];
+  }
+  while (i + j < 10) {
+[I foo];
+[I baz]; // no warning, class method baz has noreturn attribute
+  }
+
+  void (^block)() = ^{
+  };
+  void __attribute__((noreturn)) (^block_nr)(void) = ^void __attribute__((noreturn)) (void) { throw "err"; };
+
+  while (i < 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none 

[PATCH] D128766: Update references to Discourse instead of the mailing lists.

2022-07-01 Thread Tanya Lattner via Phabricator via cfe-commits
tonic updated this revision to Diff 441800.
tonic added a comment.

Fix typos.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128766

Files:
  clang/docs/ExternalClangExamples.rst
  clang/www/get_involved.html


Index: clang/www/get_involved.html
===
--- clang/www/get_involved.html
+++ clang/www/get_involved.html
@@ -36,7 +36,7 @@
  - This list is for patch submission/discussion.
 
 https://discourse.llvm.org/c/clang/6;>Clang Frontend Discourse 
forum -
-This forums is for everything else Clang related (questions and answers, design
+This forum is for everything else Clang related (questions and answers, design
 discussions, etc).
 
 
Index: clang/docs/ExternalClangExamples.rst
===
--- clang/docs/ExternalClangExamples.rst
+++ clang/docs/ExternalClangExamples.rst
@@ -18,7 +18,7 @@
 - Static analysis.
 - Documentation/cross-reference generation.
 
-If you know of (or wrote!) a tool or project using Clang, pleasepost on 
+If you know of (or wrote!) a tool or project using Clang, please post on 
 `the Discourse forums (Clang Frontend category)
 `_ to have it added.
 (or if you are already a Clang contributor, feel free to directly commit


Index: clang/www/get_involved.html
===
--- clang/www/get_involved.html
+++ clang/www/get_involved.html
@@ -36,7 +36,7 @@
  - This list is for patch submission/discussion.
 
 https://discourse.llvm.org/c/clang/6;>Clang Frontend Discourse forum -
-This forums is for everything else Clang related (questions and answers, design
+This forum is for everything else Clang related (questions and answers, design
 discussions, etc).
 
 
Index: clang/docs/ExternalClangExamples.rst
===
--- clang/docs/ExternalClangExamples.rst
+++ clang/docs/ExternalClangExamples.rst
@@ -18,7 +18,7 @@
 - Static analysis.
 - Documentation/cross-reference generation.
 
-If you know of (or wrote!) a tool or project using Clang, pleasepost on 
+If you know of (or wrote!) a tool or project using Clang, please post on 
 `the Discourse forums (Clang Frontend category)
 `_ to have it added.
 (or if you are already a Clang contributor, feel free to directly commit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-01 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 441793.
pscoro added a comment.

Combined aix and linux IR lit tests into a single file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=LINUX
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; AIX-LABEL: test_kill_canary:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:blr
+;
+; LINUX-LABEL: test_kill_canary:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; AIX-LABEL: test_kill_canary_ssp:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:mflr r0
+; AIX-NEXT:std r0, 16(r1)
+; AIX-NEXT:stdu r1, -128(r1)
+; AIX-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:std r4, 120(r1)
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:xori r4, r4, 65535
+; AIX-NEXT:xoris r4, r4, 65535
+; AIX-NEXT:std r4, 0(r3)
+; AIX-NEXT:ld r3, 0(r3)
+; AIX-NEXT:ld r4, 120(r1)
+; AIX-NEXT:cmpld r3, r4
+; AIX-NEXT:bne cr0, L..BB1_2
+; AIX-NEXT:  # %bb.1: # %entry
+; AIX-NEXT:addi r1, r1, 128
+; AIX-NEXT:ld r0, 16(r1)
+; AIX-NEXT:mtlr r0
+; AIX-NEXT:blr
+; AIX-NEXT:  L..BB1_2: # %entry
+; AIX-NEXT:bl .__stack_chk_fail[PR]
+; AIX-NEXT:nop
+;
+; LINUX-LABEL: test_kill_canary_ssp:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:mflr r0
+; LINUX-NEXT:std r0, 16(r1)
+; LINUX-NEXT:stdu r1, -128(r1)
+; LINUX-NEXT:.cfi_def_cfa_offset 128
+; LINUX-NEXT:.cfi_offset lr, 16
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:xori r3, r3, 65535
+; LINUX-NEXT:xoris r3, r3, 65535
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, 120(r1)
+; LINUX-NEXT:ld r4, -28688(r13)
+; LINUX-NEXT:cmpld r4, r3
+; LINUX-NEXT:bne cr0, .LBB1_2
+; LINUX-NEXT:  # %bb.1: # %entry
+; LINUX-NEXT:addi r1, r1, 128
+; LINUX-NEXT:ld r0, 16(r1)
+; LINUX-NEXT:mtlr r0
+; LINUX-NEXT:blr
+; LINUX-NEXT:  .LBB1_2: # %entry
+; LINUX-NEXT:bl __stack_chk_fail
+; LINUX-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -11127,6 +11127,84 @@
 }
 break;
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction  = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+/* If SafeStack or !StackProtector, kill_canary not supported */
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0)); // prepare node for deletion
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+EVT MemVT =
+DAG.getTargetLoweringInfo().getPointerMemTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+const uint64_t XORWord = 0x; // XORing with 0b111...111 will never
+ // result in the original word
+
+// try getting canary word as global value if it exists
+GlobalValue *GV = (Subtarget.isAIXABI())
+  ? M->getGlobalVariable(AIXSSPCanaryWordName)
+  : M->getNamedValue("__stack_chk_guard");
+if (GV == nullptr) { // linux uses LOAD_STACK_GUARD node instead of having a
+ // canary word global value
+  if (useLoadStackGuardNode()) {
+MachineSDNode *LSG = DAG.getMachineNode(PPC::LOAD_STACK_GUARD, DL, VT,
+Op->getOperand(0));
+if (VT != MemVT) {
+  Load = DAG.getPtrExtOrTrunc(SDValue(LSG, 0), DL, 

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-07-01 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka reopened this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

In D126907#3623377 , @vitalybuka 
wrote:

> FYI. The same on a different bot 
> https://lab.llvm.org/buildbot/#/builders/5/builds/25486/steps/19/logs/stdio

Not sure if the URL above was not related, as lease I see no red builds after 
"relanded patch"

However these are 100% relevant, I tested msan one locally 258c3aee54e1 
 vs 
188582b7e0f3 

https://lab.llvm.org/buildbot/#/builders/74/builds/11706
https://lab.llvm.org/buildbot/#/builders/85/builds/8938
https://lab.llvm.org/buildbot/#/builders/168/builds/7114

However sanitizers has nothing to do with the problems, you just need compilers 
builds with asserts, and then use that one to build and run libcxx tests.

This reproduces the issue on 188582b7e0f357bb9b137b995f773d114472a9c4 


  mkdir b0
  cd b0/
  # ${HOME}/src/clang/bin/clang++ is some stable good build of clang.
  cmake -GNinja ${HOME}/src/llvm.git/llvm-project/llvm 
'-DLLVM_ENABLE_PROJECTS=clang;lld'   -DLLVM_CCACHE_BUILD=ON 
-DCMAKE_C_COMPILER=${HOME}/src/clang/bin/clang 
-DCMAKE_CXX_COMPILER=${HOME}/src/clang/bin/clang++  -DCMAKE_BUILD_TYPE=Release 
-DLLVM_ENABLE_ASSERTIONS=ON
  ninja
  
  mkdir ../b1
  cd ../b1
  cmake -GNinja ${HOME}/src/llvm.git/llvm-project/llvm 
'-DLLVM_ENABLE_PROJECTS=libcxx;libcxxabi'  -DCMAKE_C_COMPILER=$(readlink -f 
../b0)/bin/clang -DCMAKE_CXX_COMPILER=$(readlink -f ../b0)/bin/clang++  
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON
  ninja check-cxx


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-01 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:11150
+
+const uint64_t XORWord = 0x; // XORing with 0b111...111 will never
+ // result in the original word

To address a comment on the previous review, I fixed the XOR to do what I 
intended. When you XOR bits against 1, you are guaranteed to not return the 
same bit because of exclusivity. Therefore XORing the canary word against 
0x (0b...111) guarantees that the corrupted canary word is never 
the same as the original



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:11157
+  : M->getNamedValue("__stack_chk_guard");
+if (GV == nullptr) { // linux uses LOAD_STACK_GUARD node instead of having 
a
+ // canary word global value

Addressing a comment from the previous review, GV != nullptr can not be an 
assert because linux implements stack guard loading differently than aix. This 
review now also supports linux as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

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


[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-01 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro added a comment.

Sorry about making a separate review for this again, I encountered some 
troubles with git and decided that moving my code to a fresh branch would be 
quicker than figuring out how to fix the problem, the previous review will be 
abandoned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

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


[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-01 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro created this revision.
Herald added subscribers: shchenz, kbarton, hiraditya, nemanjai.
Herald added a project: All.
pscoro requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129016

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-aix.ll
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-linux.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-linux.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-linux.ll
@@ -0,0 +1,46 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; CHECK-LABEL: test_kill_canary:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; CHECK-LABEL: test_kill_canary_ssp:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mflr r0
+; CHECK-NEXT:std r0, 16(r1)
+; CHECK-NEXT:stdu r1, -128(r1)
+; CHECK-NEXT:.cfi_def_cfa_offset 128
+; CHECK-NEXT:.cfi_offset lr, 16
+; CHECK-NEXT:ld r3, -28688(r13)
+; CHECK-NEXT:std r3, 120(r1)
+; CHECK-NEXT:ld r3, -28688(r13)
+; CHECK-NEXT:xori r3, r3, 65535
+; CHECK-NEXT:xoris r3, r3, 65535
+; CHECK-NEXT:std r3, 120(r1)
+; CHECK-NEXT:ld r3, 120(r1)
+; CHECK-NEXT:ld r4, -28688(r13)
+; CHECK-NEXT:cmpld r4, r3
+; CHECK-NEXT:bne cr0, .LBB1_2
+; CHECK-NEXT:  # %bb.1: # %entry
+; CHECK-NEXT:addi r1, r1, 128
+; CHECK-NEXT:ld r0, 16(r1)
+; CHECK-NEXT:mtlr r0
+; CHECK-NEXT:blr
+; CHECK-NEXT:  .LBB1_2: # %entry
+; CHECK-NEXT:bl __stack_chk_fail
+; CHECK-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-aix.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-aix.ll
@@ -0,0 +1,45 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; CHECK-LABEL: test_kill_canary:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; CHECK-LABEL: test_kill_canary_ssp:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mflr r0
+; CHECK-NEXT:std r0, 16(r1)
+; CHECK-NEXT:stdu r1, -128(r1)
+; CHECK-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; CHECK-NEXT:ld r4, 0(r3)
+; CHECK-NEXT:std r4, 120(r1)
+; CHECK-NEXT:ld r4, 0(r3)
+; CHECK-NEXT:xori r4, r4, 65535
+; CHECK-NEXT:xoris r4, r4, 65535
+; CHECK-NEXT:std r4, 0(r3)
+; CHECK-NEXT:ld r3, 0(r3)
+; CHECK-NEXT:ld r4, 120(r1)
+; CHECK-NEXT:cmpld r3, r4
+; CHECK-NEXT:bne cr0, L..BB1_2
+; CHECK-NEXT:  # %bb.1: # %entry
+; CHECK-NEXT:addi r1, r1, 128
+; CHECK-NEXT:ld r0, 16(r1)
+; CHECK-NEXT:mtlr r0
+; CHECK-NEXT:blr
+; CHECK-NEXT:  L..BB1_2: # %entry
+; CHECK-NEXT:bl .__stack_chk_fail[PR]
+; CHECK-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -11127,6 +11127,84 @@
 }
 break;
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction  = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+/* If SafeStack or !StackProtector, kill_canary not supported */
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0)); // prepare node for deletion
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+EVT MemVT =
+DAG.getTargetLoweringInfo().getPointerMemTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+const uint64_t XORWord = 0x; // XORing 

[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-07-01 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0d3a2b4c6601: [Lex] Introduce 
`PPCallbacks::LexedFileChanged()` preprocessor callback (authored by akyrtzi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128947

Files:
  clang-tools-extra/test/pp-trace/pp-trace-include.cpp
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Lex/PPLexerChange.cpp

Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -111,6 +111,7 @@
 ///  and start lexing tokens from it instead of the current buffer.
 void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
 ConstSearchDirIterator CurDir) {
+  PreprocessorLexer *PrevPPLexer = CurPPLexer;
 
   // Add the current lexer to the include stack.
   if (CurPPLexer || CurTokenLexer)
@@ -130,8 +131,17 @@
 SrcMgr::CharacteristicKind FileType =
SourceMgr.getFileCharacteristic(CurLexer->getFileLoc());
 
-Callbacks->FileChanged(CurLexer->getFileLoc(),
-   PPCallbacks::EnterFile, FileType);
+FileID PrevFID;
+SourceLocation EnterLoc;
+if (PrevPPLexer) {
+  PrevFID = PrevPPLexer->getFileID();
+  EnterLoc = PrevPPLexer->getSourceLocation();
+}
+Callbacks->FileChanged(CurLexer->getFileLoc(), PPCallbacks::EnterFile,
+   FileType, PrevFID);
+Callbacks->LexedFileChanged(CurLexer->getFileID(),
+PPCallbacks::LexedFileChangeReason::EnterFile,
+FileType, PrevFID, EnterLoc);
   }
 }
 
@@ -486,10 +496,13 @@
 
 // Notify the client, if desired, that we are in a new source file.
 if (Callbacks && !isEndOfMacro && CurPPLexer) {
+  SourceLocation Loc = CurPPLexer->getSourceLocation();
   SrcMgr::CharacteristicKind FileType =
-SourceMgr.getFileCharacteristic(CurPPLexer->getSourceLocation());
-  Callbacks->FileChanged(CurPPLexer->getSourceLocation(),
- PPCallbacks::ExitFile, FileType, ExitedFID);
+  SourceMgr.getFileCharacteristic(Loc);
+  Callbacks->FileChanged(Loc, PPCallbacks::ExitFile, FileType, ExitedFID);
+  Callbacks->LexedFileChanged(CurPPLexer->getFileID(),
+  PPCallbacks::LexedFileChangeReason::ExitFile,
+  FileType, ExitedFID, Loc);
 }
 
 // Restore conditional stack as well as the recorded
Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -31,23 +31,21 @@
 namespace {
 struct DepCollectorPPCallbacks : public PPCallbacks {
   DependencyCollector 
-  SourceManager 
-  DiagnosticsEngine 
-  DepCollectorPPCallbacks(DependencyCollector , SourceManager ,
-  DiagnosticsEngine )
-  : DepCollector(L), SM(SM), Diags(Diags) {}
-
-  void FileChanged(SourceLocation Loc, FileChangeReason Reason,
-   SrcMgr::CharacteristicKind FileType,
-   FileID PrevFID) override {
-if (Reason != PPCallbacks::EnterFile)
+  Preprocessor 
+  DepCollectorPPCallbacks(DependencyCollector , Preprocessor )
+  : DepCollector(L), PP(PP) {}
+
+  void LexedFileChanged(FileID FID, LexedFileChangeReason Reason,
+SrcMgr::CharacteristicKind FileType, FileID PrevFID,
+SourceLocation Loc) override {
+if (Reason != PPCallbacks::LexedFileChangeReason::EnterFile)
   return;
 
 // Dependency generation really does want to go all the way to the
 // file entry for a source location to find out what is depended on.
 // We do not want #line markers to affect dependency generation!
-if (Optional Filename = SM.getNonBuiltinFilenameForID(
-SM.getFileID(SM.getExpansionLoc(Loc
+if (Optional Filename =
+PP.getSourceManager().getNonBuiltinFilenameForID(FID))
   DepCollector.maybeAddDependency(
   llvm::sys::path::remove_leading_dotslash(*Filename),
   /*FromModule*/ false, isSystem(FileType), /*IsModuleFile*/ false,
@@ -90,7 +88,9 @@
 /*IsMissing=*/false);
   }
 
-  void EndOfMainFile() override { DepCollector.finishedMainFile(Diags); }
+  void EndOfMainFile() override {
+DepCollector.finishedMainFile(PP.getDiagnostics());
+  }
 };
 
 struct DepCollectorMMCallbacks : public ModuleMapCallbacks {
@@ -175,8 +175,7 @@
 
 DependencyCollector::~DependencyCollector() { }
 void DependencyCollector::attachToPreprocessor(Preprocessor ) {
-  PP.addPPCallbacks(std::make_unique(
-  *this, PP.getSourceManager(), PP.getDiagnostics()));
+  

[clang-tools-extra] 0d3a2b4 - [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-07-01 Thread Argyrios Kyrtzidis via cfe-commits

Author: Argyrios Kyrtzidis
Date: 2022-07-01T14:22:31-07:00
New Revision: 0d3a2b4c6601d4ff341119aa537db184197d83de

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

LOG: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

This is a preprocessor callback focused on the lexed file changing, without 
conflating effects of line number directives and other pragmas.
A client that only cares about what files the lexer processes, like dependency 
generation, can use this more straightforward
callback instead of `PPCallbacks::FileChanged()`. Clients that want the pragma 
directive effects as well can keep using `FileChanged()`.

A use case where `PPCallbacks::LexedFileChanged()` is particularly simpler to 
use than `FileChanged()` is in a situation
where a client wants to keep track of lexed file changes that include changes 
from/to the predefines buffer, where it becomes
unnecessary complicated trying to use `FileChanged()` while filtering out the 
pragma directives effects callbacks.

Also take the opportunity to provide information about the prior `FileID` the 
`Lexer` moved from, even when entering a new file.

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

Added: 


Modified: 
clang-tools-extra/test/pp-trace/pp-trace-include.cpp
clang/include/clang/Lex/PPCallbacks.h
clang/lib/Frontend/DependencyFile.cpp
clang/lib/Lex/PPLexerChange.cpp

Removed: 




diff  --git a/clang-tools-extra/test/pp-trace/pp-trace-include.cpp 
b/clang-tools-extra/test/pp-trace/pp-trace-include.cpp
index 96b4014025b78..db0b2c89430a2 100644
--- a/clang-tools-extra/test/pp-trace/pp-trace-include.cpp
+++ b/clang-tools-extra/test/pp-trace/pp-trace-include.cpp
@@ -13,7 +13,7 @@
 // CHECK-NEXT:   Loc: ":1:1"
 // CHECK-NEXT:   Reason: EnterFile
 // CHECK-NEXT:   FileType: C_User
-// CHECK-NEXT:   PrevFID: (invalid)
+// CHECK-NEXT:   PrevFID: "{{.*}}{{[/\\]}}pp-trace-include.cpp"
 // CHECK-NEXT: - Callback: FileChanged
 // CHECK-NEXT:   Loc: ":1:1"
 // CHECK-NEXT:   Reason: RenameFile
@@ -64,7 +64,7 @@
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}Inputs/Level1A.h:1:1"
 // CHECK-NEXT:   Reason: EnterFile
 // CHECK-NEXT:   FileType: C_User
-// CHECK-NEXT:   PrevFID: (invalid)
+// CHECK-NEXT:   PrevFID: "{{.*}}{{[/\\]}}pp-trace-include.cpp"
 // CHECK-NEXT: - Callback: InclusionDirective
 // CHECK-NEXT:   HashLoc: "{{.*}}{{[/\\]}}Inputs/Level1A.h:1:1"
 // CHECK-NEXT:   IncludeTok: include
@@ -79,7 +79,7 @@
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}Inputs/Level2A.h:1:1"
 // CHECK-NEXT:   Reason: EnterFile
 // CHECK-NEXT:   FileType: C_User
-// CHECK-NEXT:   PrevFID: (invalid)
+// CHECK-NEXT:   PrevFID: "{{.*}}{{[/\\]}}Inputs/Level1A.h"
 // CHECK-NEXT: - Callback: MacroDefined
 // CHECK-NEXT:   MacroNameTok: MACRO_2A
 // CHECK-NEXT:   MacroDirective: MD_Define
@@ -110,7 +110,7 @@
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}Inputs/Level1B.h:1:1"
 // CHECK-NEXT:   Reason: EnterFile
 // CHECK-NEXT:   FileType: C_User
-// CHECK-NEXT:   PrevFID: (invalid)
+// CHECK-NEXT:   PrevFID: "{{.*}}{{[/\\]}}pp-trace-include.cpp"
 // CHECK-NEXT: - Callback: InclusionDirective
 // CHECK-NEXT:   HashLoc: "{{.*}}{{[/\\]}}Inputs/Level1B.h:1:1"
 // CHECK-NEXT:   IncludeTok: include
@@ -125,7 +125,7 @@
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}Inputs/Level2B.h:1:1"
 // CHECK-NEXT:   Reason: EnterFile
 // CHECK-NEXT:   FileType: C_User
-// CHECK-NEXT:   PrevFID: (invalid)
+// CHECK-NEXT:   PrevFID: "{{.*}}{{[/\\]}}Inputs/Level1B.h"
 // CHECK-NEXT: - Callback: MacroDefined
 // CHECK-NEXT:   MacroNameTok: MACRO_2B
 // CHECK-NEXT:   MacroDirective: MD_Define

diff  --git a/clang/include/clang/Lex/PPCallbacks.h 
b/clang/include/clang/Lex/PPCallbacks.h
index 5f7cfab00e41a..045df8711a41b 100644
--- a/clang/include/clang/Lex/PPCallbacks.h
+++ b/clang/include/clang/Lex/PPCallbacks.h
@@ -43,12 +43,34 @@ class PPCallbacks {
   /// Callback invoked whenever a source file is entered or exited.
   ///
   /// \param Loc Indicates the new location.
-  /// \param PrevFID the file that was exited if \p Reason is ExitFile.
+  /// \param PrevFID the file that was exited if \p Reason is ExitFile or the
+  /// the file before the new one entered for \p Reason EnterFile.
   virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID = FileID()) {
   }
 
+  enum class LexedFileChangeReason { EnterFile, ExitFile };
+
+  /// Callback invoked whenever the \p Lexer moves to a 
diff erent file for
+  /// lexing. Unlike \p FileChanged line number directives and other related
+  /// pragmas do not trigger callbacks to \p LexedFileChanged.
+  ///
+  /// \param FID The \p FileID that the \p Lexer moved to.
+  ///
+  /// \param Reason 

[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp:654
+  // summary for aliasee will not be emitted.
+  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
+bool NonRenamableLocal = isNonRenamableLocal(A);

MaskRay wrote:
> Use an early return to avoid indenting so many lines.
Also, please use `isa(Aliasee)` instead of inspecting the value ID.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

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


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-07-01 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

I do not have commit access for the LLVM repository, could one of you commit 
this for me (Nicolas van Kempen )?

I can keep an eye on this today, otherwise I will discuss with someone 
internally and commit Tuesday.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127807

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


[PATCH] D126880: [clang-tidy] Add cppcoreguidelines-avoid-const-or-ref-data-members check

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:130
 
+- New :doc:`cppcoreguidelines-avoid-const-or-ref-data-members
+  ` check.

Sort new checks by check name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126880

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


[PATCH] D126880: [clang-tidy] Add cppcoreguidelines-avoid-const-or-ref-data-members check

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:131
+- New :doc:`cppcoreguidelines-avoid-const-or-ref-data-members
+  ` check.
+

This link is wrong, please install Sphinx and build the target 
`docs-clang-tools-html` to validate links


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126880

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


[PATCH] D128157: [clang-tidy] cppcoreguidelines-virtual-class-destructor: Fix crash when "virtual" keyword is expanded from a macro

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

In D128157#3612741 , @myhsu wrote:

> You forgot to add 
> 
>  "Differential Revison: https://reviews.llvm.org/DXX; in the commit 
> message, which is how Phabricator identifies the differential to close. I 
> don't think it has anything to do with rebasing.

Oh, OK, that makes sense, oops.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128157

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


[PATCH] D129009: [LTO] Fix LTO for aliased IFuncs

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> As https://github.com/llvm/llvm-project/issues/56290 indicates

Write the description, followed by `Fix(es)? 
https://github.com/llvm/llvm-project/issues/56290` on a separate line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

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


[PATCH] D129009: [Analysis][LTO] Fix LTO for aliased IFuncs.

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

LG but the test needs a change.




Comment at: clang/test/Analysis/alias-indirect-function-lto.c:1
+// RUN: %clang_analyze_cc1 -flto -c
+void f() __attribute__((ifunc("g")));

The test is added to the wrong place. clang Analysis != llvm Analysis.

Find somewhere in `llvm/test/ThinLTO`.





Comment at: clang/test/Analysis/alias-indirect-function-lto.c:5
+void h() __attribute__((alias("f")));
\ No newline at end of file


No newline at end of file



Comment at: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp:654
+  // summary for aliasee will not be emitted.
+  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
+bool NonRenamableLocal = isNonRenamableLocal(A);

Use an early return to avoid indenting so many lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

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


[PATCH] D118996: [clang-tidy] Support C++14 in bugprone-signal-handler.

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:237
 
+- Improved :doc:`bugprone-signal-handler
+  ` check. Partial

sort by check name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118996

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


[PATCH] D129009: [Analysis][LTO] Fix LTO for aliased IFuncs.

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441784.
SchrodingerZhu added a comment.

fix integration test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  clang/test/Analysis/alias-indirect-function-lto.c
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,23 +646,26 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
-  bool NonRenamableLocal = isNonRenamableLocal(A);
-  GlobalValueSummary::GVFlags Flags(
-  A.getLinkage(), A.getVisibility(), NonRenamableLocal,
-  /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
-  auto AS = std::make_unique(Flags);
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
   auto *Aliasee = A.getAliaseeObject();
-  auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
-  assert(AliaseeVI && "Alias expects aliasee summary to be available");
-  assert(AliaseeVI.getSummaryList().size() == 1 &&
- "Expected a single entry per aliasee in per-module index");
-  AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
-  if (NonRenamableLocal)
-CantBePromoted.insert(A.getGUID());
-  Index.addGlobalValueSummary(A, std::move(AS));
+  // Currently, skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
+bool NonRenamableLocal = isNonRenamableLocal(A);
+GlobalValueSummary::GVFlags Flags(
+A.getLinkage(), A.getVisibility(), NonRenamableLocal,
+/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
+auto AS = std::make_unique(Flags);
+auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
+assert(AliaseeVI && "Alias expects aliasee summary to be available");
+assert(AliaseeVI.getSummaryList().size() == 1 &&
+   "Expected a single entry per aliasee in per-module index");
+AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
+if (NonRenamableLocal)
+  CantBePromoted.insert(A.getGUID());
+Index.addGlobalValueSummary(A, std::move(AS));
+  }
 }
 
 // Set LiveRoot flag on entries matching the given value name.
Index: clang/test/Analysis/alias-indirect-function-lto.c
===
--- /dev/null
+++ clang/test/Analysis/alias-indirect-function-lto.c
@@ -0,0 +1,5 @@
+// RUN: %clang_analyze_cc1 -flto %s
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
+// no crash
\ No newline at end of file


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,23 +646,26 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
-  bool NonRenamableLocal = isNonRenamableLocal(A);
-  GlobalValueSummary::GVFlags 

[PATCH] D128511: [clang-tidy] Make the cert/uppercase-literal-suffix-integer fully hermetic.

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/integral_constant.h:1
+#ifndef _INTEGRAL_CONSTANT_H_
+#define _INTEGRAL_CONSTANT_H_

Identifiers beginning with `_` followed by an uppercase letter are [[ 
https://en.cppreference.com/w/cpp/language/identifiers | reserved for the 
implementation ]].

Include guards should never include double underscores or begin with an 
underscore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128511

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


[PATCH] D119296: KCFI sanitizer

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Target/X86/X86AsmPrinter.cpp:125
+
+  // Emit int3 padding to allow runtime patching of the preamble.
+  EmitAndCountInstruction(MCInstBuilder(X86::INT3));

A previous comment isn't done. This doesn't explain that the double-int3 before 
and after the identifier is an objtool requirement (or similar).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D128754: [llvm] Remove unused and redundant crc32 funcction from llvm::compression::zlib namespace

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

Thanks!




Comment at: llvm/lib/Support/Compression.cpp:25
 using namespace llvm;
 
 using namespace llvm::compression;

if a previous patch introduces a blank line between two `using`. please drop it 
from the previous patch.



Comment at: llvm/unittests/Support/CompressionTest.cpp:21
 using namespace llvm;
 
 using namespace llvm::compression;

if a previous patch introduces a blank line between two using. please drop it 
from the previous patch.


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

https://reviews.llvm.org/D128754

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


[PATCH] D119296: KCFI sanitizer

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.h:1434
+
+  /// Emit KCFI type identifier constants and remove unused identifiers
+  void FinalizeKCFITypes();

End with a period.

This function can be lower-case as well. There is no strong precedent to keep 
it upper-case.



Comment at: clang/lib/Driver/SanitizerArgs.cpp:63
 SanitizerKind::Unreachable | SanitizerKind::Return;
-static const SanitizerMask AlwaysRecoverable =
-SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress;
+static const SanitizerMask AlwaysRecoverable = SanitizerKind::KernelAddress |
+   SanitizerKind::KernelHWAddress |

This is incorrect.

If a violation is found, ud2 is executed. ud2 is not followed by normal control 
flow so I don't think recovery from the error is supported.

This seems like `Unrecoverable`



Comment at: clang/test/CodeGen/kcfi.c:2
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi 
-o - %s | FileCheck --check-prefixes=CHECK,O0 %s
+// RUN: %clang_cc1 -O2 -triple x86_64-unknown-linux-gnu -emit-llvm 
-fsanitize=kcfi -o - %s | FileCheck --check-prefixes=CHECK,O2 %s
+#if !__has_feature(kcfi)

MaskRay wrote:
> If `-O2` has different behavior, having the test in clang/test/CodeGen is 
> likely a layering violation.
> Optimization tests should be placed in llvm/test/, in the relevant pass. 
> Folks working on llvm optimizations generally don't want to test every 
> frontend.
If may be useful to have a `-x c++` test.

Add a not-address-taken external linkage function.



Comment at: clang/test/CodeGen/kcfi.c:7
+
+// COM: Must emit __kcfi_typeid symbols for address-taken function declarations
+// CHECK: module asm ".weak __kcfi_typeid_f4"

Optional: `COM:` is fine. But to make non-RUN non-CHECK lines stand out (from 
editor highlighting), a simpler `/// ` suffices as well.



Comment at: llvm/docs/LangRef.rst:7222
+functions that can be called indirectly. The type data is emitted before the
+function entry. Indirect calls with the :ref:`kcfi operand bundle`
+will emit a check that compares the type identifier to the metadata.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D129014: rewording static_assert to more generic static assertion

2022-07-01 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman created this revision.
Herald added a project: All.
Codesbyusman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129014

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -2,47 +2,47 @@
 
 int f(); // expected-note {{declared here}}
 
-static_assert(f(), "f"); // expected-error {{static_assert expression is not an integral constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
+static_assert(f(), "f"); // expected-error {{static assertion expression is not an integral constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
 static_assert(true, "true is not false");
-static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+static_assert(false, "false is false"); // expected-error {{static assertion failed "false is false"}}
 
 void g() {
-static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+static_assert(false, "false is false"); // expected-error {{static assertion failed "false is false"}}
 }
 
 class C {
-static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+static_assert(false, "false is false"); // expected-error {{static assertion failed "false is false"}}
 };
 
 template struct T {
-static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed due to requirement '1 == 2' "N is not 2!"}}
+static_assert(N == 2, "N is not 2!"); // expected-error {{static assertion failed due to requirement '1 == 2' "N is not 2!"}}
 };
 
 T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
 T<2> t2;
 
 template struct S {
-static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed due to requirement 'sizeof(char) > sizeof(char)' "Type not big enough!"}}
+static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static assertion failed due to requirement 'sizeof(char) > sizeof(char)' "Type not big enough!"}}
 };
 
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{static_assert failed L"\x"}}
-static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u"\U000317FF"}}
+static_assert(false, L"\x"); // expected-error {{static assertion failed L"\x"}}
+static_assert(false, u"\U000317FF"); // expected-error {{static assertion failed u"\U000317FF"}}
 // FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}}
-static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}}
-static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFgoop"}}
+static_assert(false, u8"Ω"); // expected-error {{static assertion failed u8"\316\251"}}
+static_assert(false, L"\u1234"); // expected-error {{static assertion failed L"\x1234"}}
+static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{static assertion failed L"\x1FF""0\x123""fx\xFgoop"}}
 
 template struct AlwaysFails {
   // Only give one error here.
-  static_assert(false, ""); // expected-error {{static_assert failed}}
+  static_assert(false, ""); // expected-error {{static assertion failed}}
 };
 AlwaysFails alwaysFails;
 
 template struct StaticAssertProtected {
-  static_assert(__is_literal(T), ""); // expected-error {{static_assert failed}}
+  static_assert(__is_literal(T), ""); // expected-error {{static assertion failed}}
   static constexpr T t = {}; // no error here
 };
 struct X { ~X(); };
@@ -67,7 +67,7 @@
   static const bool value = false;
 };
 
-static_assert(first_trait::value && second_trait::value, "message"); // expected-error{{static_assert failed due to requirement 'second_trait::value' "message"}}
+static_assert(first_trait::value && second_trait::value, "message"); // expected-error{{static assertion failed due to requirement 'second_trait::value' "message"}}
 
 namespace std {
 
@@ -111,29 +111,29 @@
 };
 
 static_assert(std::is_same::value, "message");
-// expected-error@-1{{static_assert failed due to requirement 'std::is_same::value' "message"}}
+// expected-error@-1{{static assertion failed due to requirement 'std::is_same::value' "message"}}
 static_assert(std::is_const::value, "message");
-// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value' 

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-07-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Crash that required the revert : 
https://reviews.llvm.org/rGbefa8cf087dbb8159a4d9dc8fa4d6748d6d5049a

reduces to :

   template
   concept sentinel_for =
 requires(_Ip __i) {
   __i++;
 };
  
   template
   concept bidirectional_iterator =
 sentinel_for<_Ip>;
  
   
  template 
  class move_iterator
  {
  public:
  auto operator++(int)
  requires
  sentinel_for<_Iter>;
  };
   
  static_assert( bidirectional_iterator>);

In other news, I discovered that 'check-all' and 'stage2-check-all' doesn't 
include 'check-runtimes', which managed to be why I missed this :/

I won't have time to poke that this until Tuesday since Monday is a US holiday 
and I'm done for the day, so if @ChuanqiXu or others wish to mess with this, 
feel free, otherwise I'll get back on it next week!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-07-01 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.

I'd say land this, but keep a close eye on the build bots as it may need 
reverting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127807

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


[PATCH] D119296: KCFI sanitizer

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2280
+void CodeGenModule::setKCFIType(const FunctionDecl *FD, llvm::Function *F) {
+
+  if (isa(FD) && !cast(FD)->isStatic())

delete blank line



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2286
+  llvm::MDBuilder MDB(Ctx);
+
+  F->setMetadata(llvm::LLVMContext::MD_kcfi_type,

delete blank line



Comment at: clang/test/CodeGen/kcfi.c:2
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi 
-o - %s | FileCheck --check-prefixes=CHECK,O0 %s
+// RUN: %clang_cc1 -O2 -triple x86_64-unknown-linux-gnu -emit-llvm 
-fsanitize=kcfi -o - %s | FileCheck --check-prefixes=CHECK,O2 %s
+#if !__has_feature(kcfi)

If `-O2` has different behavior, having the test in clang/test/CodeGen is 
likely a layering violation.
Optimization tests should be placed in llvm/test/, in the relevant pass. Folks 
working on llvm optimizations generally don't want to test every frontend.



Comment at: clang/test/Driver/fsanitize.c:652
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=kcfi -fsanitize=cfi -flto 
-fvisibility=hidden %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-KCFI-NOCFI
+// CHECK-KCFI-NOCFI: error: invalid argument '-fsanitize=kcfi' not allowed 
with '-fsanitize=cfi'

Use modern spelling `--target=`. `-target ` is deprecated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D113107: Support of expression granularity for _Float16.

2022-07-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think you should also at least support promoted arithmetic through the 
`_Real` and `_Imag` scalar operators before calling this complete.  That should 
be simple — just a matter of calling EmitPromotedComplexExpr from the scalar 
path.




Comment at: clang/lib/CodeGen/CGExprComplex.cpp:1005
+  QualType PromotionTypeRHS = getPromotionType(E->getRHS());
+  QualType PromotionTypeLHS =getPromotionType(E->getLHS());
+  QualType PromotionTypeCR;

whitespace



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3130
+  PromotionTypeCR = CGF.getContext().FloatTy;
+  }
+  QualType PromotionTypeLHS = getPromotionType(E->getLHS());

Please don't duplicate this computation of the promotion type.  This is just 
`getPromotionType` except you want something guaranteed non-null so you fall 
back to the normal computation result type.

You'll need to make `getPromotionType` take a type instead of an expression, 
but that's a good idea anyway.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3131
+  }
+  QualType PromotionTypeLHS = getPromotionType(E->getLHS());
+  QualType PromotionTypeRHS = getPromotionType(E->getRHS());

The difference between `getComputationLHSType()` and `E->getLHS()->getType())` 
is important here.  This needs to use `getComputationLHSType()`.

In a compound assignment, the value loaded from the LHS has to be promoted to 
the appropriate type for the computation.  The type it should be promoted to is 
the computation LHS type.  For promotion, this matters when you have something 
like `myInt *= myFloat16`; the LHS type will be `int`, but the  computation LHS 
type will be `_Float16`.  In this mode, you need to be promoting the LHS to 
`float` before evaluating the `*` operator.

You also have this wrong in the complex emitter.  These things get even more 
subtle in the complex emitter because IIRC in the scalar cases the computation 
LHS type is always equal to the computation result type, but in the complex 
cases it can still be scalar, if you do something like `myFloat *= myComplex`.


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

https://reviews.llvm.org/D113107

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


[PATCH] D119296: KCFI sanitizer

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

There are 30+ comments not marked as "done". Having so many is distracting to 
reviewers as it's unclear whether this is in a ready-for-review state.




Comment at: clang/include/clang/Basic/Features.def:233
 FEATURE(modules, LangOpts.Modules)
+FEATURE(kcfi, LangOpts.Sanitize.has(SanitizerKind::KCFI))
 FEATURE(safe_stack, LangOpts.Sanitize.has(SanitizerKind::SafeStack))

move before `modules` for an alphabetical order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D119296: KCFI sanitizer

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> It uses LLVM prefix data to store a type identifier for each function and 
> injects verification code before indirect calls.

Is "prefix data" stale now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D115844: [ubsan] Using metadata instead of prologue data for function sanitizer

2022-07-01 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D115844#3625781 , @ychen wrote:

> In D115844#3625776 , @vitalybuka 
> wrote:
>
>> @ychen  This patch causes 20% .o size increase (x86_64)  Is this expected?
>
> No, it is not expected.  Do you have a test case? I'll take a look.

Sure, I'll create reproducer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115844

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


[PATCH] D115844: [ubsan] Using metadata instead of prologue data for function sanitizer

2022-07-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D115844#3625776 , @vitalybuka 
wrote:

> @ychen  This patch causes 20% .o size increase (x86_64)  Is this expected?

No, it is not expected.  Do you have a test case? I'll take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115844

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


[clang-tools-extra] bbcd8e5 - [pseudo] NFC, polish the fix of c99827349927a44334f2b04139168efd0bc87cd3

2022-07-01 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-07-01T21:25:46+02:00
New Revision: bbcd8e5271f4af3adc28e458642a0dc65d253acd

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

LOG: [pseudo] NFC, polish the fix of c99827349927a44334f2b04139168efd0bc87cd3

Added: 


Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
index 664a1a3206fe6..d480956704960 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
@@ -140,11 +140,9 @@ class LRTable {
   // // ...apply reduce...
   //   }
   llvm::ArrayRef getReduceRules(StateID State) const {
-if (ReduceOffset[State] >= Reduces.size())
-  return {};
-size_t Length = ReduceOffset[State + 1] - ReduceOffset[State];
-return llvm::makeArrayRef([ReduceOffset[State]],
-  Length);
+assert(State + 1u < ReduceOffset.size());
+return llvm::makeArrayRef(Reduces.data() + ReduceOffset[State],
+  Reduces.data() + ReduceOffset[State+1]);
   }
   // Returns whether Terminal can follow Nonterminal in a valid source file.
   bool canFollow(SymbolID Nonterminal, SymbolID Terminal) const {



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


[PATCH] D115844: [ubsan] Using metadata instead of prologue data for function sanitizer

2022-07-01 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

@ychen  This patch causes 20% .o size increase (x86_64)  Is this expected?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115844

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


[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-07-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127803

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


[PATCH] D128754: [llvm] Refactor LLVM compression namespaces (Part 1: remove crc32)

2022-07-01 Thread Cole Kissane via Phabricator via cfe-commits
ckissane updated this revision to Diff 441770.
ckissane added a comment.

updated diff


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

https://reviews.llvm.org/D128754

Files:
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compression.h
  llvm/lib/Support/Compression.cpp
  llvm/unittests/Support/CompressionTest.cpp


Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -64,12 +64,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -84,10 +84,6 @@
   return E;
 }
 
-uint32_t zlib::crc32(StringRef Buffer) {
-  return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
-}
-
 #else
 bool zlib::isAvailable() { return false; }
 void zlib::compress(StringRef InputBuffer,
@@ -103,7 +99,4 @@
size_t UncompressedSize) {
   llvm_unreachable("zlib::uncompress is unavailable");
 }
-uint32_t zlib::crc32(StringRef Buffer) {
-  llvm_unreachable("zlib::crc32 is unavailable");
-}
 #endif
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -42,8 +42,6 @@
  SmallVectorImpl ,
  size_t UncompressedSize);
 
-uint32_t crc32(StringRef Buffer);
-
 } // End of namespace zlib
 
 } // End of namespace compression
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -184,6 +184,7 @@
   introduction of alternatives to zlib compression in the llvm toolchain.
   Changes are as follows:
   * Relocate the ``llvm::zlib`` namespace to ``llvm::compression::zlib``.
+  * Remove crc32 from zlib compression namespace, people should use the 
``llvm::crc32`` instead.
 
 Changes to the Go bindings
 --


Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -64,12 +64,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -84,10 +84,6 @@
   return E;
 }
 
-uint32_t zlib::crc32(StringRef Buffer) {
-  return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
-}
-
 #else
 bool zlib::isAvailable() { return false; }
 void zlib::compress(StringRef InputBuffer,
@@ -103,7 +99,4 @@
size_t UncompressedSize) {
   llvm_unreachable("zlib::uncompress is unavailable");
 }
-uint32_t zlib::crc32(StringRef Buffer) {
-  llvm_unreachable("zlib::crc32 is unavailable");
-}
 #endif
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -42,8 +42,6 @@
  SmallVectorImpl ,
  size_t UncompressedSize);
 
-uint32_t crc32(StringRef Buffer);
-
 } // End of namespace zlib
 
 } // End of namespace compression
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -184,6 +184,7 @@
   introduction of alternatives to zlib compression in the llvm toolchain.
   Changes are as follows:
   * Relocate the ``llvm::zlib`` namespace to ``llvm::compression::zlib``.
+  * Remove crc32 from zlib compression namespace, people should use the ``llvm::crc32`` instead.
 
 Changes to the Go bindings
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128754: [llvm] Refactor LLVM compression namespaces (Part 1: remove crc32)

2022-07-01 Thread Cole Kissane via Phabricator via cfe-commits
ckissane marked 3 inline comments as done.
ckissane added a comment.

addressed comments marked done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128754

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


[PATCH] D128012: [HLSL] Add ExternalSemaSource & vector alias

2022-07-01 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov accepted this revision.
mizvekov added a comment.
This revision is now accepted and ready to land.

This looks reasonable, LGTM for what it's worth :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128012

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


[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-07-01 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 441765.
jyu2 added a comment.

Thank Alexey for the review.  This is remove check for omp region just use 
hasDSA.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127803

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/OpenMP/default_firstprivate_ast_print.cpp
  clang/test/OpenMP/default_private_ast_print.cpp

Index: clang/test/OpenMP/default_private_ast_print.cpp
===
--- clang/test/OpenMP/default_private_ast_print.cpp
+++ clang/test/OpenMP/default_private_ast_print.cpp
@@ -96,4 +96,57 @@
   // DUMP-NEXT:  -DeclRefExpr {{.*}} 'a'
   // DUMP-NEXT:  -DeclRefExpr {{.*}} 'yy'
 }
+
+void zoo(int);
+struct A {
+  int z;
+  int f;
+  A();
+  ~A();
+  void foo() {
+#pragma omp parallel private(z) default(private)
+{
+  z++;
+  f++;
+  zoo(z + f);
+  f++;
+}
+  }
+  // PRINT:#pragma omp parallel private(this->z) default(private)
+  // DUMP: -OMPParallelDirective
+  // DUMP-NEXT:  -OMPPrivateClause
+  // DUMP-NEXT:-DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:  -OMPDefaultClause
+  // DUMP-NEXT:  -OMPPrivateClause
+  // DUMP-NEXT:-DeclRefExpr {{.*}} 'f'
+  // DUMP: -CXXThisExpr {{.*}} 'A *' implicit this
+  void bar() {
+#pragma omp parallel private(z) default(private)
+{
+#pragma omp parallel private(z) default(private)
+  {
+z++;
+f++;
+zoo(z + f);
+f++;
+  }
+}
+  }
+  // PRINT:#pragma omp parallel private(this->z) default(private)
+  // PRINT:  #pragma omp parallel private(this->z) default(private)
+  // DUMP: -OMPParallelDirective
+  // DUMP-NEXT:  -OMPPrivateClause
+  // DUMP-NEXT:-DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:  -OMPDefaultClause
+  // DUMP:   -OMPParallelDirective
+  // DUMP-NEXT:-OMPPrivateClause
+  // DUMP-NEXT:   -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:-OMPDefaultClause
+  // DUMP-NEXT:-OMPPrivateClause {{.*}} 
+  // DUMP-NEXT:   -DeclRefExpr {{.*}} 'f'
+  // DUMP: -CXXThisExpr
+  // DUMP: -MemberExpr
+  // DUMP-NEXT:   -CXXThisExpr
+  // DUMP: -CXXThisExpr
+};
 #endif // HEADER
Index: clang/test/OpenMP/default_firstprivate_ast_print.cpp
===
--- clang/test/OpenMP/default_firstprivate_ast_print.cpp
+++ clang/test/OpenMP/default_firstprivate_ast_print.cpp
@@ -38,22 +38,31 @@
   void apply() {
 #pragma omp parallel default(firstprivate)
 {
-  targetDev++;
+  [=]() -> int {
+return targetDev++;
+  }();
 }
 // PRINT: #pragma omp parallel default(firstprivate)
 // PRINT-NEXT: {
-// PRINT-NEXT:  this->targetDev++;
-// CHECK-NEXT: }
+// PRINT-NEXT:  [=]() -> int {
+// PRINT-NEXT: return this->targetDev++;
+// PRINT-NEXT:  }();
+// PRINT-NEXT: }
 // DUMP: -OMPParallelDirective
-// DUMP->NEXT: -OMPDefaultClause
+// DUMP-NEXT: -OMPDefaultClause
+// DUMP-NOT:   -OMPFirstprivateClause
   }
   // PRINT: template<> void apply<32U>()
   // PRINT: #pragma omp parallel default(firstprivate)
   // PRINT-NEXT: {
-  // PRINT-NEXT:  this->targetDev++;
+  // PRINT-NEXT:  [=]() -> int {
+  // PRINT-NEXT: return this->targetDev++;
+  // PRINT-NEXT:  }();
   // CHECK-NEXT: }
   // DUMP: -OMPParallelDirective
   // DUMP-NEXT: -OMPDefaultClause
+  // DUMP-NEXT: -OMPFirstprivateClause
+  // DUMP-NEXT:   -DeclRefExpr {{.*}} 'targetDev'
 };
 
 void use_template() {
@@ -99,4 +108,60 @@
   // DUMP-NEXT: -DeclRefExpr {{.*}} 'yy'
   // DUMP-NEXT: -DeclRefExpr {{.*}} 'y'
 }
+void zoo(int);
+struct A {
+  int z;
+  int f;
+  A();
+  ~A();
+  void foo() {
+#pragma omp parallel firstprivate(z) default(firstprivate)
+{
+  z++;
+  f++;
+  zoo(z + f);
+  f++;
+}
+  }
+  // PRINT:  #pragma omp parallel firstprivate(this->z) default(firstprivate)
+  // DUMP:   -OMPParallelDirective
+  // DUMP-NEXT: -OMPFirstprivateClause
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT: -OMPDefaultClause
+  // DUMP-NEXT: -OMPFirstprivateClause {{.*}} 
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
+  // DUMP:  -CXXThisExpr {{.*}} 'A *' implicit this
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
+  void bar() {
+#pragma omp parallel firstprivate(z) default(firstprivate)
+{
+#pragma omp parallel private(z) default(firstprivate)
+  {
+z++;
+f++;
+zoo(z + f);
+f++;
+  }
+}
+  }
+  // PRINT:  #pragma omp parallel firstprivate(this->z) default(firstprivate)
+  // PRINT:#pragma omp parallel private(this->z) default(firstprivate)
+  // DUMP: -OMPParallelDirective
+  // DUMP-NEXT: -OMPFirstprivateClause
+  // DUMP-NEXT:  -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:  

[PATCH] D128953: [NFC] Refactor llvm::zlib namespace

2022-07-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM


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

https://reviews.llvm.org/D128953

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


[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-07-01 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2273-2274
+bool Sema::isOpenMPRebuildMemberExpr(ValueDecl *D) {
+  if (getCurCapturedRegion() &&
+  getCurCapturedRegion()->CapRegionKind == CR_OpenMP) {
+DSAStackTy::DSAVarData DVarPrivate = DSAStack->hasDSA(

ABataev wrote:
> jyu2 wrote:
> > ABataev wrote:
> > > What if we have another outer OpenMP region, something like lambda inside 
> > > OpenMP region?
> > My understanding is that hasDSA will go up to find innermost openmp region 
> > which has default clause.  Am I right here?
> Yes, if you're immediate captured region is OpenMP region. But what if you're 
> inside lambda, which is inside OpenMP region? In this case 
> getCurCapturedRegion()->CapRegionKind != CR_OpenMP. Will it still work, could 
> add a test for this situation?
Good catch!!  Thank you so much!!  You are right.  I removed check for 
CR_OpenMP.  Just let hasDSA to find out.  And add test for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127803

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


[PATCH] D128953: [NFC] Refactor llvm::zlib namespace

2022-07-01 Thread Cole Kissane via Phabricator via cfe-commits
ckissane marked 2 inline comments as done.
ckissane added a comment.

comments addressed


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

https://reviews.llvm.org/D128953

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


[PATCH] D128953: [NFC] Refactor llvm::zlib namespace

2022-07-01 Thread Cole Kissane via Phabricator via cfe-commits
ckissane updated this revision to Diff 441763.
ckissane edited the summary of this revision.
ckissane added a comment.

remove compression namespace alias work


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

https://reviews.llvm.org/D128953

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  lld/ELF/Driver.cpp
  lld/ELF/InputSection.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compression.h
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/lib/Object/Decompressor.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/Compression.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/ProfileData/InstrProfTest.cpp
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -19,6 +19,8 @@
 
 using namespace llvm;
 
+using namespace llvm::compression;
+
 namespace {
 
 #if LLVM_ENABLE_ZLIB
Index: llvm/unittests/ProfileData/InstrProfTest.cpp
===
--- llvm/unittests/ProfileData/InstrProfTest.cpp
+++ llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -1147,14 +1147,16 @@
 // Compressing:
 std::string FuncNameStrings1;
 EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames1, (DoCompression && zlib::isAvailable()),
+  FuncNames1,
+  (DoCompression && compression::zlib::isAvailable()),
   FuncNameStrings1),
   Succeeded());
 
 // Compressing:
 std::string FuncNameStrings2;
 EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames2, (DoCompression && zlib::isAvailable()),
+  FuncNames2,
+  (DoCompression && compression::zlib::isAvailable()),
   FuncNameStrings2),
   Succeeded());
 
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -739,7 +739,7 @@
 .str()
 .c_str());
 }
-if (!zlib::isAvailable())
+if (!compression::zlib::isAvailable())
   return createStringError(
   errc::invalid_argument,
   "LLVM was not compiled with LLVM_ENABLE_ZLIB: can not compress");
@@ -998,7 +998,7 @@
 "--decompress-debug-sections");
   }
 
-  if (Config.DecompressDebugSections && !zlib::isAvailable())
+  if (Config.DecompressDebugSections && !compression::zlib::isAvailable())
 return createStringError(
 errc::invalid_argument,
 "LLVM was not compiled with LLVM_ENABLE_ZLIB: cannot decompress");
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -403,7 +403,7 @@
   MAI->setRelaxELFRelocations(RelaxELFRel);
 
   if (CompressDebugSections != DebugCompressionType::None) {
-if (!zlib::isAvailable()) {
+if (!compression::zlib::isAvailable()) {
   WithColor::error(errs(), ProgName)
   << "build tools with zlib to enable -compress-debug-sections";
   return 1;
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -23,10 +23,9 @@
 
 using namespace llvm;
 
+using namespace llvm::compression;
+
 #if LLVM_ENABLE_ZLIB
-static Error createError(StringRef Err) {
-  return make_error(Err, inconvertibleErrorCode());
-}
 
 static StringRef convertZlibCodeToString(int Code) {
   switch (Code) {
@@ -70,15 +69,17 @@
   // Tell MemorySanitizer that zlib output buffer is fully initialized.
   // This avoids a false report when running LLVM with uninstrumented ZLib.
   __msan_unpoison(UncompressedBuffer, UncompressedSize);
-  return Res ? createError(convertZlibCodeToString(Res)) : Error::success();
+  return Res ? make_error(convertZlibCodeToString(Res),
+   inconvertibleErrorCode())
+ : Error::success();
 }
 
 Error zlib::uncompress(StringRef InputBuffer,
SmallVectorImpl ,
size_t UncompressedSize) {
   

[PATCH] D128953: [NFC] Refactor llvm::zlib namespace

2022-07-01 Thread Cole Kissane via Phabricator via cfe-commits
ckissane updated this revision to Diff 441757.
ckissane added a comment.

discard debug string changes


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

https://reviews.llvm.org/D128953

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  lld/ELF/Driver.cpp
  lld/ELF/InputSection.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compression.h
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/lib/Object/Decompressor.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/Compression.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/ProfileData/InstrProfTest.cpp
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -19,6 +19,8 @@
 
 using namespace llvm;
 
+using namespace llvm::compression;
+
 namespace {
 
 #if LLVM_ENABLE_ZLIB
Index: llvm/unittests/ProfileData/InstrProfTest.cpp
===
--- llvm/unittests/ProfileData/InstrProfTest.cpp
+++ llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -1146,17 +1146,19 @@
   for (bool DoCompression : {false, true}) {
 // Compressing:
 std::string FuncNameStrings1;
-EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames1, (DoCompression && zlib::isAvailable()),
-  FuncNameStrings1),
-  Succeeded());
+EXPECT_THAT_ERROR(
+collectPGOFuncNameStrings(
+FuncNames1, (DoCompression && compression::profile::isAvailable()),
+FuncNameStrings1),
+Succeeded());
 
 // Compressing:
 std::string FuncNameStrings2;
-EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames2, (DoCompression && zlib::isAvailable()),
-  FuncNameStrings2),
-  Succeeded());
+EXPECT_THAT_ERROR(
+collectPGOFuncNameStrings(
+FuncNames2, (DoCompression && compression::profile::isAvailable()),
+FuncNameStrings2),
+Succeeded());
 
 for (int Padding = 0; Padding < 2; Padding++) {
   // Join with paddings :
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -739,7 +739,7 @@
 .str()
 .c_str());
 }
-if (!zlib::isAvailable())
+if (!compression::zlib::isAvailable())
   return createStringError(
   errc::invalid_argument,
   "LLVM was not compiled with LLVM_ENABLE_ZLIB: can not compress");
@@ -998,7 +998,7 @@
 "--decompress-debug-sections");
   }
 
-  if (Config.DecompressDebugSections && !zlib::isAvailable())
+  if (Config.DecompressDebugSections && !compression::zlib::isAvailable())
 return createStringError(
 errc::invalid_argument,
 "LLVM was not compiled with LLVM_ENABLE_ZLIB: cannot decompress");
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -403,7 +403,7 @@
   MAI->setRelaxELFRelocations(RelaxELFRel);
 
   if (CompressDebugSections != DebugCompressionType::None) {
-if (!zlib::isAvailable()) {
+if (!compression::zlib::isAvailable()) {
   WithColor::error(errs(), ProgName)
   << "build tools with zlib to enable -compress-debug-sections";
   return 1;
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -23,10 +23,9 @@
 
 using namespace llvm;
 
+using namespace llvm::compression;
+
 #if LLVM_ENABLE_ZLIB
-static Error createError(StringRef Err) {
-  return make_error(Err, inconvertibleErrorCode());
-}
 
 static StringRef convertZlibCodeToString(int Code) {
   switch (Code) {
@@ -70,15 +69,17 @@
   // Tell MemorySanitizer that zlib output buffer is fully initialized.
   // This avoids a false report when running LLVM with uninstrumented ZLib.
   __msan_unpoison(UncompressedBuffer, UncompressedSize);
-  return Res ? createError(convertZlibCodeToString(Res)) : Error::success();
+  return Res ? make_error(convertZlibCodeToString(Res),
+   

[PATCH] D128012: [HLSL] Add ExternalSemaSource & vector alias

2022-07-01 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 441759.
beanz added a comment.

Updates based on review feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128012

Files:
  clang/include/clang/Sema/HLSLExternalSemaSource.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Headers/hlsl/hlsl_basic_types.h
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/test/AST/HLSL/vector-alias.hlsl

Index: clang/test/AST/HLSL/vector-alias.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/vector-alias.hlsl
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s 
+
+// CHECK: NamespaceDecl 0x{{[0-9a-fA-F]+}} <>  implicit hlsl
+// CHECK-NEXT: TypeAliasTemplateDecl 0x{{[0-9a-fA-F]+}} <>  implicit vector
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9a-fA-F]+}} <>  class depth 0 index 0 element
+// CHECK-NEXT: TemplateArgument type 'float'
+// CHECK-NEXT: BuiltinType 0x{{[0-9a-fA-F]+}} 'float'
+// CHECK-NEXT: NonTypeTemplateParmDecl 0x{{[0-9a-fA-F]+}} <>  'int' depth 0 index 1 element_count
+// CHECK-NEXT: TemplateArgument expr
+// CHECK-NEXT: IntegerLiteral 0x{{[0-9a-fA-F]+}} <> 'int' 4
+// CHECK-NEXT: TypeAliasDecl 0x{{[0-9a-fA-F]+}} <>  implicit vector 'element __attribute__((ext_vector_type(element_count)))'
+// CHECK-NEXT: DependentSizedExtVectorType 0x{{[0-9a-fA-F]+}} 'element __attribute__((ext_vector_type(element_count)))' dependent 
+// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9a-fA-F]+}} 'element' dependent depth 0 index 0
+// CHECK-NEXT: TemplateTypeParm 0x{{[0-9a-fA-F]+}} 'element'
+// CHECK-NEXT: DeclRefExpr 0x{{[0-9a-fA-F]+}} <> 'int' lvalue
+// NonTypeTemplateParm 0x{{[0-9a-fA-F]+}} 'element_count' 'int'
+
+// Make sure we got a using directive at the end.
+// CHECK: UsingDirectiveDecl 0x{{[0-9a-fA-F]+}} <>  Namespace 0x{{[0-9a-fA-F]+}} 'hlsl'
+
+[numthreads(1,1,1)]
+int entry() {
+  // Verify that the alias is generated inside the hlsl namespace.
+  hlsl::vector Vec2 = {1.0, 2.0};
+
+  // CHECK: DeclStmt 0x{{[0-9a-fA-F]+}} 
+  // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}}  col:26 Vec2 'hlsl::vector':'float __attribute__((ext_vector_type(2)))' cinit
+
+  // Verify that you don't need to specify the namespace.
+  vector Vec2a = {1, 2};
+
+  // CHECK: DeclStmt 0x{{[0-9a-fA-F]+}} 
+  // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}}  col:18 Vec2a 'vector':'int __attribute__((ext_vector_type(2)))' cinit
+
+  // Build a bigger vector.
+  vector Vec4 = {1.0, 2.0, 3.0, 4.0};
+
+  // CHECK: DeclStmt 0x{{[0-9a-fA-F]+}} 
+  // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}}  col:21 used Vec4 'vector':'double __attribute__((ext_vector_type(4)))' cinit
+
+  // Verify that swizzles still work.
+  vector Vec3 = Vec4.xyz;
+
+  // CHECK: DeclStmt 0x{{[0-9a-fA-F]+}} 
+  // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}}  col:21 Vec3 'vector':'double __attribute__((ext_vector_type(3)))' cinit
+
+  // Verify that the implicit arguments generate the correct type.
+  vector<> ImpVec4 = {1.0, 2.0, 3.0, 4.0};
+
+  // CHECK: DeclStmt 0x{{[0-9a-fA-F]+}} 
+  // CHECK-NEXT: VarDecl 0x{{[0-9a-fA-F]+}}  col:12 ImpVec4 'vector<>':'float __attribute__((ext_vector_type(4)))' cinit
+  return 1;
+}
Index: clang/lib/Sema/HLSLExternalSemaSource.cpp
===
--- /dev/null
+++ clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -0,0 +1,98 @@
+//===--- HLSLExternalSemaSource.cpp - HLSL Sema Source ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//
+//===--===//
+
+#include "clang/Sema/HLSLExternalSemaSource.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/Basic/AttrKinds.h"
+#include "clang/Sema/Sema.h"
+
+using namespace clang;
+
+char HLSLExternalSemaSource::ID;
+
+HLSLExternalSemaSource::~HLSLExternalSemaSource() {}
+
+void HLSLExternalSemaSource::InitializeSema(Sema ) {
+  SemaPtr = 
+  ASTContext  = SemaPtr->getASTContext();
+  IdentifierInfo  = AST.Idents.get("hlsl", tok::TokenKind::identifier);
+  HLSLNamespace =
+  NamespaceDecl::Create(AST, AST.getTranslationUnitDecl(), false,
+SourceLocation(), SourceLocation(), , nullptr);
+  HLSLNamespace->setImplicit(true);
+  AST.getTranslationUnitDecl()->addDecl(HLSLNamespace);
+  defineHLSLVectorAlias();
+
+  // This adds a `using namespace hlsl` directive. In DXC, we don't put HLSL's
+  // built in types inside a namespace, but we are planning to change that in
+  // the near future. In order to be source compatible older versions of HLSL

[PATCH] D128807: [clang][transformer] Finish plumbing `Note` all the way to the output.

2022-07-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

> For my particular case, I just need multiple notes per rule. I don't need 
> them to be associated to a particular edit (and in that very particular case, 
> I don't even need a source location).

I'm not sure I understand: you need this additional note, but it doesn't need 
to be tied to a source location, so, why can't you concatenate it to the main 
note?

> In terms of the overall design requirements, non-`transformer` checks can 
> have multiple notes per rule, associated to a source location (and multiple 
> checks are using the note location to point to somewhere else in the code, so 
> that is a required feature if we want to be as powerful as the original 
> clang-tidies, which I think we do).

Yes, that's the goal, essentially. And the `Note` field came from exactly that 
observation.

> Notes cannot be associated to a particular `FixitHint`, and I'm not sure 
> whether that's useful.

Right. I'm not sure about that. It seems more intuitive for the note to be 
bundled with the associated `FixitHint` in the same `DiagnosticBuilder`. That 
is, if we want to (mostly) go with this design, I would think we'd create a 
separate diagnostic per note or somesuch.

Overall, I'm fine with adding support for additional notes, but I want to get 
these details sorted out first, since they subtly change the API.

> I  went with the design in this patch (notes associated to edits) because:
>
> - it looked like associating a note with an `ASTEdit` was the original 
> intent, given that `ASTEdit` already had a `Note` field.
> - we can plumb notes inside `Metadata`, but `Metadata` is already used for 
> the warning, so that looks a bit more involved.
>
> No strong opinion on that front though :)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128807

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


[PATCH] D128158: [AMDGPU] Add amdgcn_sched_group_barrier builtin

2022-07-01 Thread Jeffrey Byrnes via Phabricator via cfe-commits
jrbyrnes added a comment.

Hey Austin -- I like the removal of canAddMIs. In the original design, I was 
leaving open the possibility for users to pass in canAddMIs rather than a mask 
/ SchedGroup name, but it looks like this isn't the direction we're going, and 
the classification functions defined in a general canAddMI makes things easier.

I see this is a WIP, but I've added some thoughts I had from reading it over. I 
may have more as I use the design for my patch.




Comment at: llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp:199
+  // SchedGroupMask of instructions that should be barred.
+  SchedGroupMask invertSchedBarrierMask(SchedGroupMask Mask) const;
+

I find it confusing that SchedBarrier uses inversion while SchedGroupBarrier 
doesn't.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp:306
+bool SchedGroup::isFull() const {
+  return MaxSize.hasValue() && Collection.size() >= *MaxSize;
+}

As in the update to IGroupLP.cpp in trunk, seems like we are not supposed to 
use hasValue.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp:349
+  add(InitSU);
+  assert(MaxSize.hasValue());
+  (*MaxSize)++;

Not possible to have unsized groups?



Comment at: llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp:445
+  // initialized all of the SCHED_GROUP_BARRIER SchedGroups.
+  addSchedGroupBarrierEdges();
 }

If both types of barriers are present -- the SchedBarriers are handled first. 
However, if there is a conflict between SchedBarrier and SchedGroupBarrier, 
should SchedBarrier always get the priority? Maybe SchedBarrier should only 
handle groups not present in SchedGroupBarrier?



Comment at: llvm/test/CodeGen/AMDGPU/sched-group-barrier-pre-RA.mir:104
+GLOBAL_STORE_DWORD_SADDR %1, %13, %0, 512, 0, implicit $exec :: (store 
(s32) into %ir.out, !noalias !0, addrspace 1)
+; 1 VMEM_READ
+SCHED_GROUP_BARRIER 32, 1, 0

I think you are aware of this issue. But the ability for the mutation to match 
the pipeline is dependent upon which instructions go into which group (when an 
instruction can be mapped to multiple groups).

If we had SchedGroups: 2 VMEM_READ, 1 VALU, 1 MFMA, 2 VMEM_READ

and initial schedule: VMEMR, VALU, VMEMR, MFMA, VMEMR, with a dependency 
between middle VMEMR->MFMA. 

initSchedGroup will add the middle VMEMR to the last VMEMR group, but we could 
get a more accurate pipeline by adding it to the first group.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128158

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


[PATCH] D129009: [Analysis] Fix LTO for aliased IFuncs.

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441758.
SchrodingerZhu retitled this revision from "[llvm.analysis] Fix LTO for aliased 
IFuncs.

As https://github.com/llvm/llvm-project/issues/56290 indicates, 
when an ifunc is aliased in LTO, clang will attempt to create
an alias summary; however, as ifunc is not included in the 
module summary..." to "[Analysis] Fix LTO for aliased IFuncs.".
SchrodingerZhu edited the summary of this revision.
SchrodingerZhu added a comment.

update code area


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  clang/test/Analysis/alias-indirect-function-lto.c
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,23 +646,26 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
-  bool NonRenamableLocal = isNonRenamableLocal(A);
-  GlobalValueSummary::GVFlags Flags(
-  A.getLinkage(), A.getVisibility(), NonRenamableLocal,
-  /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
-  auto AS = std::make_unique(Flags);
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
   auto *Aliasee = A.getAliaseeObject();
-  auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
-  assert(AliaseeVI && "Alias expects aliasee summary to be available");
-  assert(AliaseeVI.getSummaryList().size() == 1 &&
- "Expected a single entry per aliasee in per-module index");
-  AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
-  if (NonRenamableLocal)
-CantBePromoted.insert(A.getGUID());
-  Index.addGlobalValueSummary(A, std::move(AS));
+  // Currently, skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
+bool NonRenamableLocal = isNonRenamableLocal(A);
+GlobalValueSummary::GVFlags Flags(
+A.getLinkage(), A.getVisibility(), NonRenamableLocal,
+/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
+auto AS = std::make_unique(Flags);
+auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
+assert(AliaseeVI && "Alias expects aliasee summary to be available");
+assert(AliaseeVI.getSummaryList().size() == 1 &&
+   "Expected a single entry per aliasee in per-module index");
+AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
+if (NonRenamableLocal)
+  CantBePromoted.insert(A.getGUID());
+Index.addGlobalValueSummary(A, std::move(AS));
+  }
 }
 
 // Set LiveRoot flag on entries matching the given value name.
Index: clang/test/Analysis/alias-indirect-function-lto.c
===
--- /dev/null
+++ clang/test/Analysis/alias-indirect-function-lto.c
@@ -0,0 +1,4 @@
+// RUN: %clang_analyze_cc1 -flto -c
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
\ No newline at end of file


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp

[PATCH] D128953: [NFC] Refactor llvm::zlib namespace

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

LGTM. Happy when @phosek is happy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


[PATCH] D129009: [llvm.analysis] Fix LTO for aliased IFuncs. As https://github.com/llvm/llvm-project/issues/56290 indicates, when an ifunc is aliased in LTO, clang will attempt to create an alias su

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu updated this revision to Diff 441756.
SchrodingerZhu retitled this revision from "[llvm.analysis] Fix LTO for aliased 
IFuncs." to "[llvm.analysis] Fix LTO for aliased IFuncs.

As https://github.com/llvm/llvm-project/issues/56290 indicates, 
when an ifunc is aliased in LTO, clang will attempt to create
an alias summary; however, as ifunc is not included in the 
module summary...".
SchrodingerZhu edited the summary of this revision.
SchrodingerZhu added a comment.



Updating D129009: [llvm.analysis] Fix LTO for aliased IFuncs.
=

As https://github.com/llvm/llvm-project/issues/56290 indicates, 
when an ifunc is aliased in LTO, clang will attempt to create
an alias summary; however, as ifunc is not included in the 
module summary...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129009

Files:
  clang/test/Analysis/alias-indirect-function-lto.c
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,23 +646,26 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
-  bool NonRenamableLocal = isNonRenamableLocal(A);
-  GlobalValueSummary::GVFlags Flags(
-  A.getLinkage(), A.getVisibility(), NonRenamableLocal,
-  /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
-  auto AS = std::make_unique(Flags);
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
   auto *Aliasee = A.getAliaseeObject();
-  auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
-  assert(AliaseeVI && "Alias expects aliasee summary to be available");
-  assert(AliaseeVI.getSummaryList().size() == 1 &&
- "Expected a single entry per aliasee in per-module index");
-  AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
-  if (NonRenamableLocal)
-CantBePromoted.insert(A.getGUID());
-  Index.addGlobalValueSummary(A, std::move(AS));
+  // Currently, skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
+bool NonRenamableLocal = isNonRenamableLocal(A);
+GlobalValueSummary::GVFlags Flags(
+A.getLinkage(), A.getVisibility(), NonRenamableLocal,
+/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
+auto AS = std::make_unique(Flags);
+auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
+assert(AliaseeVI && "Alias expects aliasee summary to be available");
+assert(AliaseeVI.getSummaryList().size() == 1 &&
+   "Expected a single entry per aliasee in per-module index");
+AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
+if (NonRenamableLocal)
+  CantBePromoted.insert(A.getGUID());
+Index.addGlobalValueSummary(A, std::move(AS));
+  }
 }
 
 // Set LiveRoot flag on entries matching the given value name.
Index: clang/test/Analysis/alias-indirect-function-lto.c
===
--- /dev/null
+++ clang/test/Analysis/alias-indirect-function-lto.c
@@ -0,0 +1,4 @@
+// RUN: %clang_analyze_cc1 -flto -c
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
\ No newline at end of file


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == 

[PATCH] D129009: [llvm.analysis] Fix LTO for aliased IFuncs.

2022-07-01 Thread Schrodinger ZHU Yifan via Phabricator via cfe-commits
SchrodingerZhu created this revision.
Herald added subscribers: steakhal, ormris, jeroen.dobbelaere, steven_wu, 
hiraditya, inglorion.
Herald added a project: All.
SchrodingerZhu requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Signed-off-by: SchrodingerZhu 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129009

Files:
  clang/test/Analysis/alias-indirect-function-lto.c
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,23 +646,26 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex , const GlobalAlias ,
-DenseSet ) {
-  bool NonRenamableLocal = isNonRenamableLocal(A);
-  GlobalValueSummary::GVFlags Flags(
-  A.getLinkage(), A.getVisibility(), NonRenamableLocal,
-  /* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
-  auto AS = std::make_unique(Flags);
+static void computeAliasSummary(ModuleSummaryIndex , const GlobalAlias 
,
+DenseSet ) {
   auto *Aliasee = A.getAliaseeObject();
-  auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
-  assert(AliaseeVI && "Alias expects aliasee summary to be available");
-  assert(AliaseeVI.getSummaryList().size() == 1 &&
- "Expected a single entry per aliasee in per-module index");
-  AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
-  if (NonRenamableLocal)
-CantBePromoted.insert(A.getGUID());
-  Index.addGlobalValueSummary(A, std::move(AS));
+  // Currently, skip summary for indirect function aliases as
+  // summary for aliasee will not be emitted.
+  if (Aliasee->getValueID() != Value::ValueTy::GlobalIFuncVal) {
+bool NonRenamableLocal = isNonRenamableLocal(A);
+GlobalValueSummary::GVFlags Flags(
+A.getLinkage(), A.getVisibility(), NonRenamableLocal,
+/* Live = */ false, A.isDSOLocal(), A.canBeOmittedFromSymbolTable());
+auto AS = std::make_unique(Flags);
+auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
+assert(AliaseeVI && "Alias expects aliasee summary to be available");
+assert(AliaseeVI.getSummaryList().size() == 1 &&
+   "Expected a single entry per aliasee in per-module index");
+AS->setAliasee(AliaseeVI, AliaseeVI.getSummaryList()[0].get());
+if (NonRenamableLocal)
+  CantBePromoted.insert(A.getGUID());
+Index.addGlobalValueSummary(A, std::move(AS));
+  }
 }
 
 // Set LiveRoot flag on entries matching the given value name.
Index: clang/test/Analysis/alias-indirect-function-lto.c
===
--- /dev/null
+++ clang/test/Analysis/alias-indirect-function-lto.c
@@ -0,0 +1,4 @@
+// RUN: %clang_analyze_cc1 -flto -c
+void f() __attribute__((ifunc("g")));
+static void *g() { return 0; };
+void h() __attribute__((alias("f")));
\ No newline at end of file


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4103,8 +4103,10 @@
 
   for (const GlobalAlias  : M.aliases()) {
 auto *Aliasee = A.getAliaseeObject();
-if (!Aliasee->hasName())
-  // Nameless function don't have an entry in the summary, skip it.
+if (!Aliasee->hasName() ||
+Aliasee->getValueID() == Value::ValueTy::GlobalIFuncVal)
+  // IFunc function and Nameless function don't have an entry in the
+  // summary, skip it.
   continue;
 auto AliasId = VE.getValueID();
 auto AliaseeId = VE.getValueID(Aliasee);
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -646,23 +646,26 @@
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void

[PATCH] D128953: [NFC] Refactor llvm::zlib namespace

2022-07-01 Thread Cole Kissane via Phabricator via cfe-commits
ckissane added inline comments.



Comment at: llvm/lib/ProfileData/InstrProf.cpp:154
+OS << ("profile uses " + compression::profile::AlgorithmName +
+   " compression but the profile reader was built " + "without " +
+   compression::profile::AlgorithmName + " support");

MaskRay wrote:
> leonardchan wrote:
> > `" compression but the profile reader was built " + "without "` -> `" 
> > compression but the profile reader was built without "`
> Keep the diagnostic unchanged in this patch.
And the other similar changes?
I will note these are NFC because if zlib is being used (as it currently always 
is), it has the exact same output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-07-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D126907#3625600 , @vitalybuka 
wrote:

> @erichkeane can you please make sure that committed revisions in git have 
> "Differential Revision: ". Usually it's added by "arc" when you upload 
> review.
> Also it would be nice if reapply have the same link.
>
> Regarding reproducer, you can follow 
> https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild
> But it's already related, let see if it resolved for our bot as well.

Yep, I'll make sure to remember that next time.  Corporate IT prevents me from 
using arc, so I am stuck doing it m anually and forget sometimes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-07-01 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

@erichkeane can you please make sure that committed revisions in git have 
"Differential Revision: ". Usually it's added by "arc" when you upload 
review.
Also it would be nice if reapply have the same link.

Regarding reproducer, you can follow 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild
But it's already related, let see if it resolved for our bot as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[clang] 258c3ae - Revert "Re-apply "Deferred Concept Instantiation Implementation"""

2022-07-01 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-07-01T11:20:16-07:00
New Revision: 258c3aee54e11bc5c5d8ac137eb15e8d5bbcc7e4

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

LOG: Revert "Re-apply "Deferred Concept Instantiation Implementation"""

This reverts commit befa8cf087dbb8159a4d9dc8fa4d6748d6d5049a.

Apparently this breaks some libc++ builds with an apparent assertion,
 so I'm looking into that .

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp

clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp

clang/test/CXX/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp

clang/test/CXX/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
clang/test/SemaTemplate/concepts.cpp
clang/test/SemaTemplate/instantiate-requires-clause.cpp

Removed: 
clang/test/SemaTemplate/concepts-friends.cpp
clang/test/SemaTemplate/deferred-concept-inst.cpp
clang/test/SemaTemplate/trailing-return-short-circuit.cpp



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 26d769deee6d4..3342f6208c4f8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -451,11 +451,10 @@ C++20 Feature Support
 - No longer attempt to evaluate a consteval UDL function call at runtime when
   it is called through a template instantiation. This fixes
   `Issue 54578 `_.
-- Implemented `__builtin_source_location()` which enables library support for 
std::source_location.
-- Clang now correctly delays the instantiation of function constraints until
-  the time of checking, which should now allow the libstdc++ ranges 
implementation
-  to work for at least trivial examples.  This fixes
-  `Issue 44178 `_.
+
+- Implemented ``__builtin_source_location()``, which enables library support
+  for ``std::source_location``.
+
 - The mangling scheme for C++20 modules has incompatibly changed. The
   initial mangling was discovered not to be reversible, and the weak
   ownership design decision did not give the backwards compatibility

diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 0a7dc63d1c25d..66fab94b45b8a 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1890,9 +1890,7 @@ class FunctionDecl : public DeclaratorDecl,
 TK_FunctionTemplateSpecialization,
 // A function template specialization that hasn't yet been resolved to a
 // particular specialized function template.
-TK_DependentFunctionTemplateSpecialization,
-// A non templated function which is in a dependent scope.
-TK_DependentNonTemplate
+TK_DependentFunctionTemplateSpecialization
   };
 
   /// Stashed information about a defaulted function definition whose body has
@@ -1941,21 +1939,20 @@ class FunctionDecl : public DeclaratorDecl,
   /// The template or declaration that this declaration
   /// describes or was instantiated from, respectively.
   ///
-  /// For non-templates this value will be NULL, unless this non-template
-  /// function declaration was declared directly inside of a function template,
-  /// in which case this will have a pointer to a FunctionDecl, stored in the
-  /// NamedDecl. For function declarations that describe a function template,
-  /// this will be a pointer to a FunctionTemplateDecl, stored in the 
NamedDecl.
-  /// For member functions of class template specializations, this will be a
-  /// MemberSpecializationInfo pointer containing information about the
-  /// specialization. For function template specializations, this will be a
-  /// FunctionTemplateSpecializationInfo, which contains information about the
-  /// template being specialized and the template arguments involved in that
-  /// specialization.
-  llvm::PointerUnion
-  TemplateOrSpecialization;
+TemplateOrSpecialization;
 
   /// Provides source/type location info for the declaration name embedded in
   /// the DeclaratorDecl base class.
@@ -2698,11 +2695,6 @@ class FunctionDecl : 

[PATCH] D128953: [NFC] Refactor llvm::zlib namespace

2022-07-01 Thread Cole Kissane via Phabricator via cfe-commits
ckissane added inline comments.



Comment at: llvm/include/llvm/Support/Compression.h:49-51
+namespace profile = llvm::compression::zlib;
+
+namespace serialize = llvm::compression::zlib;

phosek wrote:
> I think we will need to support dynamically selecting (de)compression 
> algorithm for both profile and serialization. For example, we should be able 
> to use read profiles generated by an older version of LLVM that only 
> supported zlib, even if the new one also supports zstd. Given that, I'd omit 
> these and instead use `compression::zlib` everywhere.
Correct, however I think that doing this in the meantime helps make it clear 
semantically for what purpose each compression call is for. It will make 
finding all instances of each time of use much easier in the future, and 
promotes semantically thought out usage.

Therefore I see no reason to not make these explicit aliases as it will only 
ease transition in the future.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


[PATCH] D128472: [pseudo] Check follow-sets instead of tying reduce actions to lookahead tokens.

2022-07-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the report. There is an out-of-bound issue in 
LRTable::getReduceRules, fixed in c99827349927a44334f2b04139168efd0bc87cd3 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128472

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


[clang-tools-extra] c998273 - [pseudo] Fix an out-of-bound issue in getReduceRules.

2022-07-01 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-07-01T20:16:06+02:00
New Revision: c99827349927a44334f2b04139168efd0bc87cd3

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

LOG: [pseudo] Fix an out-of-bound issue in getReduceRules.

Added: 


Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
index 70ce52924f110..664a1a3206fe6 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
@@ -140,8 +140,11 @@ class LRTable {
   // // ...apply reduce...
   //   }
   llvm::ArrayRef getReduceRules(StateID State) const {
+if (ReduceOffset[State] >= Reduces.size())
+  return {};
+size_t Length = ReduceOffset[State + 1] - ReduceOffset[State];
 return llvm::makeArrayRef([ReduceOffset[State]],
-  [ReduceOffset[State + 1]]);
+  Length);
   }
   // Returns whether Terminal can follow Nonterminal in a valid source file.
   bool canFollow(SymbolID Nonterminal, SymbolID Terminal) const {



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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-01 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 441748.
cor3ntin added a comment.

Fix typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/comment-invalid-utf8.c
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTF.cpp

Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -417,6 +417,16 @@
 return isLegalUTF8(source, length);
 }
 
+/*
+ * Exported function to return the size of the first utf-8 code unit sequence,
+ * Or 0 if the sequence is not valid;
+ */
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
+  int length = trailingBytesForUTF8[*source] + 1;
+  return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length
+  : 0;
+}
+
 /* - */
 
 static unsigned
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -181,6 +181,8 @@
 
 Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd);
 
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd);
+
 unsigned getNumBytesForUTF8(UTF8 firstByte);
 
 /*/
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2391,13 +2391,37 @@
   //
   // This loop terminates with CurPtr pointing at the newline (or end of buffer)
   // character that ends the line comment.
+
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (C != 0 &&// Potentially EOF.
-   C != '\n' && C != '\r')  // Newline or DOS-style newline.
+while (isASCII(C) && C != 0 &&   // Potentially EOF.
+   C != '\n' && C != '\r') { // Newline or DOS-style newline.
   C = *++CurPtr;
+  UnicodeDecodingAlreadyDiagnosed = false;
+}
+
+if (!isASCII(C)) {
+  unsigned Length = llvm::getUTF8SequenceSize(
+  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
+  if (Length == 0) {
+if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
+UnicodeDecodingAlreadyDiagnosed = true;
+++CurPtr;
+  } else {
+UnicodeDecodingAlreadyDiagnosed = false;
+CurPtr += Length;
+  }
+  continue;
+}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2664,6 +2688,12 @@
   if (C == '/')
 C = *CurPtr++;
 
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   while (true) {
 // Skip over all non-interesting characters until we find end of buffer or a
 // (probably ending) '/' character.
@@ -2672,14 +2702,24 @@
 // doesn't check for '\0'.
 !(PP && PP->getCodeCompletionFileLoc() == FileLoc)) {
   // While not aligned to a 16-byte boundary.
-  while (C != '/' && ((intptr_t)CurPtr & 0x0F) != 0)
+  while (C != '/' && (intptr_t)CurPtr % 16 != 0) {
+if (!isASCII(C)) {
+  CurPtr--;
+  goto MultiByteUTF8;
+}
 C = *CurPtr++;
-
+  }
   if (C == '/') goto FoundSlash;
 
 #ifdef __SSE2__
   __m128i Slashes = _mm_set1_epi8('/');
-  while (CurPtr+16 <= BufferEnd) {
+  while (CurPtr + 16 < BufferEnd) {
+int Mask = _mm_movemask_epi8(*(const __m128i *)CurPtr);
+if (LLVM_UNLIKELY(Mask != 0)) {
+  CurPtr += llvm::countTrailingZeros(Mask);
+  goto MultiByteUTF8;
+}
+// look for slashes
 int cmp = _mm_movemask_epi8(_mm_cmpeq_epi8(*(const __m128i*)CurPtr,
 Slashes));
 if (cmp != 0) {
@@ -2692,21 +2732,41 @@
 CurPtr += 16;
   }
 #elif __ALTIVEC__
+  __vector unsigned char LongUTF = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
+

[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:270
   This fixes `Issue 55962 
`_.
+- Added ``-Winvalid-utf8`` which diagnose invalid UTF-8 code unit sequences in
+  comments.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[clang] 6450dad - Test a few more C99 DRs

2022-07-01 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-07-01T13:54:11-04:00
New Revision: 6450daddd20a83327118c0c6fa8f844a99cd1f0f

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

LOG: Test a few more C99 DRs

This updates the status for another 8 DRs.

Added: 


Modified: 
clang/test/C/drs/dr2xx.c
clang/www/c_dr_status.html

Removed: 




diff  --git a/clang/test/C/drs/dr2xx.c b/clang/test/C/drs/dr2xx.c
index e4fe3183b02c9..b34b7ef2cce79 100644
--- a/clang/test/C/drs/dr2xx.c
+++ b/clang/test/C/drs/dr2xx.c
@@ -17,6 +17,21 @@
  *
  * WG14 DR215: yes
  * Equality operators
+ *
+ * WG14 DR218: yes
+ * Signs of non-numeric floating point values
+ *
+ * WG14 DR219: yes
+ * Effective types
+ *
+ * WG14 DR221: yes
+ * Lacuna in pointer arithmetic
+ *
+ * WG14 DR222: yes
+ * Partially initialized structures
+ *
+ * WG14 DR234: yes
+ * Miscellaneous Typos
  */
 
 
@@ -87,3 +102,45 @@ void dr216(void) {
   A('}'); A('~');
 #undef A
 }
+
+/* WG14 DR230: yes
+ * Enumerated type rank
+ */
+void dr230(void) {
+  enum E {
+Value = __INT_MAX__
+  } e;
+  /* The enumeration type has a compatible type that is a signed or unsigned
+   * integer type, or char. But it has to be large enough to hold all of the
+   * values of the enumerators. So it needs to be at least int or unsigned int.
+   *
+   * The integer conversion rank for an enumeration is the same as its
+   * compatible type (C99 6.3.1.1p1), so it's eligible for integer promotions
+   * to either int or unsigned int, depending on the compatible type
+   * (C99 6.3.1.1p2).
+   */
+  (void)_Generic(e, int : 1, unsigned int : 1);
+  (void)_Generic((enum E)Value, int : 1, unsigned int : 1);
+  /* The enumerators themselves have type int (C99 6.7.2.2p3). */
+  (void)_Generic(Value, int : 1);
+}
+
+/* WG14 DR231: no
+ * Semantics of text-line and non-directive
+ *
+ * One of the preprocessing groups to support is # non-directive (C99 6.10p1),
+ * which is defined as pp-tokens followed by a newline. However, we fail to
+ * translate the program if we don't recognize the directive, and we don't take
+ * note when what follows the # is not a valid preprocessing token.
+ */
+
+/* FIXME: this should not fail. */
+# nope /* expected-error {{invalid preprocessing directive}} */
+
+/* FIXME: this should fail, but not because of the unknown directive; it should
+ * fail because of the invalid preprocessing-token.
+ */
+# 'a
+/* expected-error@-1 {{invalid preprocessing directive}} \
+   expected-warning@-1 {{missing terminating ' character}}
+*/

diff  --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index ea604b498a539..239e8e8140ba8 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -1242,13 +1242,13 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_218.htm;>218
 C99
 Signs of non-numeric floating point values
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_219.htm;>219
 NAD
 Effective types
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_220.htm;>220
@@ -1260,13 +1260,13 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_221.htm;>221
 NAD
 Lacuna in pointer arithmetic
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_222.htm;>222
 C99
 Partially initialized structures
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_223.htm;>223
@@ -1290,7 +1290,7 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_226.htm;>226
 NAD
 strftime references
-Yes
+N/A
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_227.htm;>227
@@ -1314,19 +1314,19 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_230.htm;>230
 C99
 Enumerated type rank
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_231.htm;>231
 NAD
 Semantics of text-line and non-directive
-Unknown
+No
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_232.htm;>232
 C99
 Typo in Annex I
-Yes
+N/A
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_233.htm;>233



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


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood accepted this revision.
LegalizeAdulthood added a comment.
This revision is now accepted and ready to land.

Thanks for this, like Nathan James this has been pestering me for a while `:)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127807

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


[PATCH] D128402: [clang-tidy] Don't treat invalid branches as identical

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

Please provide the name and email address you wish to use on the commit and I 
will submit.


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

https://reviews.llvm.org/D128402

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


[PATCH] D128402: [clang-tidy] Don't treat invalid branches as identical

2022-07-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

I can submit after you address additional comments by Nathan James.


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

https://reviews.llvm.org/D128402

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


[PATCH] D128953: [NFC] refactor compression namespaces making way for a possible introduction of alternatives to zlib compression in the llvm toolchain.

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/ProfileData/InstrProf.cpp:154
+OS << ("profile uses " + compression::profile::AlgorithmName +
+   " compression but the profile reader was built " + "without " +
+   compression::profile::AlgorithmName + " support");

leonardchan wrote:
> `" compression but the profile reader was built " + "without "` -> `" 
> compression but the profile reader was built without "`
Keep the diagnostic unchanged in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


[PATCH] D129008: [Clang][OpenMP] Fix the issue that globalization doesn't work with byval struct function argument

2022-07-01 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 441742.
tianshilei1992 added a comment.

fix unused variable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129008

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/OpenMP/globalization_byval_struct.c

Index: clang/test/OpenMP/globalization_byval_struct.c
===
--- /dev/null
+++ clang/test/OpenMP/globalization_byval_struct.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+extern int printf(const char *, ...);
+
+struct S {
+  int a;
+  float b;
+};
+
+// CHECK: define{{.*}}void @test(%struct.S* noundef byval(%struct.S) align {{[0-9]+}} [[arg:%[0-9a-zA-Z]+]])
+// CHECK: [[g:%[0-9a-zA-Z]+]] = call align {{[0-9]+}} i8* @__kmpc_alloc_shared
+// CHECK: bitcast i8* [[g]] to %struct.S*
+// CHECK: bitcast %struct.S* [[arg]] to i8**
+// CHECK: call void [[cc:@__copy_constructor[_0-9a-zA-Z]+]]
+// CHECK: void [[cc]]
+void test(struct S s) {
+#pragma omp parallel for
+  for (int i = 0; i < s.a; ++i) {
+printf("%i : %i : %f\n", i, s.a, s.b);
+  }
+}
+
+void foo() {
+  #pragma omp target teams num_teams(1)
+  {
+struct S s;
+s.a = 7;
+s.b = 11;
+test(s);
+  }
+}
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2470,66 +2470,66 @@
 
   Address DeclPtr = Address::invalid();
   Address AllocaPtr = Address::invalid();
-  bool DoStore = false;
+  bool DoCopy = false;
   bool IsScalar = hasScalarEvaluationKind(Ty);
-  // If we already have a pointer to the argument, reuse the input pointer.
-  if (Arg.isIndirect()) {
-// If we have a prettier pointer type at this point, bitcast to that.
-DeclPtr = Arg.getIndirectAddress();
-DeclPtr = Builder.CreateElementBitCast(DeclPtr, ConvertTypeForMem(Ty),
-   D.getName());
-// Indirect argument is in alloca address space, which may be different
-// from the default address space.
-auto AllocaAS = CGM.getASTAllocaAddressSpace();
-auto *V = DeclPtr.getPointer();
-AllocaPtr = DeclPtr;
-auto SrcLangAS = getLangOpts().OpenCL ? LangAS::opencl_private : AllocaAS;
-auto DestLangAS =
-getLangOpts().OpenCL ? LangAS::opencl_private : LangAS::Default;
-if (SrcLangAS != DestLangAS) {
-  assert(getContext().getTargetAddressSpace(SrcLangAS) ==
- CGM.getDataLayout().getAllocaAddrSpace());
-  auto DestAS = getContext().getTargetAddressSpace(DestLangAS);
-  auto *T = DeclPtr.getElementType()->getPointerTo(DestAS);
-  DeclPtr = DeclPtr.withPointer(getTargetHooks().performAddrSpaceCast(
-  *this, V, SrcLangAS, DestLangAS, T, true));
-}
 
-// Push a destructor cleanup for this parameter if the ABI requires it.
-// Don't push a cleanup in a thunk for a method that will also emit a
-// cleanup.
-if (Ty->isRecordType() && !CurFuncIsThunk &&
-Ty->castAs()->getDecl()->isParamDestroyedInCallee()) {
-  if (QualType::DestructionKind DtorKind =
-  D.needsDestruction(getContext())) {
-assert((DtorKind == QualType::DK_cxx_destructor ||
-DtorKind == QualType::DK_nontrivial_c_struct) &&
-   "unexpected destructor type");
-pushDestroy(DtorKind, DeclPtr, Ty);
-CalleeDestructedParamCleanups[cast()] =
-EHStack.stable_begin();
-  }
-}
-  } else {
-// Check if the parameter address is controlled by OpenMP runtime.
-Address OpenMPLocalAddr =
-getLangOpts().OpenMP
-? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, )
-: Address::invalid();
-if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
-  DeclPtr = OpenMPLocalAddr;
+  // We first check if the parameter address is controlled by OpenMP.
+  if (getLangOpts().OpenMP) {
+DeclPtr = CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, );
+if (DeclPtr.isValid()) {
   AllocaPtr = DeclPtr;
-} else {
-  // Otherwise, create a temporary to hold the value.
-  DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(),
-  D.getName() + ".addr", );
+  DoCopy = true;
 }
-DoStore = true;
   }
 
-  llvm::Value *ArgVal = (DoStore ? Arg.getDirectValue() : nullptr);
+  // The parameter is not controlled by OpenMP.
+  if (!DeclPtr.isValid()) {
+// If we already have a pointer to the argument, reuse the 

[PATCH] D129008: [Clang][OpenMP] Fix the issue that globalization doesn't work with byval struct function argument

2022-07-01 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ABataev.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
tianshilei1992 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch fixes the issue that the globalized variable is not properly
initialized when it is a byval struct function argument.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129008

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/OpenMP/globalization_byval_struct.c

Index: clang/test/OpenMP/globalization_byval_struct.c
===
--- /dev/null
+++ clang/test/OpenMP/globalization_byval_struct.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -x c -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+extern int printf(const char *, ...);
+
+struct S {
+  int a;
+  float b;
+};
+
+// CHECK: define{{.*}}void @test(%struct.S* noundef byval(%struct.S) align {{[0-9]+}} [[arg:%[0-9a-zA-Z]+]])
+// CHECK: [[g:%[0-9a-zA-Z]+]] = call align {{[0-9]+}} i8* @__kmpc_alloc_shared
+// CHECK: bitcast i8* [[g]] to %struct.S*
+// CHECK: bitcast %struct.S* [[arg]] to i8**
+// CHECK: call void [[cc:@__copy_constructor[_0-9a-zA-Z]+]]
+// CHECK: void [[cc]]
+void test(struct S s) {
+#pragma omp parallel for
+  for (int i = 0; i < s.a; ++i) {
+printf("%i : %i : %f\n", i, s.a, s.b);
+  }
+}
+
+void foo() {
+  #pragma omp target teams num_teams(1)
+  {
+struct S s;
+s.a = 7;
+s.b = 11;
+test(s);
+  }
+}
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2471,65 +2471,66 @@
   Address DeclPtr = Address::invalid();
   Address AllocaPtr = Address::invalid();
   bool DoStore = false;
+  bool DoCopy = false;
   bool IsScalar = hasScalarEvaluationKind(Ty);
-  // If we already have a pointer to the argument, reuse the input pointer.
-  if (Arg.isIndirect()) {
-// If we have a prettier pointer type at this point, bitcast to that.
-DeclPtr = Arg.getIndirectAddress();
-DeclPtr = Builder.CreateElementBitCast(DeclPtr, ConvertTypeForMem(Ty),
-   D.getName());
-// Indirect argument is in alloca address space, which may be different
-// from the default address space.
-auto AllocaAS = CGM.getASTAllocaAddressSpace();
-auto *V = DeclPtr.getPointer();
-AllocaPtr = DeclPtr;
-auto SrcLangAS = getLangOpts().OpenCL ? LangAS::opencl_private : AllocaAS;
-auto DestLangAS =
-getLangOpts().OpenCL ? LangAS::opencl_private : LangAS::Default;
-if (SrcLangAS != DestLangAS) {
-  assert(getContext().getTargetAddressSpace(SrcLangAS) ==
- CGM.getDataLayout().getAllocaAddrSpace());
-  auto DestAS = getContext().getTargetAddressSpace(DestLangAS);
-  auto *T = DeclPtr.getElementType()->getPointerTo(DestAS);
-  DeclPtr = DeclPtr.withPointer(getTargetHooks().performAddrSpaceCast(
-  *this, V, SrcLangAS, DestLangAS, T, true));
-}
 
-// Push a destructor cleanup for this parameter if the ABI requires it.
-// Don't push a cleanup in a thunk for a method that will also emit a
-// cleanup.
-if (Ty->isRecordType() && !CurFuncIsThunk &&
-Ty->castAs()->getDecl()->isParamDestroyedInCallee()) {
-  if (QualType::DestructionKind DtorKind =
-  D.needsDestruction(getContext())) {
-assert((DtorKind == QualType::DK_cxx_destructor ||
-DtorKind == QualType::DK_nontrivial_c_struct) &&
-   "unexpected destructor type");
-pushDestroy(DtorKind, DeclPtr, Ty);
-CalleeDestructedParamCleanups[cast()] =
-EHStack.stable_begin();
-  }
-}
-  } else {
-// Check if the parameter address is controlled by OpenMP runtime.
-Address OpenMPLocalAddr =
-getLangOpts().OpenMP
-? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, )
-: Address::invalid();
-if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
-  DeclPtr = OpenMPLocalAddr;
+  // We first check if the parameter address is controlled by OpenMP.
+  if (getLangOpts().OpenMP) {
+DeclPtr = CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, );
+if (DeclPtr.isValid()) {
   AllocaPtr = DeclPtr;
-} else {
-  // Otherwise, create a temporary to hold the value.
-  DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(),
-  D.getName() + ".addr", );
+  DoCopy = true;
 

[PATCH] D125683: [runtimes] Replace LIBCXX_ENABLE_STATIC_ABI_LIBRARY & friends by a new LIBCXX_CXX_ABI choice

2022-07-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM




Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:122
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")

Would it be possible to add `set(RUNTIMES_${target}_LIBCXX_CXX_ABI 
"libcxxabi-objects" CACHE STRING "")` here?



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:189
 
set(RUNTIMES_${target}_LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")

Would it be possible to add `set(RUNTIMES_${target}_LIBCXX_CXX_ABI 
"libcxxabi-objects" CACHE STRING "")` here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125683

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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-01 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@aaron.ballman FYI this is now core-approved


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[PATCH] D127887: [CMake][Fuchsia] Use libunwind as the default unwinder

2022-07-01 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 rG6213dba19fc0: [CMake][Fuchsia] Use libunwind as the default 
unwinder (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127887

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -26,6 +26,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,6 +32,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
@@ -119,7 +120,6 @@
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
@@ -130,9 +130,6 @@
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX "libc++" CACHE STRING "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "")
-set(RUNTIMES_${target}_COMPILER_RT_TEST_COMPILER_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_SANITIZER_COMMON_TEST_TARGET_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind 
-static-libgcc" CACHE STRING "")
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
@@ -183,13 +180,10 @@
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
-
set(RUNTIMES_${target}_LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -26,6 +26,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,6 +32,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 

[clang] 6213dba - [CMake][Fuchsia] Use libunwind as the default unwinder

2022-07-01 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-07-01T17:24:00Z
New Revision: 6213dba19fc0d65ab8b366b6d78c56cbd63c9d7d

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

LOG: [CMake][Fuchsia] Use libunwind as the default unwinder

Fuchsia already uses libunwind, but it does so implicitly via libc++.
This change makes the unwinder choice explicit.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 4e3ed6086dec5..3c6cfdaa1c1cc 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,6 +32,7 @@ set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
@@ -119,7 +120,6 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
@@ -130,9 +130,6 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX "libc++" CACHE STRING "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "")
-set(RUNTIMES_${target}_COMPILER_RT_TEST_COMPILER_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_SANITIZER_COMMON_TEST_TARGET_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind 
-static-libgcc" CACHE STRING "")
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
@@ -183,13 +180,10 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
-
set(RUNTIMES_${target}_LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")

diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index 7b534e61f9520..83232b776ad9e 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -26,6 +26,7 @@ set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")



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


[PATCH] D128953: [NFC] refactor compression namespaces making way for a possible introduction of alternatives to zlib compression in the llvm toolchain.

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> [NFC] refactor compression namespaces making way for a possible introduction 
> of alternatives to zlib compression in the llvm toolchain.

I'd use `[NFC] Refactor llvm::zlib namespace` and place supplementary wording 
to the body.

`in the llvm toolchain` is redundant in the sentence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


[PATCH] D128783: [test] Check for more -fsanitize=array-bounds regressions

2022-07-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

`clang/test/SemaCXX/array-bounds.cpp` has `tailpad` and `metaprogramming` tests 
which may be added here.

Happy when @serge-sans-paille is happy.


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

https://reviews.llvm.org/D128783

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


[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-07-01 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added inline comments.



Comment at: clang/lib/Lex/PPLexerChange.cpp:136
PPCallbacks::EnterFile, FileType);
+FileID PrevFID;
+SourceLocation EnterLoc;

akyrtzi wrote:
> benlangmuir wrote:
> > Why does `LexedFileChanged` have `PrevFID` set, but `FileChanged` does not 
> > (it has a default argument of `FileID()`?  I would have expected that when 
> > you call both `FileChanged` and `LexedFileChanged` for the same event this 
> > would match.
> I didn't want to change the "contract" of `FileChanged()` as part of these 
> changes but it's probably unlikely that someone depends on `FileID` being 
> invalid, I'll give it a try.
I'm passing a `PrevFID` value for `FileChanged()` as well and I only had to 
update one test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128947

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


  1   2   >