[PATCH] D120989: Support debug info for alias variable

2022-03-10 Thread Kavitha Natarajan via Phabricator via cfe-commits
kavitha-natarajan added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3921
+  return cast(GVE);
+return dyn_cast_or_null(N);
+  }

aprantl wrote:
> When would we enter a nullptr into the cache?
In this change, only llvm::DIImportedEntity entries are pushed to 
ImportedDeclCache. So it will never return nullptr. It is only a guard to not 
to fall into the case of no definition in case of non llvm::DIImportedEntity in 
the cache (undesired and to be handled by the caller).



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1502
+const GlobalDecl CodeGenModule::getMangledNameDecl(StringRef Name) {
+  auto it = MangledDeclNames.begin();
+  while (it != MangledDeclNames.end()) {

aprantl wrote:
> std::find()?
MangledDeclNames is a llvm::MapVector implementation, so can't use std::find(). 
The key for MangledDeclNames MapVector is GlobalDecl and StringRef is the 
value. llvm::Mapvector::find() is search by key. Here we are doing search by 
value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120989

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


[PATCH] D121446: Add -no-unused-coverage option

2022-03-10 Thread Hiral via Phabricator via cfe-commits
Hiralo created this revision.
Hiralo added a reviewer: vsk.
Hiralo added a project: clang.
Herald added subscribers: dexonsmith, wenlei, dang.
Herald added a project: All.
Hiralo requested review of this revision.
Herald added a subscriber: cfe-commits.

commit 87f30be546daca55664ded147acceb9f206399e0
Author: Hiral Oza 
Date:   Fri Mar 11 09:41:38 2022 +0530

  Add -no-unused-coverage option
  
  Reduce the size of instrumented objects by eliminating counters for code that 
will not be emitted.
  
  Author: thom.h...@netapp.com

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 3301e7587d21..e51261ddcced 100644

- a/clang/include/clang/Basic/CodeGenOptions.def

+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -211,6 +211,8 @@ CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage 
mapping regions to

  ///< enable code coverage analysis.

CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping

  ///< regions.

+CODEGENOPT(NoUnusedCoverage , 1, 0) ///< Turn off coverage mapping for code 
that
+///< is not emitted.

  /// If -fpcc-struct-return or -freg-struct-return is specified.

ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, 
SRCK_Default)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index fa54d4a7689c..05926e01efb1 100644

- a/clang/include/clang/Driver/Options.td

+++ b/clang/include/clang/Driver/Options.td
@@ -5158,6 +5158,9 @@ def coverage_version_EQ : Joined<["-"], 
"coverage-version=">,
 def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">,

  HelpText<"Dump the coverage mapping records, for testing">,
  MarshallingInfoFlag>;

+def no_unused_coverage : Flag<["-"], "no-unused-coverage">,
+  HelpText<"Turn off coverage mapping for code that is not emitted">,
+  MarshallingInfoFlag>;
 def fuse_register_sized_bitfield_access: Flag<["-"], 
"fuse-register-sized-bitfield-access">,

  HelpText<"Use register sized accesses to bit-fields, when possible.">,
  MarshallingInfoFlag>;

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 9c76648f5f19..bc968d888e11 100644

- a/clang/lib/CodeGen/CodeGenModule.cpp

+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -538,7 +538,9 @@ void CodeGenModule::Release() {

  EmitCtorList(GlobalDtors, "llvm.global_dtors");
  EmitGlobalAnnotations();
  EmitStaticExternCAliases();

- EmitDeferredUnusedCoverageMappings();

+  if (!CodeGenOpts.NoUnusedCoverage) {
+EmitDeferredUnusedCoverageMappings();
+  }

  CodeGenPGO(*this).setValueProfilingFlag(getModule());
  if (CoverageMapping)
CoverageMapping->emit();


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121446

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -538,7 +538,9 @@
   EmitCtorList(GlobalDtors, "llvm.global_dtors");
   EmitGlobalAnnotations();
   EmitStaticExternCAliases();
-  EmitDeferredUnusedCoverageMappings();
+  if (!CodeGenOpts.NoUnusedCoverage) {
+EmitDeferredUnusedCoverageMappings();
+  }
   CodeGenPGO(*this).setValueProfilingFlag(getModule());
   if (CoverageMapping)
 CoverageMapping->emit();
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5158,6 +5158,9 @@
 def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">,
   HelpText<"Dump the coverage mapping records, for testing">,
   MarshallingInfoFlag>;
+def no_unused_coverage : Flag<["-"], "no-unused-coverage">,
+  HelpText<"Turn off coverage mapping for code that is not emitted">,
+  MarshallingInfoFlag>;
 def fuse_register_sized_bitfield_access: Flag<["-"], 
"fuse-register-sized-bitfield-access">,
   HelpText<"Use register sized accesses to bit-fields, when possible.">,
   MarshallingInfoFlag>;
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -211,6 +211,8 @@
///< enable code coverage analysis.
 CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping
///< regions.
+CODEGENOPT(NoUnusedCoverage , 1, 0) ///< Turn off coverage mapping for code 
that
+///< is not emitted.

   /// If -fpcc-struct-return or -freg-struct-return is specified.
 ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, 
SRCK_Default)


Index: 

[PATCH] D120989: Support debug info for alias variable

2022-03-10 Thread Kavitha Natarajan via Phabricator via cfe-commits
kavitha-natarajan updated this revision to Diff 414577.
kavitha-natarajan added a comment.

@aprantl Updated the comments following LLVM coding style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120989

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/debug-info-alias.c

Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+
+// CHECK-DAG: [[ENTITY1:![0-9]+]] = distinct !DIGlobalVariable(name: "aliased_global"
+// CHECK-DAG: [[ENTITY2:![0-9]+]] = distinct !DIGlobalVariable(name: "aliased_global_2"
+// CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "__global_alias", scope: !2, entity: [[ENTITY1]]
+// CHECK-DAG: [[ENTITY3:![0-9]+]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "global_alias_2", scope: !2, entity: [[ENTITY2]]
+// CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "__global_alias_2_alias", scope: !2, entity: [[ENTITY3]]
+
+int aliased_global = 1;
+extern int __attribute__((alias("aliased_global"))) __global_alias;
+
+// Recursive alias:
+int aliased_global_2 = 2;
+extern int __attribute__((alias("aliased_global_2"))) global_alias_2;
+extern int __attribute__((alias("global_alias_2"))) __global_alias_2_alias;
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1213,6 +1213,7 @@
 
   StringRef getMangledName(GlobalDecl GD);
   StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD);
+  const GlobalDecl getMangledNameDecl(StringRef);
 
   void EmitTentativeDefinition(const VarDecl *D);
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1498,6 +1498,16 @@
   return Result.first->first();
 }
 
+const GlobalDecl CodeGenModule::getMangledNameDecl(StringRef Name) {
+  auto it = MangledDeclNames.begin();
+  while (it != MangledDeclNames.end()) {
+if (it->second == Name)
+  return it->first;
+it++;
+  }
+  return GlobalDecl();
+}
+
 llvm::GlobalValue *CodeGenModule::GetGlobalValue(StringRef Name) {
   return getModule().getNamedValue(Name);
 }
@@ -5164,6 +5174,13 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo()) {
+  DI->EmitGlobalAlias(cast(GA->getAliasee()), GD);
+}
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -152,8 +152,10 @@
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
-  /// using declarations) that aren't covered by other more specific caches.
+  /// using declarations and global alias variables) that aren't covered
+  /// by other more specific caches.
   llvm::DenseMap DeclCache;
+  llvm::DenseMap ImportedDeclCache;
   llvm::DenseMap NamespaceCache;
   llvm::DenseMap
   NamespaceAliasCache;
@@ -512,6 +514,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global variable alias.
+  void EmitGlobalAlias(const llvm::GlobalValue *GV, const GlobalDecl Decl);
+
   /// Emit C++ using directive.
   void EmitUsingDirective(const UsingDirectiveDecl );
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3911,6 +3911,17 @@
 return dyn_cast_or_null(N);
   }
 
+  // Search imported declaration cache if it is already defined
+  // as imported declaration.
+  auto IE = ImportedDeclCache.find(D->getCanonicalDecl());
+
+  if (IE != ImportedDeclCache.end()) {
+auto N = IE->second;
+if (auto *GVE = dyn_cast_or_null(N))
+  return cast(GVE);
+return dyn_cast_or_null(N);
+  }
+
   // No definition for now. Emit a forward definition that might be
   // merged with a potential upcoming definition.
   if (const auto *FD = dyn_cast(D))
@@ -5467,6 +5478,47 @@
   Var->addDebugInfo(GVE);
 }
 
+void CGDebugInfo::EmitGlobalAlias(const llvm::GlobalValue *GV,
+  const GlobalDecl GD) {
+
+  assert(GV);
+
+  if 

[PATCH] D121445: [Clang][CSKY] Add the CSKY target and compiler driver

2022-03-10 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu created this revision.
zixuan-wu added reviewers: rengolin, kito.cheng, rsmith, asb, DavidSpickett, 
kaz7.
Herald added subscribers: krytarowski, mgorny.
Herald added a project: All.
zixuan-wu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add CSKY target toolchains to support csky in linux and elf environment.

It can leverage the basic universal Linux toolchain for linux environment, and 
only add some compile or link parameters. For elf environment, add a 
CSKYToolChain to support compile and link.

Also add some parameters into basic codebase of clang driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121445

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/CSKY.cpp
  clang/lib/Basic/Targets/CSKY.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Arch/CSKY.cpp
  clang/lib/Driver/ToolChains/Arch/CSKY.h
  clang/lib/Driver/ToolChains/CSKYToolChain.cpp
  clang/lib/Driver/ToolChains/CSKYToolChain.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/multilib_csky_linux_sdk/csky-linux-gnuabiv2/bin/ld
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/csky-linux-gnuabiv2/libc/ck860v/lib/.keep
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/csky-linux-gnuabiv2/libc/ck860v/usr/lib/crt1.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/csky-linux-gnuabiv2/libc/lib/.keep
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/csky-linux-gnuabiv2/libc/usr/lib/crt1.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/ck860v/crtbegin.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/ck860v/crtend.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/ck860v/crti.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/ck860v/crtn.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/crtbegin.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/crtend.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/crti.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/crtn.o
  clang/test/Driver/csky-arch.c
  clang/test/Driver/csky-cpus.c
  clang/test/Driver/csky-toolchain.c
  clang/test/Preprocessor/csky-target-features.c
  clang/test/Preprocessor/init-csky.c

Index: clang/test/Preprocessor/init-csky.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-csky.c
@@ -0,0 +1,212 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=csky < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix=CSKY %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=csky-unknown-linux < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefixes=CSKY,CSKY-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=csky \
+// RUN: -fforce-enable-int128 < /dev/null | FileCheck -match-full-lines \
+// RUN: -check-prefixes=CSKY,CSKY-INT128 %s
+// CSKY: #define _ILP32 1
+// CSKY: #define __ATOMIC_ACQUIRE 2
+// CSKY: #define __ATOMIC_ACQ_REL 4
+// CSKY: #define __ATOMIC_CONSUME 1
+// CSKY: #define __ATOMIC_RELAXED 0
+// CSKY: #define __ATOMIC_RELEASE 3
+// CSKY: #define __ATOMIC_SEQ_CST 5
+// CSKY: #define __BIGGEST_ALIGNMENT__ 4
+// CSKY: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// CSKY: #define __CHAR16_TYPE__ unsigned short
+// CSKY: #define __CHAR32_TYPE__ unsigned int
+// CSKY: #define __CHAR_BIT__ 8
+// CSKY: #define __DBL_DECIMAL_DIG__ 17
+// CSKY: #define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// CSKY: #define __DBL_DIG__ 15
+// CSKY: #define __DBL_EPSILON__ 2.2204460492503131e-16
+// CSKY: #define __DBL_HAS_DENORM__ 1
+// CSKY: #define __DBL_HAS_INFINITY__ 1
+// CSKY: #define __DBL_HAS_QUIET_NAN__ 1
+// CSKY: #define __DBL_MANT_DIG__ 53
+// CSKY: #define __DBL_MAX_10_EXP__ 308
+// CSKY: #define __DBL_MAX_EXP__ 1024
+// CSKY: #define __DBL_MAX__ 1.7976931348623157e+308
+// CSKY: #define __DBL_MIN_10_EXP__ (-307)
+// CSKY: #define __DBL_MIN_EXP__ (-1021)
+// CSKY: #define __DBL_MIN__ 2.2250738585072014e-308
+// CSKY: #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
+// CSKY: #define __ELF__ 1
+// CSKY: #define __FINITE_MATH_ONLY__ 0
+// CSKY: #define __FLT_DECIMAL_DIG__ 9
+// CSKY: #define __FLT_DENORM_MIN__ 1.40129846e-45F
+// CSKY: #define __FLT_DIG__ 6
+// CSKY: #define __FLT_EPSILON__ 1.19209290e-7F
+// CSKY: #define __FLT_HAS_DENORM__ 1
+// CSKY: #define __FLT_HAS_INFINITY__ 1
+// CSKY: #define __FLT_HAS_QUIET_NAN__ 1
+// CSKY: #define __FLT_MANT_DIG__ 24
+// CSKY: #define __FLT_MAX_10_EXP__ 38

[PATCH] D121441: [PowerPC][NFC] Add atomic alignments and ops tests for powerpc

2022-03-10 Thread Kai Luo via Phabricator via cfe-commits
lkail updated this revision to Diff 414583.
lkail added a comment.

Add `-verify`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121441

Files:
  clang/test/CodeGen/PowerPC/atomic-alignment.c
  clang/test/Sema/atomic-ops.c


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -4,6 +4,8 @@
 // RUN:   -fsyntax-only -triple=i686-linux-android -std=c11
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/CodeGen/PowerPC/atomic-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/atomic-alignment.c
@@ -0,0 +1,38 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -verify -triple powerpc-unkonwn-unknown -emit-llvm -o - %s 
| \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -verify -triple powerpc64le-unkonwn-linux -emit-llvm -o - 
%s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -verify -triple powerpc64-unkonwn-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+
+// PPC: @c = global i8 0, align 1{{$}}
+_Atomic(char) c; // expected-no-diagnostics
+
+// PPC: @s = global i16 0, align 2{{$}}
+_Atomic(short) s; // expected-no-diagnostics
+
+// PPC: @i = global i32 0, align 4{{$}}
+_Atomic(int) i; // expected-no-diagnostics
+
+// PPC32: @l = global i32 0, align 4{{$}}
+// PPC64: @l = global i64 0, align 8{{$}}
+_Atomic(long) l; // expected-no-diagnostics
+
+// PPC: @ll = global i64 0, align 8{{$}}
+_Atomic(long long) ll; // expected-no-diagnostics
+
+typedef struct {
+  char x[8];
+} O;
+
+// PPC32: @o = global %struct.O zeroinitializer, align 1{{$}}
+// PPC64: @o = global %struct.O zeroinitializer, align 8{{$}}
+_Atomic(O) o; // expected-no-diagnostics
+
+typedef struct {
+  char x[16];
+} Q;
+
+// PPC: @q = global %struct.Q zeroinitializer, align 1{{$}}
+_Atomic(Q) q; // expected-no-diagnostics


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -4,6 +4,8 @@
 // RUN:   -fsyntax-only -triple=i686-linux-android -std=c11
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/CodeGen/PowerPC/atomic-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/atomic-alignment.c
@@ -0,0 +1,38 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -verify -triple powerpc-unkonwn-unknown -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -verify -triple powerpc64le-unkonwn-linux -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -verify -triple powerpc64-unkonwn-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+
+// PPC: @c = global i8 0, align 1{{$}}
+_Atomic(char) c; // expected-no-diagnostics
+
+// PPC: @s = global i16 0, align 2{{$}}
+_Atomic(short) s; // expected-no-diagnostics
+
+// PPC: @i = global i32 0, align 4{{$}}
+_Atomic(int) i; // expected-no-diagnostics
+
+// PPC32: @l = global i32 0, align 4{{$}}
+// PPC64: @l = global i64 0, align 8{{$}}
+_Atomic(long) l; // expected-no-diagnostics
+
+// PPC: @ll = global i64 0, align 8{{$}}
+_Atomic(long long) ll; // expected-no-diagnostics
+
+typedef struct {
+  char x[8];
+} O;
+
+// PPC32: @o = global %struct.O zeroinitializer, align 1{{$}}
+// PPC64: @o = global %struct.O zeroinitializer, align 8{{$}}
+_Atomic(O) o; // expected-no-diagnostics
+
+typedef struct {
+  char x[16];
+} Q;
+
+// PPC: @q = global %struct.Q zeroinitializer, align 1{{$}}
+_Atomic(Q) q; // expected-no-diagnostics
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121076: [MLIR][Python] Add SCFIfOp Python binding

2022-03-10 Thread Hongzheng Chen via Phabricator via cfe-commits
chhzh123 added a comment.

Hi @ftynse , could you please take a look at it and see if there is anything 
that should be changed? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121076

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


[PATCH] D121441: [PowerPC][NFC] Add atomic alignments and ops tests for powerpc

2022-03-10 Thread Kai Luo via Phabricator via cfe-commits
lkail updated this revision to Diff 414575.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121441

Files:
  clang/test/CodeGen/PowerPC/atomic-alignment.c
  clang/test/Sema/atomic-ops.c


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -4,6 +4,8 @@
 // RUN:   -fsyntax-only -triple=i686-linux-android -std=c11
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/CodeGen/PowerPC/atomic-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/atomic-alignment.c
@@ -0,0 +1,38 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unkonwn-unknown -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -triple powerpc64le-unkonwn-linux -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -triple powerpc64-unkonwn-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+
+// PPC: @c = global i8 0, align 1{{$}}
+_Atomic(char) c;
+
+// PPC: @s = global i16 0, align 2{{$}}
+_Atomic(short) s;
+
+// PPC: @i = global i32 0, align 4{{$}}
+_Atomic(int) i;
+
+// PPC32: @l = global i32 0, align 4{{$}}
+// PPC64: @l = global i64 0, align 8{{$}}
+_Atomic(long) l;
+
+// PPC: @ll = global i64 0, align 8{{$}}
+_Atomic(long long) ll;
+
+typedef struct {
+  char x[8];
+} O;
+
+// PPC32: @o = global %struct.O zeroinitializer, align 1{{$}}
+// PPC64: @o = global %struct.O zeroinitializer, align 8{{$}}
+_Atomic(O) o;
+
+typedef struct {
+  char x[16];
+} Q;
+
+// PPC: @q = global %struct.Q zeroinitializer, align 1{{$}}
+_Atomic(Q) q;


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -4,6 +4,8 @@
 // RUN:   -fsyntax-only -triple=i686-linux-android -std=c11
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/CodeGen/PowerPC/atomic-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/atomic-alignment.c
@@ -0,0 +1,38 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unkonwn-unknown -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -triple powerpc64le-unkonwn-linux -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -triple powerpc64-unkonwn-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+
+// PPC: @c = global i8 0, align 1{{$}}
+_Atomic(char) c;
+
+// PPC: @s = global i16 0, align 2{{$}}
+_Atomic(short) s;
+
+// PPC: @i = global i32 0, align 4{{$}}
+_Atomic(int) i;
+
+// PPC32: @l = global i32 0, align 4{{$}}
+// PPC64: @l = global i64 0, align 8{{$}}
+_Atomic(long) l;
+
+// PPC: @ll = global i64 0, align 8{{$}}
+_Atomic(long long) ll;
+
+typedef struct {
+  char x[8];
+} O;
+
+// PPC32: @o = global %struct.O zeroinitializer, align 1{{$}}
+// PPC64: @o = global %struct.O zeroinitializer, align 8{{$}}
+_Atomic(O) o;
+
+typedef struct {
+  char x[16];
+} Q;
+
+// PPC: @q = global %struct.Q zeroinitializer, align 1{{$}}
+_Atomic(Q) q;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121441: [PowerPC][NFC] Add atomic alignments and ops tests for powerpc

2022-03-10 Thread Kai Luo via Phabricator via cfe-commits
lkail updated this revision to Diff 414574.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121441

Files:
  clang/test/CodeGen/PowerPC/atomic-alignment.c
  clang/test/Sema/atomic-ops.c


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -4,6 +4,8 @@
 // RUN:   -fsyntax-only -triple=i686-linux-android -std=c11
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/CodeGen/PowerPC/atomic-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/atomic-alignment.c
@@ -0,0 +1,38 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unkonwn-unknown -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -triple powerpc64le-unkonwn-linux -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -triple powerpc64-unkonwn-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+
+// PPC: @c = global i8 0, align 1{{$}}
+_Atomic(char) c;
+
+// PPC: @s = global i16 0, align 2{{$}}
+_Atomic(short) s;
+
+// PPC: @i = global i32 0, align 4{{$}}
+_Atomic(int) i;
+
+// PPC32: @l = global i32 0, align 4{{$}}
+// PPC64: @l = global i64 0, align 8{{$}}
+_Atomic(long) l;
+
+// PPC: @ll = global i64 0, align 8
+_Atomic(long long) ll;
+
+typedef struct {
+  char x[8];
+} O;
+
+// PPC32: @o = global %struct.O zeroinitializer, align 1{{$}}
+// PPC64: @o = global %struct.O zeroinitializer, align 8{{$}}
+_Atomic(O) o;
+
+typedef struct {
+  char x[16];
+} Q;
+
+// PPC: @q = global %struct.Q zeroinitializer, align 1{{$}}
+_Atomic(Q) q;


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -4,6 +4,8 @@
 // RUN:   -fsyntax-only -triple=i686-linux-android -std=c11
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/CodeGen/PowerPC/atomic-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/atomic-alignment.c
@@ -0,0 +1,38 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unkonwn-unknown -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -triple powerpc64le-unkonwn-linux -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -triple powerpc64-unkonwn-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+
+// PPC: @c = global i8 0, align 1{{$}}
+_Atomic(char) c;
+
+// PPC: @s = global i16 0, align 2{{$}}
+_Atomic(short) s;
+
+// PPC: @i = global i32 0, align 4{{$}}
+_Atomic(int) i;
+
+// PPC32: @l = global i32 0, align 4{{$}}
+// PPC64: @l = global i64 0, align 8{{$}}
+_Atomic(long) l;
+
+// PPC: @ll = global i64 0, align 8
+_Atomic(long long) ll;
+
+typedef struct {
+  char x[8];
+} O;
+
+// PPC32: @o = global %struct.O zeroinitializer, align 1{{$}}
+// PPC64: @o = global %struct.O zeroinitializer, align 8{{$}}
+_Atomic(O) o;
+
+typedef struct {
+  char x[16];
+} Q;
+
+// PPC: @q = global %struct.Q zeroinitializer, align 1{{$}}
+_Atomic(Q) q;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121434: [clang-format][NFC] Group QualifierAlignment with other C++ passes

2022-03-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 414572.
owenpan added a comment.

Swapped the order of the definitions of `BracesRemover` and `BracesInserter`.


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

https://reviews.llvm.org/D121434

Files:
  clang/lib/Format/Format.cpp

Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1784,9 +1784,9 @@
 
 namespace {
 
-class BracesRemover : public TokenAnalyzer {
+class BracesInserter : public TokenAnalyzer {
 public:
-  BracesRemover(const Environment , const FormatStyle )
+  BracesInserter(const Environment , const FormatStyle )
   : TokenAnalyzer(Env, Style) {}
 
   std::pair
@@ -1795,40 +1795,40 @@
   FormatTokenLexer ) override {
 AffectedRangeMgr.computeAffectedLines(AnnotatedLines);
 tooling::Replacements Result;
-removeBraces(AnnotatedLines, Result);
+insertBraces(AnnotatedLines, Result);
 return {Result, 0};
   }
 
 private:
-  void removeBraces(SmallVectorImpl ,
+  void insertBraces(SmallVectorImpl ,
 tooling::Replacements ) {
 const auto  = Env.getSourceManager();
 for (AnnotatedLine *Line : Lines) {
-  removeBraces(Line->Children, Result);
+  insertBraces(Line->Children, Result);
   if (!Line->Affected)
 continue;
   for (FormatToken *Token = Line->First; Token && !Token->Finalized;
Token = Token->Next) {
-if (!Token->Optional)
+if (Token->BraceCount == 0)
   continue;
-assert(Token->isOneOf(tok::l_brace, tok::r_brace));
-assert(Token->Next || Token == Line->Last);
-const auto Start =
-Token == Line->Last || (Token->Next->is(tok::kw_else) &&
-Token->Next->NewlinesBefore > 0)
-? Token->WhitespaceRange.getBegin()
-: Token->Tok.getLocation();
-const auto Range =
-CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
-cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));
+std::string Brace;
+if (Token->BraceCount < 0) {
+  assert(Token->BraceCount == -1);
+  Brace = '{';
+} else {
+  Brace = '\n' + std::string(Token->BraceCount, '}');
+}
+Token->BraceCount = 0;
+const auto Start = Token->Tok.getEndLoc();
+cantFail(Result.add(tooling::Replacement(SourceMgr, Start, 0, Brace)));
   }
 }
   }
 };
 
-class BracesInserter : public TokenAnalyzer {
+class BracesRemover : public TokenAnalyzer {
 public:
-  BracesInserter(const Environment , const FormatStyle )
+  BracesRemover(const Environment , const FormatStyle )
   : TokenAnalyzer(Env, Style) {}
 
   std::pair
@@ -1837,32 +1837,32 @@
   FormatTokenLexer ) override {
 AffectedRangeMgr.computeAffectedLines(AnnotatedLines);
 tooling::Replacements Result;
-insertBraces(AnnotatedLines, Result);
+removeBraces(AnnotatedLines, Result);
 return {Result, 0};
   }
 
 private:
-  void insertBraces(SmallVectorImpl ,
+  void removeBraces(SmallVectorImpl ,
 tooling::Replacements ) {
 const auto  = Env.getSourceManager();
 for (AnnotatedLine *Line : Lines) {
-  insertBraces(Line->Children, Result);
+  removeBraces(Line->Children, Result);
   if (!Line->Affected)
 continue;
   for (FormatToken *Token = Line->First; Token && !Token->Finalized;
Token = Token->Next) {
-if (Token->BraceCount == 0)
+if (!Token->Optional)
   continue;
-std::string Brace;
-if (Token->BraceCount < 0) {
-  assert(Token->BraceCount == -1);
-  Brace = '{';
-} else {
-  Brace = '\n' + std::string(Token->BraceCount, '}');
-}
-Token->BraceCount = 0;
-const auto Start = Token->Tok.getEndLoc();
-cantFail(Result.add(tooling::Replacement(SourceMgr, Start, 0, Brace)));
+assert(Token->isOneOf(tok::l_brace, tok::r_brace));
+assert(Token->Next || Token == Line->Last);
+const auto Start =
+Token == Line->Last || (Token->Next->is(tok::kw_else) &&
+Token->Next->NewlinesBefore > 0)
+? Token->WhitespaceRange.getBegin()
+: Token->Tok.getLocation();
+const auto Range =
+CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
+cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));
   }
 }
   }
@@ -3169,18 +3169,18 @@
   typedef std::function(
   const Environment &)>
   AnalyzerPass;
-  SmallVector Passes;
-
-  if (Style.isCpp() && Style.QualifierAlignment != FormatStyle::QAS_Leave) {
-Passes.emplace_back([&](const Environment ) {
-  return QualifierAlignmentFixer(Env, Expanded, Code, Ranges,
-  

[PATCH] D121441: [PowerPC][NFC] Add atomic alignments and ops tests for powerpc

2022-03-10 Thread Kai Luo via Phabricator via cfe-commits
lkail created this revision.
lkail added reviewers: hubert.reinterpretcast, jsji, xingxue, PowerPC.
Herald added subscribers: steven.zhang, shchenz, nemanjai.
Herald added a project: All.
lkail requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

PowerPC is lacking tests checking `_Atomic` alignment in cfe. Adding these 
tests since we're going to make change to align with gcc on Linux.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121441

Files:
  clang/test/CodeGen/PowerPC/atomic-alignment.c
  clang/test/Sema/atomic-ops.c


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -4,6 +4,8 @@
 // RUN:   -fsyntax-only -triple=i686-linux-android -std=c11
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/CodeGen/PowerPC/atomic-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/atomic-alignment.c
@@ -0,0 +1,38 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -verify -triple powerpc-unkonwn-unknown -emit-llvm -o - %s 
| \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -verify -triple powerpc64le-unkonwn-linux -emit-llvm -o - 
%s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -verify -triple powerpc64-unkonwn-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+
+// PPC: @c = global i8 0, align 1
+_Atomic(char) c;
+
+// PPC: @s = global i16 0, align 2
+_Atomic(short) s;
+
+// PPC: @i = global i32 0, align 4
+_Atomic(int) i;
+
+// PPC32: @l = global i32 0, align 4
+// PPC64: @l = global i64 0, align 8
+_Atomic(long) l;
+
+// PPC: @ll = global i64 0, align 8
+_Atomic(long long) ll;
+
+typedef struct {
+  char x[8];
+} O;
+
+// PPC32: @o = global %struct.O zeroinitializer, align 1
+// PPC64: @o = global %struct.O zeroinitializer, align 8
+_Atomic(O) o;
+
+typedef struct {
+  char x[16];
+} Q;
+
+// PPC: @q = global %struct.Q zeroinitializer, align 1
+_Atomic(Q) q;


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -4,6 +4,8 @@
 // RUN:   -fsyntax-only -triple=i686-linux-android -std=c11
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/CodeGen/PowerPC/atomic-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/atomic-alignment.c
@@ -0,0 +1,38 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -verify -triple powerpc-unkonwn-unknown -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -verify -triple powerpc64le-unkonwn-linux -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -verify -triple powerpc64-unkonwn-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+
+// PPC: @c = global i8 0, align 1
+_Atomic(char) c;
+
+// PPC: @s = global i16 0, align 2
+_Atomic(short) s;
+
+// PPC: @i = global i32 0, align 4
+_Atomic(int) i;
+
+// PPC32: @l = global i32 0, align 4
+// PPC64: @l = global i64 0, align 8
+_Atomic(long) l;
+
+// PPC: @ll = global i64 0, align 8
+_Atomic(long long) ll;
+
+typedef struct {
+  char x[8];
+} O;
+
+// PPC32: @o = global %struct.O zeroinitializer, align 1
+// PPC64: @o = global %struct.O zeroinitializer, align 8
+_Atomic(O) o;
+
+typedef struct {
+  char x[16];
+} Q;
+
+// PPC: @q = global %struct.Q zeroinitializer, align 1
+_Atomic(Q) q;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121176: [ASTStructuralEquivalence] Add support for comparing ObjCCategoryDecl.

2022-03-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 414565.
vsapsai added a comment.

Fix tests on Debian by using `-fobjc-nonfragile-abi` explicitly as declaring 
ivars in extensions is supported only with non-fragile ABI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121176

Files:
  clang/include/clang/Testing/CommandLineArgs.h
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/Testing/CommandLineArgs.cpp
  clang/unittests/AST/MatchVerifier.h
  clang/unittests/AST/StructuralEquivalenceTest.cpp

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1120,6 +1120,187 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+struct StructuralEquivalenceObjCCategoryTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, MatchinCategoryNames) {
+  auto t = makeDecls("@interface A @end @interface A(X) @end",
+   "@interface A @end @interface A(X) @end",
+   Lang_OBJC, objcCategoryDecl());
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, CategoriesForDifferentClasses) {
+  auto t = makeDecls("@interface A @end @interface A(X) @end",
+   "@interface B @end @interface B(X) @end",
+   Lang_OBJC, objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, CategoriesWithDifferentNames) {
+  auto t = makeDecls("@interface A @end @interface A(X) @end",
+   "@interface A @end @interface A(Y) @end",
+   Lang_OBJC, objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, CategoryAndExtension) {
+  auto t = makeDecls("@interface A @end @interface A(X) @end",
+   "@interface A @end @interface A() @end",
+   Lang_OBJC, objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, MatchingProtocols) {
+  auto t = makeDecls(
+  "@protocol P @end @interface A @end @interface A(X) @end",
+  "@protocol P @end @interface A @end @interface A(X) @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentProtocols) {
+  auto t = makeDecls(
+  "@protocol P @end @interface A @end @interface A(X) @end",
+  "@protocol Q @end @interface A @end @interface A(X) @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentProtocolsOrder) {
+  auto t = makeDecls(
+  "@protocol P @end @protocol Q @end @interface A @end @interface A(X) @end",
+  "@protocol P @end @protocol Q @end @interface A @end @interface A(X) @end",
+  Lang_OBJC, objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, MatchingIvars) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { int x; } @end",
+  "@interface A @end @interface A() { int x; } @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentIvarName) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { int x; } @end",
+  "@interface A @end @interface A() { int y; } @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentIvarType) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { int x; } @end",
+  "@interface A @end @interface A() { float x; } @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentIvarBitfieldWidth) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { int x: 1; } @end",
+  "@interface A @end @interface A() { int x: 2; } @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentIvarVisibility) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { @public int x; } @end",
+  "@interface A @end @interface A() { @protected int x; } @end", Lang_OBJC,
+  objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceObjCCategoryTest, DifferentIvarNumber) {
+  auto t = makeDecls(
+  "@interface A @end @interface A() { int x; } @end",
+  "@interface A @end @interface A() {} @end", 

[PATCH] D121431: Split up large test files(over 10k lines) under clang/test/CodeGen/RISCV including:

2022-03-10 Thread Brandon Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG25df633c243f: Split up large test files(over 10k lines) 
under clang/test/CodeGen/RISCV… (authored by 4vtomat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121431

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxseg_mask_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxseg_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxseg_mask_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxseg_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsoxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsoxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsuxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsuxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg_mask_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxseg_mask_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxseg_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsoxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsoxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsuxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsuxseg_mask.c

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


[PATCH] D120976: [AMDGPU] Add llvm.amdgcn.s.setprio intrinsic

2022-03-10 Thread Austin Kerbow via Phabricator via cfe-commits
kerbowa updated this revision to Diff 414559.
kerbowa added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add clang builtin and tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120976

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  clang/test/SemaOpenCL/builtins-amdgcn-error.cl
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/SOPInstructions.td
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setprio.ll

Index: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setprio.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setprio.ll
@@ -0,0 +1,49 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -march=amdgcn -mcpu=gfx90a -show-mc-encoding -verify-machineinstrs < %s | FileCheck -check-prefix=GFX9 %s
+; RUN: llc -march=amdgcn -show-mc-encoding -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
+; RUN: llc -global-isel -march=amdgcn -show-mc-encoding -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
+; RUN: llc -global-isel -march=amdgcn -mcpu=gfx90a -show-mc-encoding -verify-machineinstrs < %s | FileCheck -check-prefix=GFX9 %s
+
+declare void @llvm.amdgcn.s.setprio(i16) #0
+
+define void @test_llvm_amdgcn_s_setprio() #0 {
+; GFX9-LABEL: test_llvm_amdgcn_s_setprio:
+; GFX9:   ; %bb.0:
+; GFX9-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
+; GFX9-NEXT:s_setprio 0 ; encoding: [0x00,0x00,0x8f,0xbf]
+; GFX9-NEXT:s_setprio 1 ; encoding: [0x01,0x00,0x8f,0xbf]
+; GFX9-NEXT:s_setprio 2 ; encoding: [0x02,0x00,0x8f,0xbf]
+; GFX9-NEXT:s_setprio 3 ; encoding: [0x03,0x00,0x8f,0xbf]
+; GFX9-NEXT:s_setprio 10 ; encoding: [0x0a,0x00,0x8f,0xbf]
+; GFX9-NEXT:s_setprio -1 ; encoding: [0xff,0xff,0x8f,0xbf]
+; GFX9-NEXT:s_setprio 0 ; encoding: [0x00,0x00,0x8f,0xbf]
+; GFX9-NEXT:s_setprio 1 ; encoding: [0x01,0x00,0x8f,0xbf]
+; GFX9-NEXT:s_setprio -1 ; encoding: [0xff,0xff,0x8f,0xbf]
+; GFX9-NEXT:s_setpc_b64 s[30:31] ; encoding: [0x1e,0x1d,0x80,0xbe]
+;
+; SI-LABEL: test_llvm_amdgcn_s_setprio:
+; SI:   ; %bb.0:
+; SI-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
+; SI-NEXT:s_setprio 0 ; encoding: [0x00,0x00,0x8f,0xbf]
+; SI-NEXT:s_setprio 1 ; encoding: [0x01,0x00,0x8f,0xbf]
+; SI-NEXT:s_setprio 2 ; encoding: [0x02,0x00,0x8f,0xbf]
+; SI-NEXT:s_setprio 3 ; encoding: [0x03,0x00,0x8f,0xbf]
+; SI-NEXT:s_setprio 10 ; encoding: [0x0a,0x00,0x8f,0xbf]
+; SI-NEXT:s_setprio -1 ; encoding: [0xff,0xff,0x8f,0xbf]
+; SI-NEXT:s_setprio 0 ; encoding: [0x00,0x00,0x8f,0xbf]
+; SI-NEXT:s_setprio 1 ; encoding: [0x01,0x00,0x8f,0xbf]
+; SI-NEXT:s_setprio -1 ; encoding: [0xff,0xff,0x8f,0xbf]
+; SI-NEXT:s_setpc_b64 s[30:31] ; encoding: [0x1e,0x20,0x80,0xbe]
+  call void @llvm.amdgcn.s.setprio(i16 0)
+  call void @llvm.amdgcn.s.setprio(i16 1)
+  call void @llvm.amdgcn.s.setprio(i16 2)
+  call void @llvm.amdgcn.s.setprio(i16 3)
+  call void @llvm.amdgcn.s.setprio(i16 10)
+  call void @llvm.amdgcn.s.setprio(i16 65535)
+  call void @llvm.amdgcn.s.setprio(i16 65536)
+  call void @llvm.amdgcn.s.setprio(i16 65537)
+  call void @llvm.amdgcn.s.setprio(i16 -1)
+  ret void
+}
+
+attributes #0 = { nounwind }
Index: llvm/lib/Target/AMDGPU/SOPInstructions.td
===
--- llvm/lib/Target/AMDGPU/SOPInstructions.td
+++ llvm/lib/Target/AMDGPU/SOPInstructions.td
@@ -1278,7 +1278,10 @@
   let hasSideEffects = 1;
 }
 
-def S_SETPRIO : SOPP_Pseudo <"s_setprio" , (ins i16imm:$simm16), "$simm16">;
+def S_SETPRIO : SOPP_Pseudo <"s_setprio", (ins i16imm:$simm16), "$simm16",
+  [(int_amdgcn_s_setprio timm:$simm16)]> {
+  let hasSideEffects = 1;
+}
 
 let Uses = [EXEC, M0] in {
 // FIXME: Should this be mayLoad+mayStore?
Index: llvm/include/llvm/IR/IntrinsicsAMDGPU.td
===
--- llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1329,6 +1329,11 @@
   Intrinsic<[], [llvm_i32_ty], [ImmArg>, IntrNoMem,
 IntrHasSideEffects, IntrWillReturn]>;
 
+def int_amdgcn_s_setprio :
+  GCCBuiltin<"__builtin_amdgcn_s_setprio">,
+  Intrinsic<[], [llvm_i16_ty], [ImmArg>, IntrNoMem,
+IntrHasSideEffects, IntrWillReturn]>;
+
 def int_amdgcn_s_getreg :
   GCCBuiltin<"__builtin_amdgcn_s_getreg">,
   Intrinsic<[llvm_i32_ty], [llvm_i32_ty],
Index: clang/test/SemaOpenCL/builtins-amdgcn-error.cl
===
--- clang/test/SemaOpenCL/builtins-amdgcn-error.cl
+++ clang/test/SemaOpenCL/builtins-amdgcn-error.cl
@@ -54,6 +54,12 @@
   __builtin_amdgcn_s_decperflevel(x); 

[PATCH] D121434: [clang-format][NFC] Group QualifierAlignment with other C++ passes

2022-03-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, curdeius, HazardyKnusperkeks.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Also increases the initial size of Passes to 8.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121434

Files:
  clang/lib/Format/Format.cpp


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3169,18 +3169,18 @@
   typedef std::function(
   const Environment &)>
   AnalyzerPass;
-  SmallVector Passes;
-
-  if (Style.isCpp() && Style.QualifierAlignment != FormatStyle::QAS_Leave) {
-Passes.emplace_back([&](const Environment ) {
-  return QualifierAlignmentFixer(Env, Expanded, Code, Ranges,
- FirstStartColumn, NextStartColumn,
- LastStartColumn, FileName)
-  .process();
-});
-  }
+  SmallVector Passes;
 
   if (Style.isCpp()) {
+if (Style.QualifierAlignment != FormatStyle::QAS_Leave) {
+  Passes.emplace_back([&](const Environment ) {
+return QualifierAlignmentFixer(Env, Expanded, Code, Ranges,
+   FirstStartColumn, NextStartColumn,
+   LastStartColumn, FileName)
+.process();
+  });
+}
+
 if (Style.InsertBraces)
   Passes.emplace_back([&](const Environment ) {
 return BracesInserter(Env, Expanded).process();


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3169,18 +3169,18 @@
   typedef std::function(
   const Environment &)>
   AnalyzerPass;
-  SmallVector Passes;
-
-  if (Style.isCpp() && Style.QualifierAlignment != FormatStyle::QAS_Leave) {
-Passes.emplace_back([&](const Environment ) {
-  return QualifierAlignmentFixer(Env, Expanded, Code, Ranges,
- FirstStartColumn, NextStartColumn,
- LastStartColumn, FileName)
-  .process();
-});
-  }
+  SmallVector Passes;
 
   if (Style.isCpp()) {
+if (Style.QualifierAlignment != FormatStyle::QAS_Leave) {
+  Passes.emplace_back([&](const Environment ) {
+return QualifierAlignmentFixer(Env, Expanded, Code, Ranges,
+   FirstStartColumn, NextStartColumn,
+   LastStartColumn, FileName)
+.process();
+  });
+}
+
 if (Style.InsertBraces)
   Passes.emplace_back([&](const Environment ) {
 return BracesInserter(Env, Expanded).process();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121431: Split up large test files(over 10k lines) under clang/test/CodeGen/RISCV including:

2022-03-10 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121431

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


[PATCH] D121359: [AVR] Add more devices

2022-03-10 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 414538.

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

https://reviews.llvm.org/D121359

Files:
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/lib/Target/AVR/AVRDevices.td

Index: llvm/lib/Target/AVR/AVRDevices.td
===
--- llvm/lib/Target/AVR/AVRDevices.td
+++ llvm/lib/Target/AVR/AVRDevices.td
@@ -245,6 +245,7 @@
 def : Device<"avrtiny", FamilyTiny, ELFArchTiny>;
 
 // Specific MCUs
+// NOTE: This list has been synchronized with gcc-avr 5.4.0 and avr-libc 2.0.0.
 def : Device<"at90s1200", FamilyAVR0, ELFArchAVR1>;
 def : Device<"attiny11", FamilyAVR1, ELFArchAVR1>;
 def : Device<"attiny12", FamilyAVR1, ELFArchAVR1>;
@@ -299,6 +300,8 @@
 def : Device<"at90usb82", FamilyAVR35, ELFArchAVR35>;
 def : Device<"at90usb162", FamilyAVR35, ELFArchAVR35>;
 def : Device<"ata5505", FamilyAVR35, ELFArchAVR35>;
+def : Device<"ata6617c", FamilyAVR35, ELFArchAVR35>;
+def : Device<"ata664251", FamilyAVR35, ELFArchAVR35>;
 def : Device<"atmega8u2", FamilyAVR35, ELFArchAVR35>;
 def : Device<"atmega16u2", FamilyAVR35, ELFArchAVR35>;
 def : Device<"atmega32u2", FamilyAVR35, ELFArchAVR35>;
@@ -310,6 +313,7 @@
  [FeatureMultiplication, FeatureMOVW, FeatureLPMX, FeatureSPM]>;
 def : Device<"ata6285", FamilyAVR4, ELFArchAVR4>;
 def : Device<"ata6286", FamilyAVR4, ELFArchAVR4>;
+def : Device<"ata6612c", FamilyAVR4, ELFArchAVR4>;
 def : Device<"atmega48", FamilyAVR4, ELFArchAVR4>;
 def : Device<"atmega48a", FamilyAVR4, ELFArchAVR4>;
 def : Device<"atmega48pa", FamilyAVR4, ELFArchAVR4>;
@@ -331,8 +335,17 @@
 def : Device<"at90pwm3", FamilyAVR4, ELFArchAVR4>;
 def : Device<"at90pwm3b", FamilyAVR4, ELFArchAVR4>;
 def : Device<"at90pwm81", FamilyAVR4, ELFArchAVR4>;
+def : Device<"ata5702m322", FamilyAVR5, ELFArchAVR5>;
+def : Device<"ata5782", FamilyAVR5, ELFArchAVR5>;
 def : Device<"ata5790", FamilyAVR5, ELFArchAVR5>;
+def : Device<"ata5790n", FamilyAVR5, ELFArchAVR5>;
+def : Device<"ata5791", FamilyAVR5, ELFArchAVR5>;
 def : Device<"ata5795", FamilyAVR5, ELFArchAVR5>;
+def : Device<"ata5831", FamilyAVR5, ELFArchAVR5>;
+def : Device<"ata6613c", FamilyAVR5, ELFArchAVR5>;
+def : Device<"ata6614q", FamilyAVR5, ELFArchAVR5>;
+def : Device<"ata8210", FamilyAVR5, ELFArchAVR5>;
+def : Device<"ata8510", FamilyAVR5, ELFArchAVR5>;
 def : Device<"atmega16", FamilyAVR5, ELFArchAVR5>;
 def : Device<"atmega16a", FamilyAVR5, ELFArchAVR5>;
 def : Device<"atmega161", FamilyAVR3, ELFArchAVR5,
@@ -411,6 +424,7 @@
 def : Device<"atmega32hvb", FamilyAVR5, ELFArchAVR5>;
 def : Device<"atmega32hvbrevb", FamilyAVR5, ELFArchAVR5>;
 def : Device<"atmega64hve", FamilyAVR5, ELFArchAVR5>;
+def : Device<"atmega64hve2", FamilyAVR5, ELFArchAVR5>;
 def : Device<"at90can32", FamilyAVR5, ELFArchAVR5>;
 def : Device<"at90can64", FamilyAVR5, ELFArchAVR5>;
 def : Device<"at90pwm161", FamilyAVR5, ELFArchAVR5>;
@@ -452,7 +466,9 @@
 def : Device<"atxmega16d4", FamilyXMEGA, ELFArchXMEGA2>;
 def : Device<"atxmega32a4", FamilyXMEGA, ELFArchXMEGA2>;
 def : Device<"atxmega32a4u", FamilyXMEGAU, ELFArchXMEGA2>;
+def : Device<"atxmega32c3", FamilyXMEGAU, ELFArchXMEGA2>;
 def : Device<"atxmega32c4", FamilyXMEGAU, ELFArchXMEGA2>;
+def : Device<"atxmega32d3", FamilyXMEGA, ELFArchXMEGA2>;
 def : Device<"atxmega32d4", FamilyXMEGA, ELFArchXMEGA2>;
 def : Device<"atxmega32e5", FamilyXMEGAU, ELFArchXMEGA2>;
 def : Device<"atxmega16e5", FamilyXMEGAU, ELFArchXMEGA2>;
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -77,7 +77,7 @@
 
 // RUN: not %clang_cc1 -triple avr--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AVR
 // AVR: error: unknown target CPU 'not-a-cpu'
-// AVR-NEXT: note: valid target CPU values are: avr1, avr2, avr25, avr3, avr31, avr35, avr4, avr5, avr51, avr6, avrxmega1, avrxmega2, avrxmega3, avrxmega4, avrxmega5, avrxmega6, avrxmega7, avrtiny, at90s1200, attiny11, attiny12, attiny15, attiny28, at90s2313, at90s2323, at90s2333, at90s2343, attiny22, attiny26, at86rf401, at90s4414, at90s4433, at90s4434, at90s8515, at90c8534, at90s8535, ata5272, attiny13, attiny13a, attiny2313, attiny2313a, attiny24, attiny24a, attiny4313, attiny44, attiny44a, attiny84, attiny84a, attiny25, attiny45, attiny85, attiny261, attiny261a, attiny441, attiny461, attiny461a, attiny841, attiny861, attiny861a, attiny87, attiny43u, attiny48, attiny88, attiny828, at43usb355, at76c711, atmega103, at43usb320, attiny167, at90usb82, at90usb162, ata5505, atmega8u2, atmega16u2, atmega32u2, attiny1634, atmega8, ata6289, atmega8a, ata6285, ata6286, atmega48, atmega48a, atmega48pa, atmega48pb, atmega48p, atmega88, atmega88a, atmega88p, atmega88pa, atmega88pb, atmega8515, atmega8535, atmega8hva, at90pwm1, at90pwm2, at90pwm2b, 

[PATCH] D121431: Split up large test files(over 10k lines) under clang/test/CodeGen/RISCV including:

2022-03-10 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat created this revision.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, 
vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, 
Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb.
Herald added a project: All.
4vtomat requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: clang.

The llvm pre-merge test got timeout due to large test files, this commit
split up the files that have over 10k lines under clang/test/CodeGen/RISCV
into even smaller ones.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121431

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxseg_mask_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxseg_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxseg_mask_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxseg_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsoxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsoxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsuxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsuxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg_mask_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxseg_mask_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxseg_mf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsoxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsoxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsuxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsuxseg_mask.c

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


[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2067
+  // favor this processor.
+  TuneCPU = SD->getCPUName(GD.getMultiVersionIndex())->getName();
+}

andrew.w.kaylor wrote:
> Unfortunately, I don't think it's this easy. The list of names used for 
> cpu_specific doesn't come from the same place as the list of names used by 
> "tune-cpu". For one thing, the cpu_specific names can't contain the '-' 
> character, so we have names like "skylake_avx512" in cpu_specific that would 
> need to be translated to "skylake-avx512" for "tune-cpu". I believe the list 
> of valid names for "tune-cpu" comes from here: 
> https://github.com/llvm/llvm-project/blob/26cd258420c774254cc48330b1f4d23d353baf05/llvm/lib/Support/X86TargetParser.cpp#L294
> 
> Also, some of the aliases supported by cpu_specific don't have any 
> corresponding "tune-cpu" name. You happen to have picked one of these for the 
> test. I believe "core_4th_gen_avx" should map to "haswell".
Hmm... this is unfortunate.  I wonder if we add some 'translation' type field 
to the X86TargetParser.def entries?  Any idea who the right one to populate 
said list would be?


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

https://reviews.llvm.org/D121410

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


[PATCH] D121412: Complete the list of single-underscore keywords for MSVC compat.

2022-03-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

That makes sense, sure.  -fms-compatibility is on by default for clang-cl 
anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121412

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


[PATCH] D121412: Complete the list of single-underscore keywords for MSVC compat.

2022-03-10 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: rsmith.
rnk added a comment.

@rsmith has previously advocated for a policy of only permitting conforming 
language extensions under fms-extensions. These single underscore names are not 
in the implementors namespace, so he has argued they should be under 
fms-compatibility. At least, that's what I vaguely recall, any mistakes in 
attribution are mine.

With that in mind, would you be OK moving the *new* names over to KEYMSCOMPAT 
instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121412

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


[PATCH] D120474: [clang][deps] Remove '-fmodules-cache-path=' arguments

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120474

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


[PATCH] D120465: [clang][deps] Disable implicit module maps

2022-03-10 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp:269-273
+  // However, some module maps loaded implicitly during the dependency scan can
+  // describe anti-dependencies. That happens when the current module is marked
+  // as '[no_undeclared_includes]', doesn't 'use' module from such module map,
+  // but tries to import it anyway. We need to tell the explicit build about
+  // such module map for it to have the same semantics as the implicit build.

jansvoboda11 wrote:
> dexonsmith wrote:
> > Is there another long-term solution to this that could be pointed at with a 
> > FIXME? E.g., could the module map be encoded redundantly here? If so, what 
> > else would need to change to make that okay?
> I'm not sure I understand why this would warrant "long-term solution" or a 
> FIXME. This code handles an existing feature that just happens to be a corner 
> case from the dependency scanning point of view. (You can read up on the 
> feature [[ https://clang.llvm.org/docs/Modules.html | here ]].)
> 
> What do you mean by encoding the module map redundantly?
Yes, I know the feature.

... but I was probably wrong about how it affects the logic here.

I also now have two guesses at the scenario being handled here (previously I 
assumed (1)):

1. A textual include from a module that is not marked as used. I wasn't sure 
what you meant by "tries to import", but I guess I thought it was just "loads 
the module map and finds the textual header listed there". IIUC, there's no 
actual attempt to import a module when the only thing referenced from it is a 
textual header, but I could see how parsing the module map could affect the 
state anyway.

2. A modular include from a module that is not marked as used. Something like a 
`__has_include`, or a `#include` that fails but there's another search path 
with the same header. In this case, there'd be an actual import attempt, which 
would fail. And that could also affect state.

Can you clarify which scenario you need to handle? Or is it a 3rd?

> I'm not sure I understand why this would warrant "long-term solution" or a 
> FIXME.

This smells like a workaround to me. IIUC, sending in module maps that aren't 
actually "needed" except to reproduce side effects of failed queries.

My intuition is that the right long-term fix would involve isolate the failed 
queries from the compiler state in the scanning phase so that they don't have 
side effects. Then there would be no side effects to reproduce in the explicit 
build.

> What do you mean by encoding the module map redundantly?

I think I was confused about scanning vs building, thinking that a module using 
a textual include (1) could be copied into each module PCM that directly 
imports it. (I know that this wouldn't scale right now for various reasons, but 
I wondered if there was some way to get there... but regardless, seems like 
it's totally unrelated)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120465

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


[PATCH] D117730: [DNM][VFS] Do not overwrite the path when nesting RedirectingFileSystems

2022-03-10 Thread Ben Barham via Phabricator via cfe-commits
bnbarham abandoned this revision.
bnbarham added a comment.
Herald added a project: All.

Rather than trying to fix nested RedirectingFileSystems, I've instead put up a 
bunch of patches to simplify RedirectingFileSystem. This does mean we can't 
"chain" remappings any more, but that seems like a good change to me. See:
https://reviews.llvm.org/D121421
https://reviews.llvm.org/D121423
https://reviews.llvm.org/D121424
https://reviews.llvm.org/D121425
https://reviews.llvm.org/D121426


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117730

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


[PATCH] D121427: [lit] add lit_config.substitute to interpolate lit_config.params

2022-03-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: aaron.ballman, hokein.
Herald added subscribers: usaxena95, kadircet, arphaman, delcypher.
Herald added a project: All.
sammccall requested review of this revision.
Herald added projects: LLVM, clang-tools-extra.
Herald added subscribers: cfe-commits, llvm-commits.

A version of this logic appears in ~every lit.site.cfg.in (28 copies total).
This patch just removes two, but I'll update the rest of llvm-project next.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121427

Files:
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang-tools-extra/test/lit.site.cfg.py.in
  llvm/utils/lit/lit/LitConfig.py


Index: llvm/utils/lit/lit/LitConfig.py
===
--- llvm/utils/lit/lit/LitConfig.py
+++ llvm/utils/lit/lit/LitConfig.py
@@ -175,6 +175,15 @@
 # output.
 sys.stderr.flush()
 
+def substitute(self, string):
+"""substitute - Interpolate params into a string"""
+try:
+  return string % self.params
+except KeyError as e:
+  key, = e.args
+  self.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (
+  key,key))
+
 def note(self, message):
 if not self.quiet:
 self._write_message('note', message)
Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -2,28 +2,19 @@
 
 import sys
 
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
-config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
 config.clang_libs_dir = "@SHLIBDIR@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
 config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
-
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
-try:
-config.clang_tools_dir = config.clang_tools_dir % lit_config.params
-config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
-config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
-except KeyError:
-e = sys.exc_info()[1]
-key, = e.args
-lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))
+config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
+config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@")
 
 import lit.llvm
 lit.llvm.initialize(lit_config, config)
Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -2,24 +2,15 @@
 
 # Variables needed for common clang config.
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
-config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.clang_libs_dir = "@CLANG_LIBS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
-
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
-try:
-config.clang_tools_dir = config.clang_tools_dir % lit_config.params
-config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
-config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
-except KeyError:
-e = sys.exc_info()[1]
-key, = e.args
-lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))
+config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@")
+config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
 
 config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.."
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."


Index: llvm/utils/lit/lit/LitConfig.py
===
--- llvm/utils/lit/lit/LitConfig.py
+++ llvm/utils/lit/lit/LitConfig.py
@@ -175,6 +175,15 @@
 # output.
 sys.stderr.flush()
 
+def substitute(self, string):
+"""substitute - Interpolate params into a string"""
+try:
+  return string % self.params
+except KeyError as e:
+  key, = e.args
+  self.fatal("unable to find %r parameter, use 

[PATCH] D121426: [VFS] Update uses of getVFSFromYAML to use the new getVFSFromYAMLs API

2022-03-10 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added inline comments.



Comment at: llvm/include/llvm/Support/Error.h:1284
 
-  StringRef getFileName() { return FileName; }
+  StringRef getFileName() const { return FileName; }
 

Should this be in a change all by itself?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121426

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


[PATCH] D121426: [VFS] Update uses of getVFSFromYAML to use the new getVFSFromYAMLs API

2022-03-10 Thread Ben Barham via Phabricator via cfe-commits
bnbarham created this revision.
bnbarham added reviewers: keith, dexonsmith, JDevlieghere, vsapsai.
Herald added a subscriber: carlosgalvezp.
Herald added a project: All.
bnbarham requested review of this revision.
Herald added projects: clang, LLDB, LLVM, clang-tools-extra.
Herald added subscribers: cfe-commits, llvm-commits, lldb-commits.

Includes two test fixes (since chained mappings are no longer allowed)
and adds a new test for multiple overlays.

Uses other than `CompilerInvocation.cpp` are simple 1:1 mappings, but
without the need to read into a buffer first.

Depends on D121421  and D121423 
 and D121424 
 and D121425 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121426

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/VFS/Inputs/vfsroot.yaml
  clang/test/VFS/directory.c
  clang/test/VFS/multiple-overlays.c
  clang/test/VFS/vfsroot-with-overlay.c
  lldb/source/Commands/CommandObjectReproducer.cpp
  llvm/include/llvm/Support/Error.h
  llvm/tools/dsymutil/Reproducer.cpp
  llvm/tools/dsymutil/Reproducer.h

Index: llvm/tools/dsymutil/Reproducer.h
===
--- llvm/tools/dsymutil/Reproducer.h
+++ llvm/tools/dsymutil/Reproducer.h
@@ -59,8 +59,7 @@
 };
 
 /// Reproducer instance used to use an existing reproducer. The VFS returned by
-/// this instance is a RedirectingFileSystem that remaps paths to their
-/// counterpart in the reproducer.
+/// remaps paths to their counterpart in the reproducer.
 class ReproducerUse : public Reproducer {
 public:
   ReproducerUse(StringRef Root, std::error_code );
Index: llvm/tools/dsymutil/Reproducer.cpp
===
--- llvm/tools/dsymutil/Reproducer.cpp
+++ llvm/tools/dsymutil/Reproducer.cpp
@@ -48,15 +48,15 @@
 ReproducerUse::ReproducerUse(StringRef Root, std::error_code ) {
   SmallString<128> Mapping(Root);
   sys::path::append(Mapping, "mapping.yaml");
-  ErrorOr> Buffer =
-  vfs::getRealFileSystem()->getBufferForFile(Mapping.str());
 
-  if (!Buffer) {
-EC = Buffer.getError();
+  auto OverlayFS = llvm::vfs::getVFSFromYAMLs(Mapping.str());
+  if (auto Err = OverlayFS.takeError()) {
+llvm::handleAllErrors(std::move(Err), [&](const llvm::ErrorInfoBase ) {
+  EC = E.convertToErrorCode();
+});
 return;
   }
-
-  VFS = llvm::vfs::getVFSFromYAML(std::move(Buffer.get()), nullptr, Mapping);
+  VFS = std::move(*OverlayFS);
 }
 
 llvm::Expected>
Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -1281,7 +1281,7 @@
 return OS.str();
   }
 
-  StringRef getFileName() { return FileName; }
+  StringRef getFileName() const { return FileName; }
 
   Error takeError() { return Error(std::move(Err)); }
 
Index: lldb/source/Commands/CommandObjectReproducer.cpp
===
--- lldb/source/Commands/CommandObjectReproducer.cpp
+++ lldb/source/Commands/CommandObjectReproducer.cpp
@@ -409,23 +409,19 @@
 switch (m_options.provider) {
 case eReproducerProviderFiles: {
   FileSpec vfs_mapping = loader->GetFile();
+  std::string overlay_path = vfs_mapping.GetPath();
 
-  // Read the VFS mapping.
-  ErrorOr> buffer =
-  vfs::getRealFileSystem()->getBufferForFile(vfs_mapping.GetPath());
-  if (!buffer) {
-SetError(result, errorCodeToError(buffer.getError()));
+  Expected> vfs =
+  vfs::getVFSFromYAMLs(StringRef(overlay_path));
+  if (auto err = vfs.takeError()) {
+SetError(result, std::move(err));
 return false;
   }
 
-  // Initialize a VFS from the given mapping.
-  IntrusiveRefCntPtr vfs = vfs::getVFSFromYAML(
-  std::move(buffer.get()), nullptr, vfs_mapping.GetPath());
-
   // Dump the VFS to a buffer.
   std::string str;
   raw_string_ostream os(str);
-  static_cast(*vfs).dump(os);
+  (*vfs)->dump(os);
   os.flush();
 
   // Return the string.
Index: clang/test/VFS/vfsroot-with-overlay.c
===
--- clang/test/VFS/vfsroot-with-overlay.c
+++ clang/test/VFS/vfsroot-with-overlay.c
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
 // RUN: sed -e "s@TEST_DIR@%{/S:regex_replacement}@g" -e "s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/vfsroot.yaml > %t.yaml
-// RUN: sed -e "s@INPUT_DIR@/indirect-vfs-root-files@g" -e "s@OUT_DIR@/overlay-dir@g" %S/Inputs/vfsoverlay.yaml > %t/vfsoverlay.yaml
+// RUN: sed -e "s@INPUT_DIR@%{/S:regex_replacement}/Inputs@g" -e "s@OUT_DIR@/overlay-dir@g" %S/Inputs/vfsoverlay.yaml > %t/vfsoverlay.yaml
 // RUN: %clang_cc1 

[PATCH] D121422: [clang-tools-extra] Reuse llvm_config.use_clang() to set up test environment

2022-03-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: aaron.ballman, hokein.
Herald added subscribers: usaxena95, kadircet.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang-tools-extra.

This replaces a bunch of duplicate logic to set up environment variables
and a few substitutions.

It does a little more than we were doing previously:

- searching for clang and setting up substitutions for it
- setting up some substitutions for target triples, which are potentially 
useful but not actually used

clangd has been happily using this for its tests for a while.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121422

Files:
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in


Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -8,9 +8,10 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
-config.clang_libs_dir = "@SHLIBDIR@"
+config.llvm_shlib_dir = "@SHLIBDIR@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
 config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
 
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -1,13 +1,9 @@
 # -*- Python -*-
 
 import os
-import platform
-import re
 import shlex
-import subprocess
 
 import lit.formats
-import lit.util
 
 from lit.llvm import llvm_config
 
@@ -33,43 +29,8 @@
 # test_exec_root: The root path where tests should be run.
 config.test_exec_root = os.path.join(config.clang_tools_binary_dir, 'test')
 
-# Clear some environment variables that might affect Clang.
-#
-# This first set of vars are read by Clang, but shouldn't affect tests
-# that aren't specifically looking for these features, or are required
-# simply to run the tests at all.
-#
-# FIXME: Should we have a tool that enforces this?
-
-# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
-#  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
-#  'IOS_SIMULATOR_DEPLOYMENT_TARGET',
-#  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
-#  'VC80COMNTOOLS')
-possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
-   'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
-   'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
-   'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
-   'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
-   'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
-   'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
-   'LIBCLANG_RESOURCE_USAGE',
-   'LIBCLANG_CODE_COMPLETION_LOGGING']
-# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
-if platform.system() != 'Windows':
-possibly_dangerous_env_vars.append('INCLUDE')
-for name in possibly_dangerous_env_vars:
-  if name in config.environment:
-del config.environment[name]
-
-# Tweak the PATH to include the tools dir and the scripts dir.
-path = os.path.pathsep.join((
-config.clang_tools_dir, config.llvm_tools_dir, 
config.environment['PATH']))
-config.environment['PATH'] = path
-
-path = os.path.pathsep.join((config.clang_libs_dir, config.llvm_libs_dir,
-  config.environment.get('LD_LIBRARY_PATH','')))
-config.environment['LD_LIBRARY_PATH'] = path
+# Tools need the same environment setup as clang (we don't need clang itself).
+llvm_config.use_clang(required = False)
 
 if config.clang_tidy_staticanalyzer:
 config.available_features.add('static-analyzer')
@@ -91,9 +52,6 @@
 ('%run_clang_tidy',
  '%s %s' % (python_exec, run_clang_tidy)) )
 
-config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
-config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
-
 # Plugins (loadable modules)
 if config.has_plugins and config.llvm_plugin_ext:
 config.available_features.add('plugins')


Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -8,9 +8,10 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 

[PATCH] D107141: [Inline-asm] Add diagnosts for unsupported inline assembly arguments

2022-03-10 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/SemaStmtAsm.cpp:622
+if (InTy->isIntegerType() || InTy->isPointerType() ||
+InTy->isStructureType() || InTy->isConstantArrayType())
   InputDomain = AD_Int;

Are you sure you want to change the Input/output Domain?  Since you changed 
this, could you add both codegen and sema check tests for  struct type(you 
already has sema check for struct type, but I don't see any array type) and 
array type.  

Thanks.
Jennifer



Comment at: clang/lib/Sema/SemaStmtAsm.cpp:677
+  Context.getIntTypeForBitwidth(OutSize, /*Signed*/ false).isNull())
+targetDiag(OutputExpr->getExprLoc(), diag::err_store_value_to_reg);
+

Do you need return NS after diagnostic?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107141

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


[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-10 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2067
+  // favor this processor.
+  TuneCPU = SD->getCPUName(GD.getMultiVersionIndex())->getName();
+}

Unfortunately, I don't think it's this easy. The list of names used for 
cpu_specific doesn't come from the same place as the list of names used by 
"tune-cpu". For one thing, the cpu_specific names can't contain the '-' 
character, so we have names like "skylake_avx512" in cpu_specific that would 
need to be translated to "skylake-avx512" for "tune-cpu". I believe the list of 
valid names for "tune-cpu" comes from here: 
https://github.com/llvm/llvm-project/blob/26cd258420c774254cc48330b1f4d23d353baf05/llvm/lib/Support/X86TargetParser.cpp#L294

Also, some of the aliases supported by cpu_specific don't have any 
corresponding "tune-cpu" name. You happen to have picked one of these for the 
test. I believe "core_4th_gen_avx" should map to "haswell".



Comment at: clang/test/CodeGen/attr-cpuspecific-avx-abi.c:28
 // CHECK: attributes #[[V]] = 
{{.*}}"target-features"="+avx,+avx2,+bmi,+cmov,+crc32,+cx8,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK-SAME: "tune-cpu"="core_4th_gen_avx"

As noted above, this isn't a valid setting for "tune-cpu". I think it would 
just be ignored.


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

https://reviews.llvm.org/D121410

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


[PATCH] D121269: [clang-format] Fix namespace format when the name is followed by a macro

2022-03-10 Thread Zequan Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd54c4df31470: [clang-format] Fix namespace format when the 
name is followed by a macro (authored by zequanwu).

Changed prior to commit:
  https://reviews.llvm.org/D121269?vs=414442=414506#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121269

Files:
  clang/lib/Format/NamespaceEndCommentsFixer.cpp
  clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Index: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -189,6 +189,49 @@
 "int i;\n"
 "int j;\n"
 "}"));
+  EXPECT_EQ("#define M(x) x##x\n"
+"namespace A M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace A M(x)",
+fixNamespaceEndComments("#define M(x) x##x\n"
+"namespace A M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}"));
+  EXPECT_EQ(
+  "#define B __attribute__((availability(macos, introduced=10.15)))\n"
+  "namespace A B {\n"
+  "int i;\n"
+  "int j;\n"
+  "}// namespace A B",
+  fixNamespaceEndComments(
+  "#define B __attribute__((availability(macos, introduced=10.15)))\n"
+  "namespace A B {\n"
+  "int i;\n"
+  "int j;\n"
+  "}"));
+  EXPECT_EQ("#define M(x) x##x\n"
+"namespace A::B M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace A::B",
+fixNamespaceEndComments("#define M(x) x##x\n"
+"namespace A::B M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}"));
+  EXPECT_EQ(
+  "namespace A __attribute__((availability(macos, introduced=10.15))) {\n"
+  "int i;\n"
+  "int j;\n"
+  "}// namespace A",
+  fixNamespaceEndComments(
+  "namespace A __attribute__((availability(macos, introduced=10.15))) "
+  "{\n"
+  "int i;\n"
+  "int j;\n"
+  "}"));
   EXPECT_EQ("inline namespace A {\n"
 "int i;\n"
 "int j;\n"
Index: clang/lib/Format/NamespaceEndCommentsFixer.cpp
===
--- clang/lib/Format/NamespaceEndCommentsFixer.cpp
+++ clang/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "NamespaceEndCommentsFixer.h"
+#include "clang/Basic/TokenKinds.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Regex.h"
 
@@ -22,6 +23,40 @@
 namespace format {
 
 namespace {
+// Iterates all tokens starting from StartTok to EndTok and apply Fn to all
+// tokens between them including StartTok and EndTok. Returns the token after
+// EndTok.
+const FormatToken *
+processTokens(const FormatToken *Tok, tok::TokenKind StartTok,
+  tok::TokenKind EndTok,
+  llvm::function_ref Fn) {
+  if (!Tok || Tok->isNot(StartTok))
+return Tok;
+  int NestLevel = 0;
+  do {
+if (Tok->is(StartTok))
+  ++NestLevel;
+else if (Tok->is(EndTok))
+  --NestLevel;
+if (Fn)
+  Fn(Tok);
+Tok = Tok->getNextNonComment();
+  } while (Tok && NestLevel > 0);
+  return Tok;
+}
+
+const FormatToken *skipAttribute(const FormatToken *Tok) {
+  if (!Tok)
+return nullptr;
+  if (Tok->is(tok::kw___attribute)) {
+Tok = Tok->getNextNonComment();
+Tok = processTokens(Tok, tok::l_paren, tok::r_paren, nullptr);
+  } else if (Tok->is(tok::l_square)) {
+Tok = processTokens(Tok, tok::l_square, tok::r_square, nullptr);
+  }
+  return Tok;
+}
+
 // Computes the name of a namespace given the namespace token.
 // Returns "" for anonymous namespace.
 std::string computeName(const FormatToken *NamespaceTok) {
@@ -39,48 +74,69 @@
   name += Tok->TokenText;
   Tok = Tok->getNextNonComment();
 }
-  } else {
-// Skip attributes.
-if (Tok && Tok->is(tok::l_square)) {
-  for (int NestLevel = 1; NestLevel > 0;) {
-Tok = Tok->getNextNonComment();
-if (!Tok)
-  break;
-if (Tok->is(tok::l_square))
-  ++NestLevel;
-else if (Tok->is(tok::r_square))
-  --NestLevel;
-  }
-  if (Tok)
-Tok = Tok->getNextNonComment();
-}
+return name;
+  }
+  Tok = skipAttribute(Tok);
 
-// Use the string after `namespace` as a name candidate until `{` or `::` or
-// `(`. If the name is empty, use the candicate.
-std::string FirstNSName;
-// For `namespace 

[clang] d54c4df - [clang-format] Fix namespace format when the name is followed by a macro

2022-03-10 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2022-03-10T15:00:32-08:00
New Revision: d54c4df31470044a66605ebb8a2f936e8dd552af

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

LOG: [clang-format] Fix namespace format when the name is followed by a macro

Example:
```
$ cat a.cpp
namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
void test() {}
}

$ clang-format a.cpp
namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
void test() {}
}// namespace my_namespace::yeahAPI_AVAILABLE(macos(10.15))
```
After:
```
$ clang-format a.cpp
namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
void test() {}
}// namespace my_namespace::yeah
```

Reviewed By: MyDeveloperDay, owenpan, curdeius

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

Added: 


Modified: 
clang/lib/Format/NamespaceEndCommentsFixer.cpp
clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Removed: 




diff  --git a/clang/lib/Format/NamespaceEndCommentsFixer.cpp 
b/clang/lib/Format/NamespaceEndCommentsFixer.cpp
index e527402e33074..2615a499f7abf 100644
--- a/clang/lib/Format/NamespaceEndCommentsFixer.cpp
+++ b/clang/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -13,6 +13,7 @@
 
//===--===//
 
 #include "NamespaceEndCommentsFixer.h"
+#include "clang/Basic/TokenKinds.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Regex.h"
 
@@ -22,6 +23,40 @@ namespace clang {
 namespace format {
 
 namespace {
+// Iterates all tokens starting from StartTok to EndTok and apply Fn to all
+// tokens between them including StartTok and EndTok. Returns the token after
+// EndTok.
+const FormatToken *
+processTokens(const FormatToken *Tok, tok::TokenKind StartTok,
+  tok::TokenKind EndTok,
+  llvm::function_ref Fn) {
+  if (!Tok || Tok->isNot(StartTok))
+return Tok;
+  int NestLevel = 0;
+  do {
+if (Tok->is(StartTok))
+  ++NestLevel;
+else if (Tok->is(EndTok))
+  --NestLevel;
+if (Fn)
+  Fn(Tok);
+Tok = Tok->getNextNonComment();
+  } while (Tok && NestLevel > 0);
+  return Tok;
+}
+
+const FormatToken *skipAttribute(const FormatToken *Tok) {
+  if (!Tok)
+return nullptr;
+  if (Tok->is(tok::kw___attribute)) {
+Tok = Tok->getNextNonComment();
+Tok = processTokens(Tok, tok::l_paren, tok::r_paren, nullptr);
+  } else if (Tok->is(tok::l_square)) {
+Tok = processTokens(Tok, tok::l_square, tok::r_square, nullptr);
+  }
+  return Tok;
+}
+
 // Computes the name of a namespace given the namespace token.
 // Returns "" for anonymous namespace.
 std::string computeName(const FormatToken *NamespaceTok) {
@@ -39,48 +74,69 @@ std::string computeName(const FormatToken *NamespaceTok) {
   name += Tok->TokenText;
   Tok = Tok->getNextNonComment();
 }
-  } else {
-// Skip attributes.
-if (Tok && Tok->is(tok::l_square)) {
-  for (int NestLevel = 1; NestLevel > 0;) {
-Tok = Tok->getNextNonComment();
-if (!Tok)
-  break;
-if (Tok->is(tok::l_square))
-  ++NestLevel;
-else if (Tok->is(tok::r_square))
-  --NestLevel;
-  }
-  if (Tok)
-Tok = Tok->getNextNonComment();
-}
+return name;
+  }
+  Tok = skipAttribute(Tok);
 
-// Use the string after `namespace` as a name candidate until `{` or `::` 
or
-// `(`. If the name is empty, use the candicate.
-std::string FirstNSName;
-// For `namespace [[foo]] A::B::inline C {` or
-// `namespace MACRO1 MACRO2 A::B::inline C {`, returns "A::B::inline C".
-// Peek for the first '::' (or '{' or '(')) and then return all tokens from
-// one token before that up until the '{'. A '(' might be a macro with
-// arguments.
-const FormatToken *FirstNSTok = Tok;
-while (Tok && !Tok->isOneOf(tok::l_brace, tok::coloncolon, tok::l_paren)) {
+  std::string FirstNSName;
+  // For `namespace [[foo]] A::B::inline C {` or
+  // `namespace MACRO1 MACRO2 A::B::inline C {`, returns "A::B::inline C".
+  // Peek for the first '::' (or '{' or '(')) and then return all tokens from
+  // one token before that up until the '{'. A '(' might be a macro with
+  // arguments.
+  const FormatToken *FirstNSTok = nullptr;
+  while (Tok && !Tok->isOneOf(tok::l_brace, tok::coloncolon, tok::l_paren)) {
+if (FirstNSTok)
   FirstNSName += FirstNSTok->TokenText;
-  FirstNSTok = Tok;
-  Tok = Tok->getNextNonComment();
-}
+FirstNSTok = Tok;
+Tok = Tok->getNextNonComment();
+  }
 
+  if (FirstNSTok)
 Tok = FirstNSTok;
-while (Tok && !Tok->is(tok::l_brace)) {
-  name += Tok->TokenText;
-  if (Tok->is(tok::kw_inline))
+  Tok = skipAttribute(Tok);
+
+  FirstNSTok = nullptr;
+  // Add everything from '(' to ')'.
+  auto 

[clang-tools-extra] 7f0df31 - [clang-tools-extra] Don't consider python below LLVM_MINIMUM_PYTHON_VERSION. NFC

2022-03-10 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-10T23:57:27+01:00
New Revision: 7f0df31ee3f596c36a0bb6af4248aaf431541e3a

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

LOG: [clang-tools-extra] Don't consider python below 
LLVM_MINIMUM_PYTHON_VERSION. NFC

Added: 


Modified: 
clang-tools-extra/test/lit.cfg.py

Removed: 




diff  --git a/clang-tools-extra/test/lit.cfg.py 
b/clang-tools-extra/test/lit.cfg.py
index 1527b07a33ee6..1c16cc73c7446 100644
--- a/clang-tools-extra/test/lit.cfg.py
+++ b/clang-tools-extra/test/lit.cfg.py
@@ -3,6 +3,7 @@
 import os
 import platform
 import re
+import shlex
 import subprocess
 
 import lit.formats
@@ -73,16 +74,7 @@
 if config.clang_tidy_staticanalyzer:
 config.available_features.add('static-analyzer')
 
-# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
-# it's not available.
-try:
-import shlex
-sh_quote = shlex.quote
-except:
-import pipes
-sh_quote = pipes.quote
-python_exec = sh_quote(config.python_executable)
-
+python_exec = shlex.quote(config.python_executable)
 check_clang_tidy = os.path.join(
 config.test_source_root, "clang-tidy", "check_clang_tidy.py")
 config.substitutions.append(



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


[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-10 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

This example illustrates the problem this patch intends to fix: 
https://godbolt.org/z/j445sxPMc

For Intel microarchitectures before Skylake, the LLVM cost model says that 
vector fsqrt is slow, so if fast-math is enabled, we'll use an approximation 
rather than the vsqrtps instruction when vectorizing a call to sqrtf(). If the 
code is compiled with -march=skylake or -mtune=skylake, we'll choose the 
vsqrtps instruction, but with any earlier base target, we'll choose the 
approximation even if there is a cpu_specific(skylake) implementation in the 
source code.

For example

  __attribute__((cpu_specific(skylake))) void foo(void) {
for (int i = 0; i < 8; ++i)
  x[i] = sqrtf(y[i]);
  }

compiles to

  foo.b:
  vmovaps ymm0, ymmword ptr [rip + y]
  vrsqrtpsymm1, ymm0
  vmulps  ymm2, ymm0, ymm1
  vbroadcastssymm3, dword ptr [rip + .LCPI2_0] # ymm3 = 
[-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0,-3.0E+0]
  vfmadd231ps ymm3, ymm2, ymm1# ymm3 = (ymm2 * ymm1) + ymm3
  vbroadcastssymm1, dword ptr [rip + .LCPI2_1] # ymm1 = 
[-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
  vmulps  ymm1, ymm2, ymm1
  vmulps  ymm1, ymm1, ymm3
  vbroadcastssymm2, dword ptr [rip + .LCPI2_2] # ymm2 = 
[NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN]
  vandps  ymm0, ymm0, ymm2
  vbroadcastssymm2, dword ptr [rip + .LCPI2_3] # ymm2 = 
[1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38,1.17549435E-38]
  vcmplepsymm0, ymm2, ymm0
  vandps  ymm0, ymm0, ymm1
  vmovaps ymmword ptr [rip + x], ymm0
  vzeroupper
  ret

but it should compile to

  foo.b:
  vsqrtps ymm0, ymmword ptr [rip + y]
  vmovaps ymmword ptr [rip + x], ymm0
  vzeroupper
  ret


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

https://reviews.llvm.org/D121410

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


[PATCH] D120936: [Sema][Windows] Don't special-case void* in __unaligned conversions.

2022-03-10 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG27a574962567: [Sema][Windows] Dont special-case void* 
in __unaligned conversions. (authored by efriedma).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120936

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp

Index: clang/test/SemaCXX/MicrosoftExtensions.cpp
===
--- clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -85,18 +85,22 @@
   foo_unaligned(p2);
 
   __unaligned B_unaligned *p3 = 0;
-  int p4 = foo_unaligned(p3);
+  int p4 = foo_unaligned(p3); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
+  // expected-warning@-1 {{implicit cast from type '__unaligned B_unaligned *' to type 'B_unaligned *' drops __unaligned qualifier}}
 
-  B_unaligned *p5 = p3; // expected-error {{cannot initialize a variable of type 'B_unaligned *' with an lvalue of type '__unaligned B_unaligned *'}}
+  B_unaligned *p5 = p3;
+  // expected-warning@-1 {{implicit cast from type '__unaligned B_unaligned *' to type 'B_unaligned *' drops __unaligned qualifier}}
 
   __unaligned B_unaligned *p6 = p3;
 
   p1_aligned_type4 = p2_aligned_type4;
-  p2_aligned_type4 = p1_aligned_type4; // expected-error {{assigning to 'int aligned_type4::*' from incompatible type '__unaligned int aligned_type4::*'}}
+  p2_aligned_type4 = p1_aligned_type4;
+  // expected-warning@-1 {{implicit cast from type '__unaligned int aligned_type4::*' to type 'int aligned_type4::*' drops __unaligned qualifier}}
   p3_aligned_type4 = p1_aligned_type4;
 
   __unaligned int a[10];
-  int *b = a; // expected-error {{cannot initialize a variable of type 'int *' with an lvalue of type '__unaligned int[10]'}}
+  int *b = a;
+  // expected-warning@-1 {{implicit cast from type '__unaligned int[10]' to type 'int *' drops __unaligned qualifier}}
 }
 
 // Test from PR27367
@@ -115,13 +119,18 @@
 // We should accept type conversion of __unaligned to non-__unaligned references
 typedef struct in_addr {
 public:
-  in_addr(in_addr ) {} // expected-note {{candidate constructor not viable: no known conversion from '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to 'in_addr &' for 1st argument; dereference the argument with *}}
-  in_addr(in_addr *a) {} // expected-note {{candidate constructor not viable: 1st argument ('__unaligned IN_ADDR *' (aka '__unaligned in_addr *')) would lose __unaligned qualifier}}
+  in_addr(in_addr ) {} // expected-note {{candidate constructor not viable: expects an lvalue for 1st argument}}
+  in_addr(in_addr *a) {} // expected-note {{candidate constructor not viable: no known conversion from 'IN_ADDR' (aka 'in_addr') to 'in_addr *' for 1st argument}}
 } IN_ADDR;
 
 void f(IN_ADDR __unaligned *a) {
   IN_ADDR local_addr = *a;
-  IN_ADDR local_addr2 = a; // expected-error {{no viable conversion from '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to 'IN_ADDR' (aka 'in_addr')}}
+  // FIXME: MSVC accepts the following; not sure why clang tries to
+  // copy-construct an in_addr.
+  IN_ADDR local_addr2 = a; // expected-error {{no viable constructor copying variable of type 'IN_ADDR' (aka 'in_addr')}}
+  // expected-warning@-1 {{implicit cast from type '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to type 'in_addr *' drops __unaligned qualifier}}
+  IN_ADDR local_addr3(a);
+  // expected-warning@-1 {{implicit cast from type '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to type 'in_addr *' drops __unaligned qualifier}}
 }
 
 template void h1(T (__stdcall M::* const )()) { }
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -3195,9 +3195,8 @@
   Qualifiers FromQuals = FromType.getQualifiers();
   Qualifiers ToQuals = ToType.getQualifiers();
 
-  // Ignore __unaligned qualifier if this type is void.
-  if (ToType.getUnqualifiedType()->isVoidType())
-FromQuals.removeUnaligned();
+  // Ignore __unaligned qualifier.
+  FromQuals.removeUnaligned();
 
   // Objective-C ARC:
   //   Check Objective-C lifetime conversions.
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4641,6 +4641,13 @@
 From->getType()->getPointeeType().getAddressSpace())
   CK = CK_AddressSpaceConversion;
 
+if (!isCast(CCK) &&
+!ToType->getPointeeType().getQualifiers().hasUnaligned() &&
+From->getType()->getPointeeType().getQualifiers().hasUnaligned()) {
+  Diag(From->getBeginLoc(), 

[clang] 27a5749 - [Sema][Windows] Don't special-case void* in __unaligned conversions.

2022-03-10 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2022-03-10T14:49:16-08:00
New Revision: 27a574962567224d3a36a70cf8abf0ad3d751ec5

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

LOG: [Sema][Windows] Don't special-case void* in __unaligned conversions.

As far as I can tell, MSVC allows the relevant conversions for all
pointer types. Found compiling a Windows SDK header.

I've verified that the updated errors in MicrosoftExtensions.cpp match
the ones that MSVC actually emits, except for the one with a FIXME. (Not
sure why this wasn't done for the patch that added the tests.)

To make up for the missing error, add a warning that triggers on
conversions that drop the __unaligned qualfier.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0468370536fc0..db4adbbb6e1e6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10272,6 +10272,11 @@ def err_openclcxx_placement_new : Error<
 def warn_mig_server_routine_does_not_return_kern_return_t : Warning<
   "'mig_server_routine' attribute only applies to routines that return a 
kern_return_t">,
   InGroup;
+
+def warn_imp_cast_drops_unaligned : Warning<
+  "implicit cast from type %0 to type %1 drops __unaligned qualifier">,
+  InGroup>;
+
 } // end of sema category
 
 let CategoryName = "OpenMP Issue" in {

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 5cf718cb6d25d..3138ec3b1c77d 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4641,6 +4641,13 @@ Sema::PerformImplicitConversion(Expr *From, QualType 
ToType,
 From->getType()->getPointeeType().getAddressSpace())
   CK = CK_AddressSpaceConversion;
 
+if (!isCast(CCK) &&
+!ToType->getPointeeType().getQualifiers().hasUnaligned() &&
+From->getType()->getPointeeType().getQualifiers().hasUnaligned()) {
+  Diag(From->getBeginLoc(), diag::warn_imp_cast_drops_unaligned)
+  << InitialFromType << ToType;
+}
+
 From = ImpCastExprToType(From, ToType.getNonLValueExprType(Context), CK, 
VK,
  /*BasePath=*/nullptr, CCK)
.get();

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 6167526f8096d..767074bdbd15f 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -3195,9 +3195,8 @@ static bool isQualificationConversionStep(QualType 
FromType, QualType ToType,
   Qualifiers FromQuals = FromType.getQualifiers();
   Qualifiers ToQuals = ToType.getQualifiers();
 
-  // Ignore __unaligned qualifier if this type is void.
-  if (ToType.getUnqualifiedType()->isVoidType())
-FromQuals.removeUnaligned();
+  // Ignore __unaligned qualifier.
+  FromQuals.removeUnaligned();
 
   // Objective-C ARC:
   //   Check Objective-C lifetime conversions.

diff  --git a/clang/test/SemaCXX/MicrosoftExtensions.cpp 
b/clang/test/SemaCXX/MicrosoftExtensions.cpp
index f1ba8afc221fc..8c1644589cab0 100644
--- a/clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -85,18 +85,22 @@ void test_unaligned() {
   foo_unaligned(p2);
 
   __unaligned B_unaligned *p3 = 0;
-  int p4 = foo_unaligned(p3);
+  int p4 = foo_unaligned(p3); // expected-error {{cannot initialize a variable 
of type 'int' with an rvalue of type 'void *'}}
+  // expected-warning@-1 {{implicit cast from type '__unaligned B_unaligned *' 
to type 'B_unaligned *' drops __unaligned qualifier}}
 
-  B_unaligned *p5 = p3; // expected-error {{cannot initialize a variable of 
type 'B_unaligned *' with an lvalue of type '__unaligned B_unaligned *'}}
+  B_unaligned *p5 = p3;
+  // expected-warning@-1 {{implicit cast from type '__unaligned B_unaligned *' 
to type 'B_unaligned *' drops __unaligned qualifier}}
 
   __unaligned B_unaligned *p6 = p3;
 
   p1_aligned_type4 = p2_aligned_type4;
-  p2_aligned_type4 = p1_aligned_type4; // expected-error {{assigning to 'int 
aligned_type4::*' from incompatible type '__unaligned int aligned_type4::*'}}
+  p2_aligned_type4 = p1_aligned_type4;
+  // expected-warning@-1 {{implicit cast from type '__unaligned int 
aligned_type4::*' to type 'int aligned_type4::*' drops __unaligned qualifier}}
   p3_aligned_type4 = p1_aligned_type4;
 
   __unaligned int a[10];
-  int *b = a; // expected-error {{cannot initialize a variable of type 'int *' 
with an lvalue of type '__unaligned int[10]'}}
+  int *b = 

[PATCH] D121412: Complete the list of single-underscore keywords for MSVC compat.

2022-03-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 414499.
efriedma added a comment.

Drop _except; __except is a contextual keyword.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121412

Files:
  clang/include/clang/Basic/TokenKinds.def


Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -676,24 +676,39 @@
 KEYWORD(__virtual_inheritance , KEYMS)
 KEYWORD(__interface   , KEYMS)
 ALIAS("__int8"   , char   , KEYMS)
-ALIAS("_int8", char   , KEYMS)
 ALIAS("__int16"  , short  , KEYMS)
-ALIAS("_int16"   , short  , KEYMS)
 ALIAS("__int32"  , int, KEYMS)
-ALIAS("_int32"   , int, KEYMS)
-ALIAS("_int64"   , __int64, KEYMS)
 ALIAS("__wchar_t", wchar_t, KEYMS)
-ALIAS("_asm" , asm, KEYMS)
-ALIAS("_alignof" , __alignof  , KEYMS)
 ALIAS("__builtin_alignof", __alignof  , KEYMS)
-ALIAS("_cdecl"   , __cdecl, KEYMS | KEYBORLAND)
-ALIAS("_fastcall", __fastcall , KEYMS | KEYBORLAND)
-ALIAS("_stdcall" , __stdcall  , KEYMS | KEYBORLAND)
-ALIAS("_thiscall", __thiscall , KEYMS)
-ALIAS("_vectorcall"  , __vectorcall, KEYMS)
-ALIAS("_uuidof"  , __uuidof   , KEYMS | KEYBORLAND)
-ALIAS("_inline"  , inline , KEYMS)
-ALIAS("_declspec", __declspec , KEYMS)
+
+// Microsoft single-underscore prefixed aliases for double-underscore prefixed
+// keywords.
+ALIAS("_asm" , asm  , KEYMS)
+ALIAS("_alignof" , __alignof, KEYMS)
+ALIAS("_cdecl"   , __cdecl  , KEYMS | KEYBORLAND)
+ALIAS("_declspec", __declspec   , KEYMS)
+ALIAS("_fastcall", __fastcall   , KEYMS | KEYBORLAND)
+ALIAS("_finally" , __finally, KEYMS)
+ALIAS("_forceinline" , __forceinline, KEYMS)
+ALIAS("_inline"  , inline   , KEYMS)
+ALIAS("_int8", char , KEYMS)
+ALIAS("_int16"   , short, KEYMS)
+ALIAS("_int32"   , int  , KEYMS)
+ALIAS("_int64"   , __int64  , KEYMS)
+ALIAS("_leave"   , __leave  , KEYMS)
+ALIAS("_multiple_inheritance", __multiple_inheritance, KEYMS)
+ALIAS("_ptr32"   , __ptr32  , KEYMS)
+ALIAS("_ptr64"   , __ptr64  , KEYMS)
+ALIAS("_restrict", restrict , KEYMS)
+ALIAS("_stdcall" , __stdcall, KEYMS | KEYBORLAND)
+ALIAS("_thiscall", __thiscall   , KEYMS)
+ALIAS("_try" , __try, KEYMS)
+ALIAS("_vectorcall"  , __vectorcall , KEYMS)
+ALIAS("_unaligned"   , __unaligned  , KEYMS)
+ALIAS("_uptr", __uptr   , KEYMS)
+ALIAS("_uuidof"  , __uuidof , KEYMS | KEYBORLAND)
+ALIAS("_virtual_inheritance", __virtual_inheritance, KEYMS)
+ALIAS("_w64" , __w64, KEYMS)
 
 // Borland Extensions which should be disabled in strict conformance mode.
 ALIAS("_pascal"  , __pascal   , KEYBORLAND)


Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -676,24 +676,39 @@
 KEYWORD(__virtual_inheritance , KEYMS)
 KEYWORD(__interface   , KEYMS)
 ALIAS("__int8"   , char   , KEYMS)
-ALIAS("_int8", char   , KEYMS)
 ALIAS("__int16"  , short  , KEYMS)
-ALIAS("_int16"   , short  , KEYMS)
 ALIAS("__int32"  , int, KEYMS)
-ALIAS("_int32"   , int, KEYMS)
-ALIAS("_int64"   , __int64, KEYMS)
 ALIAS("__wchar_t", wchar_t, KEYMS)
-ALIAS("_asm" , asm, KEYMS)
-ALIAS("_alignof" , __alignof  , KEYMS)
 ALIAS("__builtin_alignof", __alignof  , KEYMS)
-ALIAS("_cdecl"   , __cdecl, KEYMS | KEYBORLAND)
-ALIAS("_fastcall", __fastcall , KEYMS | KEYBORLAND)
-ALIAS("_stdcall" , __stdcall  , KEYMS | KEYBORLAND)
-ALIAS("_thiscall", __thiscall , KEYMS)
-ALIAS("_vectorcall"  , __vectorcall, KEYMS)
-ALIAS("_uuidof"  , __uuidof   , KEYMS | KEYBORLAND)
-ALIAS("_inline"  , inline , KEYMS)
-ALIAS("_declspec", __declspec , KEYMS)
+
+// Microsoft single-underscore prefixed aliases for double-underscore prefixed
+// keywords.
+ALIAS("_asm" , asm  , KEYMS)
+ALIAS("_alignof" , __alignof, KEYMS)
+ALIAS("_cdecl"   , __cdecl  , KEYMS | KEYBORLAND)
+ALIAS("_declspec", __declspec   , KEYMS)
+ALIAS("_fastcall", __fastcall   , KEYMS | KEYBORLAND)
+ALIAS("_finally" , __finally, KEYMS)
+ALIAS("_forceinline" , __forceinline, KEYMS)
+ALIAS("_inline"  , 

[PATCH] D120857: WIP [randstruct] Add randomize structure layout support

2022-03-10 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 414500.
void added a comment.

Improve bad cast warning message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120857

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/Randstruct.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/Randstruct.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/RandstructTest.cpp

Index: clang/unittests/AST/RandstructTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/RandstructTest.cpp
@@ -0,0 +1,409 @@
+//===- unittest/AST/RandstructTest.cpp ===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains tests for Clang's structure field layout randomization.
+//
+//===--===//
+
+/*
+ * Build this test suite by running `make ASTTests` in the build folder.
+ *
+ * Run this test suite by running the following in the build folder:
+ * ` ./tools/clang/unittests/AST/ASTTests
+ * --gtest_filter=StructureLayoutRandomization*`
+ */
+
+#include "clang/AST/Randstruct.h"
+#include "gtest/gtest.h"
+
+#include "DeclMatcher.h"
+#include "clang/AST/RecordLayout.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Testing/CommandLineArgs.h"
+#include "clang/Tooling/Tooling.h"
+
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+using namespace clang::randstruct;
+
+using field_names = std::vector;
+
+namespace {
+
+std::unique_ptr makeAST(const std::string ) {
+  std::vector Args = getCommandLineArgsForTesting(Lang_C99);
+  Args.push_back("-frandstruct-seed=1234567890abcdef");
+  return tooling::buildASTFromCodeWithArgs(SourceCode, Args, "input.cc");
+}
+
+RecordDecl *getRecordDeclFromAST(const ASTContext , const std::string ) {
+  return FirstDeclMatcher().match(C.getTranslationUnitDecl(),
+  recordDecl(hasName(Name)));
+}
+
+std::vector getFieldNamesFromRecord(const RecordDecl *RD) {
+  std::vector Fields;
+
+  Fields.reserve(8);
+  for (auto *Field : RD->fields())
+Fields.push_back(Field->getNameAsString());
+
+  return Fields;
+}
+
+bool isSubsequence(const field_names , const field_names ) {
+  unsigned SeqLen = Seq.size();
+  unsigned SubLen = Subseq.size();
+
+  bool IsSubseq = false;
+  for (unsigned I = 0; I < SeqLen; ++I)
+if (Seq[I] == Subseq[0]) {
+  IsSubseq = true;
+  for (unsigned J = 0; J + I < SeqLen && J < SubLen; ++J) {
+if (Seq[J + I] != Subseq[J]) {
+  IsSubseq = false;
+  break;
+}
+  }
+}
+
+  return IsSubseq;
+}
+
+} // end anonymous namespace
+
+namespace clang {
+namespace ast_matchers {
+
+#define RANDSTRUCT_TEST_SUITE_TEST StructureLayoutRandomizationTestSuiteTest
+
+TEST(RANDSTRUCT_TEST_SUITE_TEST, CanDetermineIfSubsequenceExists) {
+  const field_names Seq = {"a", "b", "c", "d"};
+
+  ASSERT_TRUE(isSubsequence(Seq, {"b", "c"}));
+  ASSERT_TRUE(isSubsequence(Seq, {"a", "b", "c", "d"}));
+  ASSERT_TRUE(isSubsequence(Seq, {"b", "c", "d"}));
+  ASSERT_TRUE(isSubsequence(Seq, {"a"}));
+  ASSERT_FALSE(isSubsequence(Seq, {"a", "d"}));
+}
+
+#define RANDSTRUCT_TEST StructureLayoutRandomization
+
+TEST(RANDSTRUCT_TEST, UnmarkedStruct) {
+  const std::unique_ptr AST = makeAST(R"c(
+struct test {
+int bacon;
+long lettuce;
+long long tomato;
+float mayonnaise;
+};
+  )c");
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  const field_names Expected = {"bacon", "lettuce", "tomato", "mayonnaise"};
+
+  ASSERT_FALSE(RD->getAttr());
+  ASSERT_FALSE(RD->isRandomized());
+  ASSERT_EQ(Expected, getFieldNamesFromRecord(RD));
+}
+
+TEST(RANDSTRUCT_TEST, MarkedNoRandomize) {
+  const std::unique_ptr AST = makeAST(R"c(
+struct test {
+int bacon;
+long lettuce;
+long long tomato;
+float mayonnaise;
+} 

[clang] 0be56c8 - [clang-format][NFC] Group all C++ passes under isCpp()

2022-03-10 Thread via cfe-commits

Author: owenca
Date: 2022-03-10T14:30:30-08:00
New Revision: 0be56c87013b585405209f324cc8dfc5ebde416f

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

LOG: [clang-format][NFC] Group all C++ passes under isCpp()

Also removes a not very helpful comment.

Added: 


Modified: 
clang/lib/Format/Format.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index a8b8efb5b22f5..9e3eaf72e121e 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1800,7 +1800,6 @@ class BracesRemover : public TokenAnalyzer {
   }
 
 private:
-  // Remove optional braces.
   void removeBraces(SmallVectorImpl ,
 tooling::Replacements ) {
 const auto  = Env.getSourceManager();
@@ -3181,17 +3180,17 @@ reformat(const FormatStyle , StringRef Code,
 });
   }
 
-  if (Style.isCpp() && Style.InsertBraces)
-Passes.emplace_back([&](const Environment ) {
-  return BracesInserter(Env, Expanded).process();
-});
+  if (Style.isCpp()) {
+if (Style.InsertBraces)
+  Passes.emplace_back([&](const Environment ) {
+return BracesInserter(Env, Expanded).process();
+  });
 
-  if (Style.isCpp() && Style.RemoveBracesLLVM)
-Passes.emplace_back([&](const Environment ) {
-  return BracesRemover(Env, Expanded).process();
-});
+if (Style.RemoveBracesLLVM)
+  Passes.emplace_back([&](const Environment ) {
+return BracesRemover(Env, Expanded).process();
+  });
 
-  if (Style.isCpp()) {
 if (Style.FixNamespaceComments)
   Passes.emplace_back([&](const Environment ) {
 return NamespaceEndCommentsFixer(Env, Expanded).process();



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


[clang-tools-extra] 2d58ba2 - [clang-tools-extra] Remove unused lit features/substitutions. NFCI

2022-03-10 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-10T23:28:43+01:00
New Revision: 2d58ba200a39ddacaa9923cb623321c295ae5949

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

LOG: [clang-tools-extra] Remove unused lit features/substitutions. NFCI

Added: 


Modified: 
clang-tools-extra/test/lit.cfg.py

Removed: 




diff  --git a/clang-tools-extra/test/lit.cfg.py 
b/clang-tools-extra/test/lit.cfg.py
index 820914b51f15e..1527b07a33ee6 100644
--- a/clang-tools-extra/test/lit.cfg.py
+++ b/clang-tools-extra/test/lit.cfg.py
@@ -16,9 +16,6 @@
 config.name = 'Clang Tools'
 
 # testFormat: The test format to use to interpret tests.
-#
-# For now we require '&&' between commands, until they get globally killed and
-# the test runner updated.
 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
 
 # suffixes: A list of file extensions to treat as test files.
@@ -73,23 +70,6 @@
   config.environment.get('LD_LIBRARY_PATH','')))
 config.environment['LD_LIBRARY_PATH'] = path
 
-# When running under valgrind, we mangle '-vg' onto the end of the triple so we
-# can check it with XFAIL and XTARGET.
-if lit_config.useValgrind:
-config.target_triple += '-vg'
-
-config.available_features.add('crash-recovery')
-# Set available features we allow tests to conditionalize on.
-#
-
-# Exclude MSYS due to transforming '/' to 'X:/mingwroot/'.
-if not platform.system() in ['Windows'] or llvm_config.use_lit_shell:
-config.available_features.add('shell-preserves-root')
-
-# ANSI escape sequences in non-dumb terminal
-if platform.system() not in ['Windows']:
-config.available_features.add('ansi-escape-sequences')
-
 if config.clang_tidy_staticanalyzer:
 config.available_features.add('static-analyzer')
 
@@ -119,11 +99,6 @@
 ('%run_clang_tidy',
  '%s %s' % (python_exec, run_clang_tidy)) )
 
-clangd_benchmarks_dir = os.path.join(os.path.dirname(config.clang_tools_dir),
- "tools", "clang", "tools", "extra",
- "clangd", "benchmarks")
-config.substitutions.append(('%clangd-benchmark-dir',
- '%s' % (clangd_benchmarks_dir)))
 config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
 config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
 



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


[clang-tools-extra] 6ed2f89 - Fix reference to execute_external leftover in 69924ccf7a328f

2022-03-10 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-10T23:20:03+01:00
New Revision: 6ed2f8902b8f109ead47e20a519860c803900d29

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

LOG: Fix reference to execute_external leftover in 69924ccf7a328f

Added: 


Modified: 
clang-tools-extra/test/lit.cfg.py

Removed: 




diff  --git a/clang-tools-extra/test/lit.cfg.py 
b/clang-tools-extra/test/lit.cfg.py
index 5c3934fb0b162..820914b51f15e 100644
--- a/clang-tools-extra/test/lit.cfg.py
+++ b/clang-tools-extra/test/lit.cfg.py
@@ -83,7 +83,7 @@
 #
 
 # Exclude MSYS due to transforming '/' to 'X:/mingwroot/'.
-if not platform.system() in ['Windows'] or not execute_external:
+if not platform.system() in ['Windows'] or llvm_config.use_lit_shell:
 config.available_features.add('shell-preserves-root')
 
 # ANSI escape sequences in non-dumb terminal



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


[clang-tools-extra] 69924cc - Remove redundant lit config already handled in llvm_config. NFCI

2022-03-10 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-10T23:11:01+01:00
New Revision: 69924ccf7a328f5f9bcc7073f38fa608a0dbfe2c

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

LOG: Remove redundant lit config already handled in llvm_config. NFCI

This logic duplicates lit.llvm.initialize, which we're already calling
(in lit.site.cfg.py.in).
The equivalent logic was removed from clang in d4401d354a938dd366bf but
never cleaned up here.

Added: 


Modified: 
clang-tools-extra/test/lit.cfg.py

Removed: 




diff  --git a/clang-tools-extra/test/lit.cfg.py 
b/clang-tools-extra/test/lit.cfg.py
index 858e42ace2a82..5c3934fb0b162 100644
--- a/clang-tools-extra/test/lit.cfg.py
+++ b/clang-tools-extra/test/lit.cfg.py
@@ -8,39 +8,18 @@
 import lit.formats
 import lit.util
 
+from lit.llvm import llvm_config
+
 # Configuration file for the 'lit' test runner.
 
 # name: The name of this test suite.
 config.name = 'Clang Tools'
 
-# Tweak PATH for Win32
-if platform.system() == 'Windows':
-# Seek sane tools in directories and set to $PATH.
-path = getattr(config, 'lit_tools_dir', None)
-path = lit_config.getToolsPath(path,
-   config.environment['PATH'],
-   ['cmp.exe', 'grep.exe', 'sed.exe'])
-if path is not None:
-path = os.path.pathsep.join((path,
- config.environment['PATH']))
-config.environment['PATH'] = path
-
-# Choose between lit's internal shell pipeline runner and a real shell.  If
-# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
-use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
-if use_lit_shell:
-# 0 is external, "" is default, and everything else is internal.
-execute_external = (use_lit_shell == "0")
-else:
-# Otherwise we default to internal on Windows and external elsewhere, as
-# bash on Windows is usually very slow.
-execute_external = (not sys.platform in ['win32'])
-
 # testFormat: The test format to use to interpret tests.
 #
 # For now we require '&&' between commands, until they get globally killed and
 # the test runner updated.
-config.test_format = lit.formats.ShTest(execute_external)
+config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
 
 # suffixes: A list of file extensions to treat as test files.
 config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', 
'.s',
@@ -103,10 +82,6 @@
 # Set available features we allow tests to conditionalize on.
 #
 
-# Shell execution
-if execute_external:
-config.available_features.add('shell')
-
 # Exclude MSYS due to transforming '/' to 'X:/mingwroot/'.
 if not platform.system() in ['Windows'] or not execute_external:
 config.available_features.add('shell-preserves-root')



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


[PATCH] D121413: [clang-repl] Add an accessor to our underlying execution engine

2022-03-10 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 414494.
v.g.vassilev added a comment.

Order fwd decls alphabetically.


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

https://reviews.llvm.org/D121413

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/Interpreter.cpp


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -196,6 +196,12 @@
   return IncrParser->getCI();
 }
 
+const llvm::orc::LLJIT *Interpreter::getExecutionEngine() const {
+  if (IncrExecutor)
+return IncrExecutor->getExecutionEngine();
+  return nullptr;
+}
+
 llvm::Expected
 Interpreter::Parse(llvm::StringRef Code) {
   return IncrParser->Parse(Code);
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -45,6 +45,7 @@
   llvm::Error runCtors() const;
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
+  llvm::orc::LLJIT *getExecutionEngine() const { return Jit.get(); }
 };
 
 } // end namespace clang
Index: clang/include/clang/Interpreter/Interpreter.h
===
--- clang/include/clang/Interpreter/Interpreter.h
+++ clang/include/clang/Interpreter/Interpreter.h
@@ -26,6 +26,7 @@
 
 namespace llvm {
 namespace orc {
+class LLJIT;
 class ThreadSafeContext;
 }
 class Module;
@@ -58,6 +59,7 @@
   static llvm::Expected>
   create(std::unique_ptr CI);
   const CompilerInstance *getCompilerInstance() const;
+  const llvm::orc::LLJIT *getExecutionEngine() const;
   llvm::Expected Parse(llvm::StringRef Code);
   llvm::Error Execute(PartialTranslationUnit );
   llvm::Error ParseAndExecute(llvm::StringRef Code) {


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -196,6 +196,12 @@
   return IncrParser->getCI();
 }
 
+const llvm::orc::LLJIT *Interpreter::getExecutionEngine() const {
+  if (IncrExecutor)
+return IncrExecutor->getExecutionEngine();
+  return nullptr;
+}
+
 llvm::Expected
 Interpreter::Parse(llvm::StringRef Code) {
   return IncrParser->Parse(Code);
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -45,6 +45,7 @@
   llvm::Error runCtors() const;
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
+  llvm::orc::LLJIT *getExecutionEngine() const { return Jit.get(); }
 };
 
 } // end namespace clang
Index: clang/include/clang/Interpreter/Interpreter.h
===
--- clang/include/clang/Interpreter/Interpreter.h
+++ clang/include/clang/Interpreter/Interpreter.h
@@ -26,6 +26,7 @@
 
 namespace llvm {
 namespace orc {
+class LLJIT;
 class ThreadSafeContext;
 }
 class Module;
@@ -58,6 +59,7 @@
   static llvm::Expected>
   create(std::unique_ptr CI);
   const CompilerInstance *getCompilerInstance() const;
+  const llvm::orc::LLJIT *getExecutionEngine() const;
   llvm::Expected Parse(llvm::StringRef Code);
   llvm::Error Execute(PartialTranslationUnit );
   llvm::Error ParseAndExecute(llvm::StringRef Code) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121413: [clang-repl] Add an accessor to our underlying execution engine

2022-03-10 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: rsmith, lhames, sgraenitz.
Herald added a project: All.
v.g.vassilev requested review of this revision.

This patch will allow better incremental adoption of these changes in 
downstream cling and other users which want to experiment by customizing the 
execution engine.


Repository:
  rC Clang

https://reviews.llvm.org/D121413

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/Interpreter.cpp


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -196,6 +196,12 @@
   return IncrParser->getCI();
 }
 
+const llvm::orc::LLJIT *Interpreter::getExecutionEngine() const {
+  if (IncrExecutor)
+return IncrExecutor->getExecutionEngine();
+  return nullptr;
+}
+
 llvm::Expected
 Interpreter::Parse(llvm::StringRef Code) {
   return IncrParser->Parse(Code);
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -45,6 +45,7 @@
   llvm::Error runCtors() const;
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
+  llvm::orc::LLJIT *getExecutionEngine() const { return Jit.get(); }
 };
 
 } // end namespace clang
Index: clang/include/clang/Interpreter/Interpreter.h
===
--- clang/include/clang/Interpreter/Interpreter.h
+++ clang/include/clang/Interpreter/Interpreter.h
@@ -27,6 +27,7 @@
 namespace llvm {
 namespace orc {
 class ThreadSafeContext;
+class LLJIT;
 }
 class Module;
 } // namespace llvm
@@ -58,6 +59,7 @@
   static llvm::Expected>
   create(std::unique_ptr CI);
   const CompilerInstance *getCompilerInstance() const;
+  const llvm::orc::LLJIT *getExecutionEngine() const;
   llvm::Expected Parse(llvm::StringRef Code);
   llvm::Error Execute(PartialTranslationUnit );
   llvm::Error ParseAndExecute(llvm::StringRef Code) {


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -196,6 +196,12 @@
   return IncrParser->getCI();
 }
 
+const llvm::orc::LLJIT *Interpreter::getExecutionEngine() const {
+  if (IncrExecutor)
+return IncrExecutor->getExecutionEngine();
+  return nullptr;
+}
+
 llvm::Expected
 Interpreter::Parse(llvm::StringRef Code) {
   return IncrParser->Parse(Code);
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -45,6 +45,7 @@
   llvm::Error runCtors() const;
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
+  llvm::orc::LLJIT *getExecutionEngine() const { return Jit.get(); }
 };
 
 } // end namespace clang
Index: clang/include/clang/Interpreter/Interpreter.h
===
--- clang/include/clang/Interpreter/Interpreter.h
+++ clang/include/clang/Interpreter/Interpreter.h
@@ -27,6 +27,7 @@
 namespace llvm {
 namespace orc {
 class ThreadSafeContext;
+class LLJIT;
 }
 class Module;
 } // namespace llvm
@@ -58,6 +59,7 @@
   static llvm::Expected>
   create(std::unique_ptr CI);
   const CompilerInstance *getCompilerInstance() const;
+  const llvm::orc::LLJIT *getExecutionEngine() const;
   llvm::Expected Parse(llvm::StringRef Code);
   llvm::Error Execute(PartialTranslationUnit );
   llvm::Error ParseAndExecute(llvm::StringRef Code) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121412: Complete the list of single-underscore keywords for MSVC compat.

2022-03-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma created this revision.
efriedma added reviewers: rnk, mstorsjo.
Herald added a subscriber: dexonsmith.
Herald added a project: All.
efriedma requested review of this revision.
Herald added a project: clang.

List derived from https://docs.microsoft.com/en-us/cpp/cpp/keywords-cpp .  Not 
that this is something we really want to encourage, but some of these show up 
in practice, so I figured I should just complete the list.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121412

Files:
  clang/include/clang/Basic/TokenKinds.def


Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -676,24 +676,40 @@
 KEYWORD(__virtual_inheritance , KEYMS)
 KEYWORD(__interface   , KEYMS)
 ALIAS("__int8"   , char   , KEYMS)
-ALIAS("_int8", char   , KEYMS)
 ALIAS("__int16"  , short  , KEYMS)
-ALIAS("_int16"   , short  , KEYMS)
 ALIAS("__int32"  , int, KEYMS)
-ALIAS("_int32"   , int, KEYMS)
-ALIAS("_int64"   , __int64, KEYMS)
 ALIAS("__wchar_t", wchar_t, KEYMS)
-ALIAS("_asm" , asm, KEYMS)
-ALIAS("_alignof" , __alignof  , KEYMS)
 ALIAS("__builtin_alignof", __alignof  , KEYMS)
-ALIAS("_cdecl"   , __cdecl, KEYMS | KEYBORLAND)
-ALIAS("_fastcall", __fastcall , KEYMS | KEYBORLAND)
-ALIAS("_stdcall" , __stdcall  , KEYMS | KEYBORLAND)
-ALIAS("_thiscall", __thiscall , KEYMS)
-ALIAS("_vectorcall"  , __vectorcall, KEYMS)
-ALIAS("_uuidof"  , __uuidof   , KEYMS | KEYBORLAND)
-ALIAS("_inline"  , inline , KEYMS)
-ALIAS("_declspec", __declspec , KEYMS)
+
+// Microsoft single-underscore prefixed aliases for double-underscore prefixed
+// keywords.
+ALIAS("_asm" , asm  , KEYMS)
+ALIAS("_alignof" , __alignof, KEYMS)
+ALIAS("_cdecl"   , __cdecl  , KEYMS | KEYBORLAND)
+ALIAS("_declspec", __declspec   , KEYMS)
+ALIAS("_except"  , __except , KEYMS)
+ALIAS("_fastcall", __fastcall   , KEYMS | KEYBORLAND)
+ALIAS("_finally" , __finally, KEYMS)
+ALIAS("_forceinline" , __forceinline, KEYMS)
+ALIAS("_inline"  , inline   , KEYMS)
+ALIAS("_int8", char , KEYMS)
+ALIAS("_int16"   , short, KEYMS)
+ALIAS("_int32"   , int  , KEYMS)
+ALIAS("_int64"   , __int64  , KEYMS)
+ALIAS("_leave"   , __leave  , KEYMS)
+ALIAS("_multiple_inheritance", __multiple_inheritance, KEYMS)
+ALIAS("_ptr32"   , __ptr32  , KEYMS)
+ALIAS("_ptr64"   , __ptr64  , KEYMS)
+ALIAS("_restrict", restrict , KEYMS)
+ALIAS("_stdcall" , __stdcall, KEYMS | KEYBORLAND)
+ALIAS("_thiscall", __thiscall   , KEYMS)
+ALIAS("_try" , __try, KEYMS)
+ALIAS("_vectorcall"  , __vectorcall , KEYMS)
+ALIAS("_unaligned"   , __unaligned  , KEYMS)
+ALIAS("_uptr", __uptr   , KEYMS)
+ALIAS("_uuidof"  , __uuidof , KEYMS | KEYBORLAND)
+ALIAS("_virtual_inheritance", __virtual_inheritance, KEYMS)
+ALIAS("_w64" , __w64, KEYMS)
 
 // Borland Extensions which should be disabled in strict conformance mode.
 ALIAS("_pascal"  , __pascal   , KEYBORLAND)


Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -676,24 +676,40 @@
 KEYWORD(__virtual_inheritance , KEYMS)
 KEYWORD(__interface   , KEYMS)
 ALIAS("__int8"   , char   , KEYMS)
-ALIAS("_int8", char   , KEYMS)
 ALIAS("__int16"  , short  , KEYMS)
-ALIAS("_int16"   , short  , KEYMS)
 ALIAS("__int32"  , int, KEYMS)
-ALIAS("_int32"   , int, KEYMS)
-ALIAS("_int64"   , __int64, KEYMS)
 ALIAS("__wchar_t", wchar_t, KEYMS)
-ALIAS("_asm" , asm, KEYMS)
-ALIAS("_alignof" , __alignof  , KEYMS)
 ALIAS("__builtin_alignof", __alignof  , KEYMS)
-ALIAS("_cdecl"   , __cdecl, KEYMS | KEYBORLAND)
-ALIAS("_fastcall", __fastcall , KEYMS | KEYBORLAND)
-ALIAS("_stdcall" , __stdcall  , KEYMS | KEYBORLAND)
-ALIAS("_thiscall", __thiscall , KEYMS)
-ALIAS("_vectorcall"  , __vectorcall, KEYMS)
-ALIAS("_uuidof"  , __uuidof   , KEYMS | KEYBORLAND)
-ALIAS("_inline"  , inline , KEYMS)
-ALIAS("_declspec", __declspec , KEYMS)
+
+// Microsoft single-underscore prefixed aliases for double-underscore prefixed
+// keywords.
+ALIAS("_asm" , asm  , KEYMS)
+ALIAS("_alignof" , __alignof, KEYMS)

[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

@aaron.ballman : if you can add other reviewers or subscribers (particularly 
those from "VendorA") it would be greatly appreciated!


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

https://reviews.llvm.org/D121410

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


[PATCH] D121410: Have cpu-specific variants set 'tune-cpu' as an optimization hint

2022-03-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added a reviewer: aaron.ballman.
Herald added a subscriber: pengfei.
Herald added a project: All.
erichkeane requested review of this revision.

Due to various implementation constraints, despite the programmer
choosing a 'processor' cpu_dispatch/cpu_specific needs to use the
'feature' list of a processor to identify it.  This results in the
identified processor in source-code not being propogated to the
optimizer, and thus, not able to be tuned for.

This patch changes to use the actual cpu as written for tune-cpu so that
opt can make decisions based on the cpu-as-spelled, which should better
match the behavior expected by the programmer.

Note that the 'valid' list of processors for x86 is in
llvm/include/llvm/Support/X86TargetParser.def.  At the moment, this list
contains only Intel processors, but other vendors may wish to add their
own entries as 'alias'es (or wiht different feature lists!).

If this is not done, there is two potential performance issues with the 
patch, but I believe them to be worth it in light of the improvements to
behavior and performance.

1- In the event that the user spelled "ProcessorB", but we only have the
features available to test for "ProcessorA" (where A is B minus features),
AND there is an optimization opportunity for "B" that negatively affects
"A", the optimizer will likely choose to do so.

2- In the even that the user spelled VendorI's processor, and the feature
list allows it to run on VendorA's processor of similar features, AND there
is an optimization opportunity for VendorIs that negatively affects "A"s,
the optimizer will likely choose to do so.  This can be fixed by adding an
alias to X86TargetParser.def.


https://reviews.llvm.org/D121410

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific.c


Index: clang/test/CodeGen/attr-cpuspecific.c
===
--- clang/test/CodeGen/attr-cpuspecific.c
+++ clang/test/CodeGen/attr-cpuspecific.c
@@ -340,5 +340,8 @@
 void OrderDispatchUsageSpecific(void) {}
 
 // CHECK: attributes #[[S]] = 
{{.*}}"target-features"="+avx,+cmov,+crc32,+cx8,+f16c,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK-SAME: "tune-cpu"="ivybridge"
 // CHECK: attributes #[[K]] = 
{{.*}}"target-features"="+adx,+avx,+avx2,+avx512cd,+avx512er,+avx512f,+avx512pf,+bmi,+cmov,+crc32,+cx8,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK-SAME: "tune-cpu"="knl"
 // CHECK: attributes #[[O]] = 
{{.*}}"target-features"="+cmov,+cx8,+mmx,+movbe,+sse,+sse2,+sse3,+ssse3,+x87"
+// CHECK-SAME: "tune-cpu"="atom"
Index: clang/test/CodeGen/attr-cpuspecific-avx-abi.c
===
--- clang/test/CodeGen/attr-cpuspecific-avx-abi.c
+++ clang/test/CodeGen/attr-cpuspecific-avx-abi.c
@@ -23,4 +23,6 @@
 // CHECK: define{{.*}} @foo.V() #[[V:[0-9]+]]
 
 // CHECK: attributes #[[A]] = 
{{.*}}"target-features"="+avx,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK-SAME: "tune-cpu"="generic"
 // CHECK: attributes #[[V]] = 
{{.*}}"target-features"="+avx,+avx2,+bmi,+cmov,+crc32,+cx8,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK-SAME: "tune-cpu"="core_4th_gen_avx"
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2060,6 +2060,12 @@
   getTarget().isValidCPUName(ParsedAttr.Tune))
 TuneCPU = ParsedAttr.Tune;
 }
+
+if (SD) {
+  // Apply the given CPU name as the 'tune-cpu' so that the optimizer can
+  // favor this processor.
+  TuneCPU = SD->getCPUName(GD.getMultiVersionIndex())->getName();
+}
   } else {
 // Otherwise just add the existing target cpu and target features to the
 // function.


Index: clang/test/CodeGen/attr-cpuspecific.c
===
--- clang/test/CodeGen/attr-cpuspecific.c
+++ clang/test/CodeGen/attr-cpuspecific.c
@@ -340,5 +340,8 @@
 void OrderDispatchUsageSpecific(void) {}
 
 // CHECK: attributes #[[S]] = {{.*}}"target-features"="+avx,+cmov,+crc32,+cx8,+f16c,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK-SAME: "tune-cpu"="ivybridge"
 // CHECK: attributes #[[K]] = {{.*}}"target-features"="+adx,+avx,+avx2,+avx512cd,+avx512er,+avx512f,+avx512pf,+bmi,+cmov,+crc32,+cx8,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK-SAME: "tune-cpu"="knl"
 // CHECK: attributes #[[O]] = {{.*}}"target-features"="+cmov,+cx8,+mmx,+movbe,+sse,+sse2,+sse3,+ssse3,+x87"
+// CHECK-SAME: "tune-cpu"="atom"
Index: clang/test/CodeGen/attr-cpuspecific-avx-abi.c

[PATCH] D119675: Also remove the empty StoredDeclsList entry from the lookup table

2022-03-10 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.
Herald added a project: All.

ping.


Repository:
  rC Clang

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

https://reviews.llvm.org/D119675

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


[PATCH] D121352: [clang-format] Handle "// clang-format off" for RemoveBracesLLVM

2022-03-10 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe2b219bded11: [clang-format] Handle // clang-format 
off for RemoveBracesLLVM (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121352

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -24805,6 +24805,19 @@
"}",
Style);
 
+  verifyFormat("// clang-format off\n"
+   "// comment\n"
+   "while (i > 0) { --i; }\n"
+   "// clang-format on\n"
+   "while (j < 0)\n"
+   "  ++j;",
+   "// clang-format off\n"
+   "// comment\n"
+   "while (i > 0) { --i; }\n"
+   "// clang-format on\n"
+   "while (j < 0) { ++j; }",
+   Style);
+
   verifyFormat("if (a)\n"
"  b; // comment\n"
"else if (c)\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1808,7 +1808,8 @@
   removeBraces(Line->Children, Result);
   if (!Line->Affected)
 continue;
-  for (FormatToken *Token = Line->First; Token; Token = Token->Next) {
+  for (FormatToken *Token = Line->First; Token && !Token->Finalized;
+   Token = Token->Next) {
 if (!Token->Optional)
   continue;
 assert(Token->isOneOf(tok::l_brace, tok::r_brace));


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -24805,6 +24805,19 @@
"}",
Style);
 
+  verifyFormat("// clang-format off\n"
+   "// comment\n"
+   "while (i > 0) { --i; }\n"
+   "// clang-format on\n"
+   "while (j < 0)\n"
+   "  ++j;",
+   "// clang-format off\n"
+   "// comment\n"
+   "while (i > 0) { --i; }\n"
+   "// clang-format on\n"
+   "while (j < 0) { ++j; }",
+   Style);
+
   verifyFormat("if (a)\n"
"  b; // comment\n"
"else if (c)\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1808,7 +1808,8 @@
   removeBraces(Line->Children, Result);
   if (!Line->Affected)
 continue;
-  for (FormatToken *Token = Line->First; Token; Token = Token->Next) {
+  for (FormatToken *Token = Line->First; Token && !Token->Finalized;
+   Token = Token->Next) {
 if (!Token->Optional)
   continue;
 assert(Token->isOneOf(tok::l_brace, tok::r_brace));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e2b219b - [clang-format] Handle "// clang-format off" for RemoveBracesLLVM

2022-03-10 Thread via cfe-commits

Author: owenca
Date: 2022-03-10T13:30:53-08:00
New Revision: e2b219bded113160500d1084f87ee11ec926877b

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

LOG: [clang-format] Handle "// clang-format off" for RemoveBracesLLVM

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 6c2765c038436..a8b8efb5b22f5 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1808,7 +1808,8 @@ class BracesRemover : public TokenAnalyzer {
   removeBraces(Line->Children, Result);
   if (!Line->Affected)
 continue;
-  for (FormatToken *Token = Line->First; Token; Token = Token->Next) {
+  for (FormatToken *Token = Line->First; Token && !Token->Finalized;
+   Token = Token->Next) {
 if (!Token->Optional)
   continue;
 assert(Token->isOneOf(tok::l_brace, tok::r_brace));

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 1d9b158ee6475..dab8f83fffe3c 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -24805,6 +24805,19 @@ TEST_F(FormatTest, RemoveBraces) {
"}",
Style);
 
+  verifyFormat("// clang-format off\n"
+   "// comment\n"
+   "while (i > 0) { --i; }\n"
+   "// clang-format on\n"
+   "while (j < 0)\n"
+   "  ++j;",
+   "// clang-format off\n"
+   "// comment\n"
+   "while (i > 0) { --i; }\n"
+   "// clang-format on\n"
+   "while (j < 0) { ++j; }",
+   Style);
+
   verifyFormat("if (a)\n"
"  b; // comment\n"
"else if (c)\n"



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


[PATCH] D121269: [clang-format] Fix namespace format when the name is followed by a macro

2022-03-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.



Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:108
+  // which one is name. For example, `namespace A B {`.
+  while (Tok && !Tok->is(tok::l_brace)) {
+if (FirstNSTok) {





Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:116
+}
+if (!FirstNSTok->is(tok::coloncolon)) {
+  NameFinished = true;





Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:135
   }
-  return name;
+  if (!NameFinished && FirstNSTok && !FirstNSTok->is(tok::l_brace))
+name += FirstNSTok->TokenText;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121269

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


[PATCH] D121380: Pragma `clang fp eval_method` needs to take as input a supported value.

2022-03-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG15ef06f453c6: Diagnose when `#pragma clang fp eval_method` 
doesnt have a supported value. (authored by zahiraam).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121380

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/test/Sema/fp-eval-pragma.cpp


Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+  // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp 
eval_method'; expected 'source', 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 
'assume_safety'}1 or 'disable'">;


Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+  // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp eval_method'; expected 'source', 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 'assume_safety'}1 or 'disable'">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 15ef06f - Diagnose when `#pragma clang fp eval_method` doesn't have a supported value.

2022-03-10 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2022-03-10T13:19:53-08:00
New Revision: 15ef06f453c6f9513b476e80dd9567d01fc662e8

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

LOG: Diagnose when `#pragma clang fp eval_method` doesn't have a supported 
value.
Currently the compiler is crashing.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/test/Sema/fp-eval-pragma.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 92ae27d6212a0..7af15f5504ff9 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@ def err_pragma_fp_invalid_argument : Error<
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 
'assume_safety'}1 or 'disable'">;

diff  --git a/clang/test/Sema/fp-eval-pragma.cpp 
b/clang/test/Sema/fp-eval-pragma.cpp
index 42d88fd438e81..571b8097e9abf 100644
--- a/clang/test/Sema/fp-eval-pragma.cpp
+++ b/clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@ int foo2() {
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+  // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp 
eval_method'; expected 'source', 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {



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


[PATCH] D121405: [ASan] Moved optimized callbacks out of asan_static to avoid DSO size increase.

2022-03-10 Thread Kirill Stoimenov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG035441ff3008: [ASan] Moved optimized callbacks out of 
asan_static to avoid DSO size increase. (authored by kstoimenov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121405

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/asan_rtl_x86_64.S


Index: compiler-rt/lib/asan/asan_rtl_x86_64.S
===
--- compiler-rt/lib/asan/asan_rtl_x86_64.S
+++ compiler-rt/lib/asan/asan_rtl_x86_64.S
@@ -42,7 +42,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 1, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##1_asm ;\
+jmp__asan_report_##op##1 ;\
 
 #define ASAN_MEMORY_ACCESS_EXTRA_CHECK_2(reg, op, i) \
 CLABEL(reg, op, 2, i): ;\
@@ -54,7 +54,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 2, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##2_asm ;\
+jmp__asan_report_##op##2 ;\
 
 #define ASAN_MEMORY_ACCESS_EXTRA_CHECK_4(reg, op, i) \
 CLABEL(reg, op, 4, i): ;\
@@ -66,7 +66,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 4, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##4_asm ;\
+jmp__asan_report_##op##4 ;\
 
 #define ASAN_MEMORY_ACCESS_CALLBACK_ADD_1(reg, op) \
 BEGINF(reg, op, 1, add) ;\
@@ -97,7 +97,7 @@
 #define ASAN_MEMORY_ACCESS_FAIL(reg, op, s, i) \
 FLABEL(reg, op, s, i): ;\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##s##_asm;\
+jmp__asan_report_##op##s##;\
 
 #define ASAN_MEMORY_ACCESS_CALLBACK_ADD_8(reg, op) \
 BEGINF(reg, op, 8, add) ;\
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,6 +34,7 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
+asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -48,7 +49,6 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_STATIC_SOURCES
-asan_rtl_x86_64.S
   )
 endif()
 
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -30,7 +30,6 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-EXECUTABLE-LINUX %s
 //
-// CHECK-ASAN-EXECUTABLE-LINUX: libclang_rt.asan_static-x86_64
 // CHECK-ASAN-EXECUTABLE-LINUX: libclang_rt.asan-x86_64
 
 // RUN: %clang -fsanitize=address -shared %s -### -o %t.o 2>&1  \
@@ -39,7 +38,6 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-SHARED-LINUX %s
 //
-// CHECK-ASAN-SHARED-LINUX: libclang_rt.asan_static-x86_64
 // CHECK-ASAN-SHARED-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -842,10 +842,6 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
-  // Always link the static runtime regardless of DSO or executable.
-  if (SanArgs.needsAsanRt())
-HelperStaticRuntimes.push_back("asan_static");
-
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.


Index: compiler-rt/lib/asan/asan_rtl_x86_64.S
===
--- compiler-rt/lib/asan/asan_rtl_x86_64.S
+++ compiler-rt/lib/asan/asan_rtl_x86_64.S
@@ -42,7 +42,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 1, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##1_asm ;\
+jmp__asan_report_##op##1 ;\
 
 #define ASAN_MEMORY_ACCESS_EXTRA_CHECK_2(reg, op, i) \
 CLABEL(reg, op, 2, i): ;\
@@ -54,7 +54,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 2, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##2_asm ;\
+jmp__asan_report_##op##2 ;\
 
 #define ASAN_MEMORY_ACCESS_EXTRA_CHECK_4(reg, op, i) \
 CLABEL(reg, op, 4, i): ;\
@@ -66,7 +66,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 4, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##4_asm ;\
+jmp__asan_report_##op##4 ;\
 
 #define ASAN_MEMORY_ACCESS_CALLBACK_ADD_1(reg, op) \
 BEGINF(reg, op, 1, add) ;\
@@ -97,7 +97,7 @@
 #define ASAN_MEMORY_ACCESS_FAIL(reg, op, s, i) \
 FLABEL(reg, op, s, i): ;\
 mov%##reg,%rdi ;\
-jmp

[clang] 035441f - [ASan] Moved optimized callbacks out of asan_static to avoid DSO size increase.

2022-03-10 Thread Kirill Stoimenov via cfe-commits

Author: Kirill Stoimenov
Date: 2022-03-10T21:11:32Z
New Revision: 035441ff3008c2a1930363751c6db61b71a5f089

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

LOG: [ASan] Moved optimized callbacks out of asan_static to avoid DSO size 
increase.

Reviewed By: vitalybuka

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/sanitizer-ld.c
compiler-rt/lib/asan/CMakeLists.txt
compiler-rt/lib/asan/asan_rtl_x86_64.S

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index abbba00e97537..2f3dc86eaad1d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -842,10 +842,6 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
-  // Always link the static runtime regardless of DSO or executable.
-  if (SanArgs.needsAsanRt())
-HelperStaticRuntimes.push_back("asan_static");
-
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index 966edbd7d038b..9a7a7db284c5d 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -30,7 +30,6 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-EXECUTABLE-LINUX %s
 //
-// CHECK-ASAN-EXECUTABLE-LINUX: libclang_rt.asan_static-x86_64
 // CHECK-ASAN-EXECUTABLE-LINUX: libclang_rt.asan-x86_64
 
 // RUN: %clang -fsanitize=address -shared %s -### -o %t.o 2>&1  \
@@ -39,7 +38,6 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-SHARED-LINUX %s
 //
-// CHECK-ASAN-SHARED-LINUX: libclang_rt.asan_static-x86_64
 // CHECK-ASAN-SHARED-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \

diff  --git a/compiler-rt/lib/asan/CMakeLists.txt 
b/compiler-rt/lib/asan/CMakeLists.txt
index 0e7250a8fa10b..0862a3d648fa2 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -34,6 +34,7 @@ set(ASAN_SOURCES
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
+asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -48,7 +49,6 @@ set(ASAN_STATIC_SOURCES
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_STATIC_SOURCES
-asan_rtl_x86_64.S
   )
 endif()
 

diff  --git a/compiler-rt/lib/asan/asan_rtl_x86_64.S 
b/compiler-rt/lib/asan/asan_rtl_x86_64.S
index 50e039e53d626..92376f5b9a78f 100644
--- a/compiler-rt/lib/asan/asan_rtl_x86_64.S
+++ b/compiler-rt/lib/asan/asan_rtl_x86_64.S
@@ -42,7 +42,7 @@ CLABEL(reg, op, 1, i): ;\
 pop%rcx ;\
 jl RLABEL(reg, op, 1, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##1_asm ;\
+jmp__asan_report_##op##1 ;\
 
 #define ASAN_MEMORY_ACCESS_EXTRA_CHECK_2(reg, op, i) \
 CLABEL(reg, op, 2, i): ;\
@@ -54,7 +54,7 @@ CLABEL(reg, op, 2, i): ;\
 pop%rcx ;\
 jl RLABEL(reg, op, 2, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##2_asm ;\
+jmp__asan_report_##op##2 ;\
 
 #define ASAN_MEMORY_ACCESS_EXTRA_CHECK_4(reg, op, i) \
 CLABEL(reg, op, 4, i): ;\
@@ -66,7 +66,7 @@ CLABEL(reg, op, 4, i): ;\
 pop%rcx ;\
 jl RLABEL(reg, op, 4, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##4_asm ;\
+jmp__asan_report_##op##4 ;\
 
 #define ASAN_MEMORY_ACCESS_CALLBACK_ADD_1(reg, op) \
 BEGINF(reg, op, 1, add) ;\
@@ -97,7 +97,7 @@ ENDF
 #define ASAN_MEMORY_ACCESS_FAIL(reg, op, s, i) \
 FLABEL(reg, op, s, i): ;\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##s##_asm;\
+jmp__asan_report_##op##s##;\
 
 #define ASAN_MEMORY_ACCESS_CALLBACK_ADD_8(reg, op) \
 BEGINF(reg, op, 8, add) ;\



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


[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/test/CodeGen/eval-method-fast-math.c:83
+#pragma float_control(pop)
+
+int getFPEvalMethod() {

aaron.ballman wrote:
> What should happen in a case like this?
> ```
> int whatever(float a, float b, float c) {
>   #pragma float_control(precise, off)
>   res = a + b + c;
>   int val = __FLT_EVAL_METHOD__;
>   #pragma float_control(precise, on)
>   return __FLT_EVAL_METHOD__;
> }
> ```
> I would expect that `int val` would hold `-1` and the return statement would 
> return `0`?
This test case is failing with this error (at the second pragma):

  t1.cpp:9:11: error: '#pragma float_control' can only appear at file scope or 
at
  the start of a compound statement
  #pragma float_control(precise, off)
  ^
  1 error generated.

Tried this:

  int whatever(float a, float b, float c) {
  #pragma float_control(precise, off)
  res = a + b + c;
  int val =__FLT_EVAL_METHOD__;
  {
  #pragma float_control(precise, on)
  return __FLT_EVAL_METHOD__;
  }
}

This generated these last IR instructions:
  store float %add1, float* @"?res@@3MA", align 4
  store i32 -1, i32* %val, align 4
  ret i32 -1

Not sure if this is correct. I guess the first pragma (off) didn't popped, so 
it's still on?  But inside the scope of the second pragma the first pragma 
shouldn't be visible? Not sure what should happen here. 


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

https://reviews.llvm.org/D121122

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


[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-03-10 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk planned changes to this revision.
kwk added a comment.

A test if failing. Need to address this first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

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


[PATCH] D121283: [Clang] Support multiple attributes in a single pragma

2022-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thanks for this, I plan on giving it a more thorough review when I can. But the 
summary led me to a design question: why do we support multiple attribute 
*specifiers* in the same pragma? I would not expect to be able to mix attribute 
styles in the same pragma given that all of the individual styles allow you to 
specify multiple attributes within a single specifier. e.g., 
https://godbolt.org/z/9v7r6Eanz

  __declspec(deprecated, naked) void f();
  __attribute__((annotate("test"), constructor(0))) void g();
  [[clang::annotate("test"), gnu::constructor(0)]] void h();

What's the use case for letting someone mix and match attribute styles as in:

  #pragma clang attribute push ([[clang::disable_tail_calls]] 
__attribute__((annotate("test"))), apply_to = function)

and why is whitespace the correct separator as opposed to a comma-delimited 
list?

(Note, I'm still thinking about whether this approach poses any actual 
problems; it may be perfectly fine, but it'd help to know why we're being lax 
in mixing forms and what the rationale is for whitespace separation; that's not 
a common approach to lists of things in C or C++).

Also, I'd expect there to be some documentation changes along with this patch 
and a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121283

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


[PATCH] D121405: [ASan] Moved optimized callbacks out of asan_static to avoid DSO size increase.

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

LGTM, but maybe we can chat about that later today


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121405

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


[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-03-10 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk added a comment.

Thank you for your comments! I've addressed many of them and now address the 
rest.




Comment at: clang/lib/Format/Format.cpp:2759
+  IncludeName =
+  StringRef(Twine("<", IncludeName).concat(Twine(">")).str());
+}

curdeius wrote:
> HazardyKnusperkeks wrote:
> > How does that not go out of scope and I have a dangling reference?
> Why not doing it the other way round, i.e. trimming `<>"` from include name?
> Why not doing it the other way round, i.e. trimming `<>"` from include name?

Because the include name is used for sorting later and if the `<>` is removed 
from the name, the `<>` included will be mixed with the `""`. That's 
undesirable. 



Comment at: clang/lib/Format/Format.cpp:2759
+  IncludeName =
+  StringRef(Twine("<", IncludeName).concat(Twine(">")).str());
+}

kwk wrote:
> curdeius wrote:
> > HazardyKnusperkeks wrote:
> > > How does that not go out of scope and I have a dangling reference?
> > Why not doing it the other way round, i.e. trimming `<>"` from include name?
> > Why not doing it the other way round, i.e. trimming `<>"` from include name?
> 
> Because the include name is used for sorting later and if the `<>` is removed 
> from the name, the `<>` included will be mixed with the `""`. That's 
> undesirable. 
> How does that not go out of scope and I have a dangling reference?

Sorry I was a bit lost with this but with some help I found other places in 
which `concat` was used and `toStringRef`. I hope everything is fine now.



Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:177
 const char IncludeRegexPattern[] =
-R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
+R"(^[\t\ ]*[@#]?[\t\ ]*(import|include)[^"<]*[\t\n\ 
\\]*("[^"]+"|<[^>]+>|[^"<>;]+;))";
 

HazardyKnusperkeks wrote:
> HazardyKnusperkeks wrote:
> > I don't see why this is needed. It should match with the previous stuff.
> Do we want that optional?
> I don't see why this is needed. It should match with the previous stuff.

That's why I thought too. I swear I ran the tests before and I wouldn't work 
without this. But I re-ran the tests and now it works. Thanks for bringing up 
this very obvious part.



Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:177
 const char IncludeRegexPattern[] =
-R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
+R"(^[\t\ ]*[@#]?[\t\ ]*(import|include)[^"<]*[\t\n\ 
\\]*("[^"]+"|<[^>]+>|[^"<>;]+;))";
 

kwk wrote:
> HazardyKnusperkeks wrote:
> > HazardyKnusperkeks wrote:
> > > I don't see why this is needed. It should match with the previous stuff.
> > Do we want that optional?
> > I don't see why this is needed. It should match with the previous stuff.
> 
> That's why I thought too. I swear I ran the tests before and I wouldn't work 
> without this. But I re-ran the tests and now it works. Thanks for bringing up 
> this very obvious part.
> Do we want that optional?

We don't need it optional for the tests to pass. Only for C++20 Modules, we 
need it optional. But this is *not* part of this change. I've removed the 
optional part of this. 



Comment at: clang/unittests/Format/SortIncludesTest.cpp:471
+ "@import Foundation;\n"
+ "#import \"a.h\"\n"));
+}

HazardyKnusperkeks wrote:
> I've no idea about obj-c, is it feasible to mix `#` and `@`? If so please add 
> a test where the `@` is between `#`s.
> I've no idea about obj-c, is it feasible to mix `#` and `@`? If so please add 
> a test where the `@` is between `#`s.

This test is copied from the issue itself. I have no idea about Obj-c as well. 
The `@` already *is* between the `#`. Did I miss something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

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


[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-03-10 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 414469.
kwk marked 2 inline comments as done.
kwk added a comment.

- Make @ or # not optional again
- Remove [\t\n\ \\]*
- Properly concat string


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -458,6 +458,19 @@
  "#include \"b.h\"\n"));
 }
 
+TEST_F(SortIncludesTest, SupportAtImportLines) {
+  EXPECT_EQ("#import \"a.h\"\n"
+"#import \"b.h\"\n"
+"#import \"c.h\"\n"
+"#import \n"
+"@import Foundation;\n",
+sort("#import \"b.h\"\n"
+ "#import \"c.h\"\n"
+ "#import \n"
+ "@import Foundation;\n"
+ "#import \"a.h\"\n"));
+}
+
 TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
   EXPECT_EQ("#include \"llvm/a.h\"\n"
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -170,11 +170,11 @@
 }
 
 inline StringRef trimInclude(StringRef IncludeName) {
-  return IncludeName.trim("\"<>");
+  return IncludeName.trim("\"<>;");
 }
 
 const char IncludeRegexPattern[] =
-R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
+R"(^[\t\ ]*[@#][\t\ ]*(import|include)[^"<]*("[^"]+"|<[^>]+>|[^"<>;]+;))";
 
 // The filename of Path excluding extension.
 // Used to match implementation with headers, this differs from 
sys::path::stem:
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2682,7 +2682,7 @@
 namespace {
 
 const char CppIncludeRegexPattern[] =
-R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
+R"(^[\t\ ]*[@#][\t\ ]*(import|include)[^"<]*("[^"]+"|<[^>]+>|[^"<>;]+;))";
 
 } // anonymous namespace
 
@@ -2752,6 +2752,15 @@
 if (!FormattingOff && !MergeWithNextLine) {
   if (IncludeRegex.match(Line, )) {
 StringRef IncludeName = Matches[2];
+SmallString<0> IncludeNameStr;
+// HACK(kkleine): Sort C++ module includes/imports that are not 
enclosed
+// in "" or <> as if they are enclosed with <.
+if (!IncludeName.startswith("\"") && !IncludeName.startswith("<")) {
+  IncludeName = Twine("<", IncludeName)
+.concat(Twine(">"))
+.toStringRef(IncludeNameStr);
+}
+
 if (Line.contains("/*") && !Line.contains("*/")) {
   // #include with a start of a block comment, but without the end.
   // Need to keep all the lines until the end of the comment together.


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -458,6 +458,19 @@
  "#include \"b.h\"\n"));
 }
 
+TEST_F(SortIncludesTest, SupportAtImportLines) {
+  EXPECT_EQ("#import \"a.h\"\n"
+"#import \"b.h\"\n"
+"#import \"c.h\"\n"
+"#import \n"
+"@import Foundation;\n",
+sort("#import \"b.h\"\n"
+ "#import \"c.h\"\n"
+ "#import \n"
+ "@import Foundation;\n"
+ "#import \"a.h\"\n"));
+}
+
 TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
   EXPECT_EQ("#include \"llvm/a.h\"\n"
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -170,11 +170,11 @@
 }
 
 inline StringRef trimInclude(StringRef IncludeName) {
-  return IncludeName.trim("\"<>");
+  return IncludeName.trim("\"<>;");
 }
 
 const char IncludeRegexPattern[] =
-R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
+R"(^[\t\ ]*[@#][\t\ ]*(import|include)[^"<]*("[^"]+"|<[^>]+>|[^"<>;]+;))";
 
 // The filename of Path excluding extension.
 // Used to match implementation with headers, this differs from sys::path::stem:
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2682,7 +2682,7 @@
 namespace {
 
 const char CppIncludeRegexPattern[] =

[PATCH] D121380: Pragma `clang fp eval_method` needs to take as input a supported value.

2022-03-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 414467.

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

https://reviews.llvm.org/D121380

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/test/Sema/fp-eval-pragma.cpp


Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+  // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp 
eval_method'; expected 'source', 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 
'assume_safety'}1 or 'disable'">;


Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+  // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp eval_method'; expected 'source', 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 'assume_safety'}1 or 'disable'">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121405: [ASan] Moved optimized callbacks out of asan_static to avoid DSO size increase.

2022-03-10 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov created this revision.
Herald added a subscriber: mgorny.
Herald added a project: All.
kstoimenov requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121405

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/asan_rtl_x86_64.S


Index: compiler-rt/lib/asan/asan_rtl_x86_64.S
===
--- compiler-rt/lib/asan/asan_rtl_x86_64.S
+++ compiler-rt/lib/asan/asan_rtl_x86_64.S
@@ -42,7 +42,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 1, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##1_asm ;\
+jmp__asan_report_##op##1 ;\
 
 #define ASAN_MEMORY_ACCESS_EXTRA_CHECK_2(reg, op, i) \
 CLABEL(reg, op, 2, i): ;\
@@ -54,7 +54,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 2, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##2_asm ;\
+jmp__asan_report_##op##2 ;\
 
 #define ASAN_MEMORY_ACCESS_EXTRA_CHECK_4(reg, op, i) \
 CLABEL(reg, op, 4, i): ;\
@@ -66,7 +66,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 4, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##4_asm ;\
+jmp__asan_report_##op##4 ;\
 
 #define ASAN_MEMORY_ACCESS_CALLBACK_ADD_1(reg, op) \
 BEGINF(reg, op, 1, add) ;\
@@ -97,7 +97,7 @@
 #define ASAN_MEMORY_ACCESS_FAIL(reg, op, s, i) \
 FLABEL(reg, op, s, i): ;\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##s##_asm;\
+jmp__asan_report_##op##s##;\
 
 #define ASAN_MEMORY_ACCESS_CALLBACK_ADD_8(reg, op) \
 BEGINF(reg, op, 8, add) ;\
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,6 +34,7 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
+asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -48,7 +49,6 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_STATIC_SOURCES
-asan_rtl_x86_64.S
   )
 endif()
 
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -30,7 +30,6 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-EXECUTABLE-LINUX %s
 //
-// CHECK-ASAN-EXECUTABLE-LINUX: libclang_rt.asan_static-x86_64
 // CHECK-ASAN-EXECUTABLE-LINUX: libclang_rt.asan-x86_64
 
 // RUN: %clang -fsanitize=address -shared %s -### -o %t.o 2>&1  \
@@ -39,7 +38,6 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-SHARED-LINUX %s
 //
-// CHECK-ASAN-SHARED-LINUX: libclang_rt.asan_static-x86_64
 // CHECK-ASAN-SHARED-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -842,10 +842,6 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
-  // Always link the static runtime regardless of DSO or executable.
-  if (SanArgs.needsAsanRt())
-HelperStaticRuntimes.push_back("asan_static");
-
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.


Index: compiler-rt/lib/asan/asan_rtl_x86_64.S
===
--- compiler-rt/lib/asan/asan_rtl_x86_64.S
+++ compiler-rt/lib/asan/asan_rtl_x86_64.S
@@ -42,7 +42,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 1, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##1_asm ;\
+jmp__asan_report_##op##1 ;\
 
 #define ASAN_MEMORY_ACCESS_EXTRA_CHECK_2(reg, op, i) \
 CLABEL(reg, op, 2, i): ;\
@@ -54,7 +54,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 2, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##2_asm ;\
+jmp__asan_report_##op##2 ;\
 
 #define ASAN_MEMORY_ACCESS_EXTRA_CHECK_4(reg, op, i) \
 CLABEL(reg, op, 4, i): ;\
@@ -66,7 +66,7 @@
 pop%rcx ;\
 jl RLABEL(reg, op, 4, i);\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##4_asm ;\
+jmp__asan_report_##op##4 ;\
 
 #define ASAN_MEMORY_ACCESS_CALLBACK_ADD_1(reg, op) \
 BEGINF(reg, op, 1, add) ;\
@@ -97,7 +97,7 @@
 #define ASAN_MEMORY_ACCESS_FAIL(reg, op, s, i) \
 FLABEL(reg, op, s, i): ;\
 mov%##reg,%rdi ;\
-jmp__asan_report_##op##s##_asm;\
+jmp

[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/CodeGen/eval-method-fast-math.c:83
+#pragma float_control(pop)
+
+int getFPEvalMethod() {

What should happen in a case like this?
```
int whatever(float a, float b, float c) {
  #pragma float_control(precise, off)
  res = a + b + c;
  int val = __FLT_EVAL_METHOD__;
  #pragma float_control(precise, on)
  return __FLT_EVAL_METHOD__;
}
```
I would expect that `int val` would hold `-1` and the return statement would 
return `0`?


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

https://reviews.llvm.org/D121122

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


[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 414461.

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

https://reviews.llvm.org/D121122

Files:
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/CodeGen/eval-method-fast-math.c

Index: clang/test/CodeGen/eval-method-fast-math.c
===
--- /dev/null
+++ clang/test/CodeGen/eval-method-fast-math.c
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - %s  \
+// RUN: | FileCheck %s -check-prefixes=CHECK
+
+// RUN: %clang_cc1 -triple i386--linux -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-EXT
+
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -mreassociate -freciprocal-math -ffp-contract=fast \
+// RUN: -ffast-math -triple x86_64-linux-gnu \
+// RUN: -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+// RUN: %clang_cc1 -triple i386--linux -mreassociate -freciprocal-math \
+// RUN: -ffp-contract=fast -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+float res;
+int add(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: load float, float*
+  // CHECK-FAST: fadd fast float
+  // CHECK: ret i32 0
+  // CHECK-EXT: ret i32 2
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+int add_precise(float a, float b, float c) {
+#pragma float_control(precise, on)
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+#pragma float_control(precise, on)
+int add_precise_1(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int add_not_precise(float a, float b, float c) {
+  // Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: load float, float*
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+// Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+int add_not_precise_1(float a, float b, float c) {
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: load float, float*
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int getFPEvalMethod() {
+  // CHECK: ret i32 0
+  return __FLT_EVAL_METHOD__;
+}
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -517,6 +517,9 @@
 else
   NewFPFeatures.setFPPreciseEnabled(false);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+// `AllowFPReassoc` or `AllowReciprocal` option is enabled.
+PP.setCurrentFPEvalMethod(
+Loc, LangOptions::FPEvalMethodKind::FEM_Indeterminable);
 break;
   case PFC_Except:
 if (!isPreciseFPEnabled())
@@ -540,6 +543,12 @@
 }
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
 NewFPFeatures = FpPragmaStack.CurrentValue;
+if (CurFPFeatures.getAllowFPReassociate() ||
+CurFPFeatures.getAllowReciprocal())
+  // Since we are popping the pragma, we don't want to be passing
+  // a location here.
+  PP.setCurrentFPEvalMethod(SourceLocation(),
+CurFPFeatures.getFPEvalMethod());
 break;
   }
   CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -254,6 +254,12 @@
 PP.setCurrentFPEvalMethod(SourceLocation(),
   getLangOpts().getFPEvalMethod());
   CurFPFeatures.setFPEvalMethod(PP.getCurrentFPEvalMethod());
+  // When `-ffast-math` option is enabled, it triggers several driver math
+  // options to be enabled. Among those, only one the following two modes
+  // affect the eval-method:  reciprocal or reassociate.
+  if (getLangOpts().AllowFPReassoc || getLangOpts().AllowRecip)
+PP.setCurrentFPEvalMethod(SourceLocation(),
+  LangOptions::FEM_Indeterminable);
 }
 
 // Anchor Sema's type info to this TU.
Index: clang/lib/Lex/PPMacroExpansion.cpp

[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 414460.
zahiraam marked an inline comment as done.

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

https://reviews.llvm.org/D121122

Files:
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/CodeGen/eval-method-fast-math.c

Index: clang/test/CodeGen/eval-method-fast-math.c
===
--- /dev/null
+++ clang/test/CodeGen/eval-method-fast-math.c
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - %s  \
+// RUN: | FileCheck %s -check-prefixes=CHECK
+
+// RUN: %clang_cc1 -triple i386--linux -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-EXT
+
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -mreassociate -freciprocal-math -ffp-contract=fast \
+// RUN: -ffast-math -triple x86_64-linux-gnu \
+// RUN: -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+// RUN: %clang_cc1 -triple i386--linux -mreassociate -freciprocal-math \
+// RUN: -ffp-contract=fast -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+float res;
+int add(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: load float, float*
+  // CHECK-FAST: fadd fast float
+  // CHECK: ret i32 0
+  // CHECK-EXT: ret i32 2
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+int add_precise(float a, float b, float c) {
+#pragma float_control(precise, on)
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+#pragma float_control(precise, on)
+int add_precise_1(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int add_not_precise(float a, float b, float c) {
+  // Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: load float, float*
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+// Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+int add_not_precise_1(float a, float b, float c) {
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: load float, float*
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int getFPEvalMethod() {
+  // CHECK: ret i32 0
+  return __FLT_EVAL_METHOD__;
+}
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -517,6 +517,9 @@
 else
   NewFPFeatures.setFPPreciseEnabled(false);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+// `AllowFPReassoc` or `AllowReciprocal` option is enabled.
+PP.setCurrentFPEvalMethod(
+Loc, LangOptions::FPEvalMethodKind::FEM_Indeterminable);
 break;
   case PFC_Except:
 if (!isPreciseFPEnabled())
@@ -540,6 +543,12 @@
 }
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
 NewFPFeatures = FpPragmaStack.CurrentValue;
+if (CurFPFeatures.getAllowFPReassociate() ||
+CurFPFeatures.getAllowReciprocal())
+  // Since we are popping the pragma, we don't want to be passing
+  // a location here.
+  PP.setCurrentFPEvalMethod(SourceLocation(),
+CurFPFeatures.getFPEvalMethod());
 break;
   }
   CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -254,6 +254,12 @@
 PP.setCurrentFPEvalMethod(SourceLocation(),
   getLangOpts().getFPEvalMethod());
   CurFPFeatures.setFPEvalMethod(PP.getCurrentFPEvalMethod());
+  // When `-ffast-math` option is enabled, it triggers several driver math
+  // options to be enabled. Among these, only one the following two modes
+  // affect the eval-method:  reciprocal or reassociate.
+  if (getLangOpts().AllowFPReassoc || getLangOpts().AllowRecip)
+PP.setCurrentFPEvalMethod(SourceLocation(),
+  LangOptions::FEM_Indeterminable);
 }
 
 // Anchor Sema's type info to this TU.
Index: clang/lib/Lex/PPMacroExpansion.cpp

[PATCH] D121269: [clang-format] Fix namespace format when the name is followed by a macro

2022-03-10 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 414442.
zequanwu marked 7 inline comments as done.
zequanwu added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121269

Files:
  clang/lib/Format/NamespaceEndCommentsFixer.cpp
  clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Index: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -189,6 +189,49 @@
 "int i;\n"
 "int j;\n"
 "}"));
+  EXPECT_EQ("#define M(x) x##x\n"
+"namespace A M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace A M(x)",
+fixNamespaceEndComments("#define M(x) x##x\n"
+"namespace A M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}"));
+  EXPECT_EQ(
+  "#define B __attribute__((availability(macos, introduced=10.15)))\n"
+  "namespace A B {\n"
+  "int i;\n"
+  "int j;\n"
+  "}// namespace A B",
+  fixNamespaceEndComments(
+  "#define B __attribute__((availability(macos, introduced=10.15)))\n"
+  "namespace A B {\n"
+  "int i;\n"
+  "int j;\n"
+  "}"));
+  EXPECT_EQ("#define M(x) x##x\n"
+"namespace A::B M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace A::B",
+fixNamespaceEndComments("#define M(x) x##x\n"
+"namespace A::B M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}"));
+  EXPECT_EQ(
+  "namespace A __attribute__((availability(macos, introduced=10.15))) {\n"
+  "int i;\n"
+  "int j;\n"
+  "}// namespace A",
+  fixNamespaceEndComments(
+  "namespace A __attribute__((availability(macos, introduced=10.15))) "
+  "{\n"
+  "int i;\n"
+  "int j;\n"
+  "}"));
   EXPECT_EQ("inline namespace A {\n"
 "int i;\n"
 "int j;\n"
Index: clang/lib/Format/NamespaceEndCommentsFixer.cpp
===
--- clang/lib/Format/NamespaceEndCommentsFixer.cpp
+++ clang/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "NamespaceEndCommentsFixer.h"
+#include "clang/Basic/TokenKinds.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Regex.h"
 
@@ -22,6 +23,40 @@
 namespace format {
 
 namespace {
+// Iterates all tokens starting from StartTok to EndTok and apply Fn to all
+// tokens between them including StartTok and EndTok. Returns the token after
+// EndTok.
+const FormatToken *
+processTokens(const FormatToken *Tok, tok::TokenKind StartTok,
+  tok::TokenKind EndTok,
+  llvm::function_ref Fn) {
+  if (!Tok || Tok->isNot(StartTok))
+return Tok;
+  int NestLevel = 0;
+  do {
+if (Tok->is(StartTok))
+  ++NestLevel;
+else if (Tok->is(EndTok))
+  --NestLevel;
+if (Fn)
+  Fn(Tok);
+Tok = Tok->getNextNonComment();
+  } while (Tok && NestLevel > 0);
+  return Tok;
+}
+
+const FormatToken *skipAttribute(const FormatToken *Tok) {
+  if (!Tok)
+return nullptr;
+  if (Tok->is(tok::kw___attribute)) {
+Tok = Tok->getNextNonComment();
+Tok = processTokens(Tok, tok::l_paren, tok::r_paren, nullptr);
+  } else if (Tok->is(tok::l_square)) {
+Tok = processTokens(Tok, tok::l_square, tok::r_square, nullptr);
+  }
+  return Tok;
+}
+
 // Computes the name of a namespace given the namespace token.
 // Returns "" for anonymous namespace.
 std::string computeName(const FormatToken *NamespaceTok) {
@@ -39,48 +74,69 @@
   name += Tok->TokenText;
   Tok = Tok->getNextNonComment();
 }
-  } else {
-// Skip attributes.
-if (Tok && Tok->is(tok::l_square)) {
-  for (int NestLevel = 1; NestLevel > 0;) {
-Tok = Tok->getNextNonComment();
-if (!Tok)
-  break;
-if (Tok->is(tok::l_square))
-  ++NestLevel;
-else if (Tok->is(tok::r_square))
-  --NestLevel;
-  }
-  if (Tok)
-Tok = Tok->getNextNonComment();
-}
+return name;
+  }
+  Tok = skipAttribute(Tok);
 
-// Use the string after `namespace` as a name candidate until `{` or `::` or
-// `(`. If the name is empty, use the candicate.
-std::string FirstNSName;
-// For `namespace [[foo]] A::B::inline C {` or
-// `namespace MACRO1 MACRO2 A::B::inline C {`, returns "A::B::inline C".
-// Peek for the first '::' (or '{' or 

[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:258
+  // Fast-math is enabled.
+  if (getLangOpts().AllowFPReassoc || getLangOpts().AllowRecip)
+PP.setCurrentFPEvalMethod(SourceLocation(),

zahiraam wrote:
> aaron.ballman wrote:
> > Shouldn't this be looking at `getLangOpts().FastMath`?
> when the -ffast-math is enabled on the command line, it triggers all these 
> math driver options:
> 
> "-menable-no-infs" "-menable-no-nans" "-fapprox-func" 
> "-menable-unsafe-fp-math" "-fno-signed-zeros" "-mreassociate" 
> "-freciprocal-math" "-ffp-contract=fast"  "-ffast-math" "-ffinite-math-only"
> 
> That's a bit restrictive. We want the eval-method set to -1 when either 
> reassoc or allowrecip are enabled.
> 
> 
Okay, then I think the comments about fast math should be fixed up; otherwise 
that's going to get confusing.


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

https://reviews.llvm.org/D121122

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


[PATCH] D121100: [clang][DebugInfo] clang should not generate DW_TAG_subprogram entry without DW_AT_name

2022-03-10 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Ideally, this would be fixed in GDB. If that's really not feasibly I would 
rather like to see this as a gdb debugger tuning instead f the default behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121100

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


[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:258
+  // Fast-math is enabled.
+  if (getLangOpts().AllowFPReassoc || getLangOpts().AllowRecip)
+PP.setCurrentFPEvalMethod(SourceLocation(),

aaron.ballman wrote:
> Shouldn't this be looking at `getLangOpts().FastMath`?
when the -ffast-math is enabled on the command line, it triggers all these math 
driver options:

"-menable-no-infs" "-menable-no-nans" "-fapprox-func" "-menable-unsafe-fp-math" 
"-fno-signed-zeros" "-mreassociate" "-freciprocal-math" "-ffp-contract=fast"  
"-ffast-math" "-ffinite-math-only"

That's a bit restrictive. We want the eval-method set to -1 when either reassoc 
or allowrecip are enabled.




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

https://reviews.llvm.org/D121122

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

2022-03-10 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny added a comment.

In D121078#3373139 , @philnik wrote:

> In D121078#3373081 , @SimplyDanny 
> wrote:
>
>> I'm happy that you found a reasonable compromise. I like it too. ;)
>>
>> Now, I ask you to help me a little bit with the workflow and the test 
>> failures. The review comments are all taken care of as far as I see. One 
>> reviewer approved the changes, others are still in a "needs changes"  or an 
>> undecided state. Are approvals of all reviewers required? I guess, the test 
>> failures have nothing to do with my changes, or have they? Can we just 
>> ignore them if they are unrelated?
>
> Please wait for libunwind and libc++ approval. I won't approve, because I'm 
> not familiar with the documentation stuff.
> If the test failures are unrelated you can ignore them.

Okay, I'll wait a few more days and probably ping people again if there is no 
response until then,

In D121078#3373128 , @aaron.ballman 
wrote:

> Btw, do you have commit rights for the project? If not, what name and email 
> address would you like used for patch attribution?

I don't have commit rights. Please use "Danny Mösch" with the email address 
"danny.moe...@icloud.com". Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

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


[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:258
+  // Fast-math is enabled.
+  if (getLangOpts().AllowFPReassoc || getLangOpts().AllowRecip)
+PP.setCurrentFPEvalMethod(SourceLocation(),

Shouldn't this be looking at `getLangOpts().FastMath`?


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

https://reviews.llvm.org/D121122

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


[PATCH] D118511: Add a warning for not packing non-POD members in packed structs

2022-03-10 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D118511#3373173 , @tstellar wrote:

> In D118511#3373082 , @dblaikie 
> wrote:
>
>> In D118511#3372728 , @jyknight 
>> wrote:
>>
>>> In D118511#3371432 , @tstellar 
>>> wrote:
>>>
 I'm fine with reverting if you think this is the best solution.  I just 
 would like to conclude soon so I can make the final release candidate.
>>>
>>> ISTM that reverting the ABI change in the 14.x branch makes sense, to avoid 
>>> ping-ponging the ABI for packed structs which would become non-packed 
>>> (breaking ABI) in 14.x and packed again (breaking ABI) in 
>>> https://reviews.llvm.org/D119051.
>>
>> Yeah - I think it'd be a pretty niche amount of code that'd churn like that, 
>> but doesn't seem super important to rush this either.
>>
>> @tstellar - can/do you want to revert this on the release branch yourself? 
>> Is that something I should do? Should I revert this on trunk (would be a bit 
>> awkward/more churny for users - maybe not a full revert, but one that leaves 
>> the new ABI version flag available as a no-op so users opting out don't need 
>> to remove the flag only to add it back in later) so it can be integrated to 
>> the release?
>
> I can revert in the release branch.  Is this the commit: 
> https://reviews.llvm.org/rG277123376ce08c98b07c154bf83e4092a5d4d3c6?

Yep, that's the one!

> It doesn't seem necessary to me to revert in the main branch, but I think 
> that can be your call.

Yeah, I'm leaning towards not reverting on main & hoping we can sort out the 
POD ABI issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118511

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


[PATCH] D120949: [clang][AST matchers] adding attributedStmt AST matcher

2022-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2713-2714
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher
+attributedStmt;
+

sammccall wrote:
> aaron.ballman wrote:
> > sammccall wrote:
> > > jdoerfert wrote:
> > > > aaron.ballman wrote:
> > > > > Design-wise, I'm on the fence here. AST matchers match the AST nodes 
> > > > > that Clang produces, and from that perspective, this makes a lot of 
> > > > > sense. But `AttributedStmt` is a bit of a hack in some ways, and do 
> > > > > we want to expose that hack to AST matcher users? e.g., is there a 
> > > > > reason we shouldn't make `returnStmt(hasAttr(attr::Likely))` work 
> > > > > directly rather than making the user pick their way through the 
> > > > > `AttributedStmt`? This is more in line with how you check for a 
> > > > > declaration with a particular attribute and seems like the more 
> > > > > natural way to surface this.
> > > > > 
> > > > > For the moment, since this is following the current AST structure in 
> > > > > Clang, I think this is fine. But I'm curious if @klimek or perhaps 
> > > > > @sammccall has an opinion here.
> > > > I think a way to find any kind of statement (or expression) that has a 
> > > > specific attribute is very useful. How that should look, idk.
> > > TL;DR: I think this matcher fits the current design best. 
> > > `returnStmt(hasAttr())` sounds awesome, but I think it's a significant 
> > > new concept, and a cross-cutting project like traversal modes.
> > > 
> > > ---
> > > 
> > > returnStmt(hasAttr()) is definitely nicer in isolation (and in 
> > > combination with how decls work).
> > > It's definitely potentially confusing to not match the AST. The AST is 
> > > unlikely to be fixed because (IIUC) we don't want to burden each stmt 
> > > with tracking if it has attrs.
> > > So I think the easy answer is this patch gets it right.
> > > 
> > > The inconsistency with decls is annoying, and maybe worse it doesn't 
> > > yield a simple way to express "a return statement, maybe with an 
> > > attribute, I don't care" unless you're searching recursively anyway, and 
> > > this should almost be the default.
> > > `returnStmt(hasAttr())` suggests that it would enable this, maybe by 
> > > skipping over the AttributedStmt with some fancy traversal mode, and then 
> > > looking it up again in the hasAttr matcher from the parent map.
> > > 
> > > I think this would be a less brittle way to handle mostly-transparent 
> > > nodes that you nevertheless want to be able to match the contents of 
> > > sometimes. The current options (explicitly unwrap, rely on recursive 
> > > search, and traversal modes) all seem to have significant limitations.
> > > However this is a pretty general idea (and I guess a pretty large 
> > > project), and I don't think it's worth introducing just for 
> > > AttributedStmt.
> > Thanks for the feedback Sam!
> > 
> > > The AST is unlikely to be fixed because (IIUC) we don't want to burden 
> > > each stmt with tracking if it has attrs.
> > 
> > I'm less convinced of this. We didn't want to do it originally because 
> > there were so very few statement attributes. These days, there's quite a 
> > few more more statement attributes, so we may very well revisit this. 
> > `AttributedStmt` is a pain that has caused us problems in the past with 
> > things like `isa()` failing because it didn't expect an attributed 
> > `FooStmt`.
> > 
> > That said, the rest of your points are compelling, so this matcher is fine 
> > for me.
> > We didn't want to do it originally because there were so very few statement 
> > attributes.
> 
> Ah, i assumed it was some kind of issue with size or the logistics of 
> allocation. Fixing the AST sounds good then! (But I wouldn't block this patch 
> on it unless someone's ready to work on it).
Yeah, I'm not ready to work on it and I don't know of anyone else planning to 
do that work any time soon (it's more of an idle "someday" task than anything 
we need to do immediately). So definitely agreed, let's not block this patch on 
it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120949

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


[PATCH] D120949: [clang][AST matchers] adding attributedStmt AST matcher

2022-03-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2713-2714
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher
+attributedStmt;
+

aaron.ballman wrote:
> sammccall wrote:
> > jdoerfert wrote:
> > > aaron.ballman wrote:
> > > > Design-wise, I'm on the fence here. AST matchers match the AST nodes 
> > > > that Clang produces, and from that perspective, this makes a lot of 
> > > > sense. But `AttributedStmt` is a bit of a hack in some ways, and do we 
> > > > want to expose that hack to AST matcher users? e.g., is there a reason 
> > > > we shouldn't make `returnStmt(hasAttr(attr::Likely))` work directly 
> > > > rather than making the user pick their way through the 
> > > > `AttributedStmt`? This is more in line with how you check for a 
> > > > declaration with a particular attribute and seems like the more natural 
> > > > way to surface this.
> > > > 
> > > > For the moment, since this is following the current AST structure in 
> > > > Clang, I think this is fine. But I'm curious if @klimek or perhaps 
> > > > @sammccall has an opinion here.
> > > I think a way to find any kind of statement (or expression) that has a 
> > > specific attribute is very useful. How that should look, idk.
> > TL;DR: I think this matcher fits the current design best. 
> > `returnStmt(hasAttr())` sounds awesome, but I think it's a significant new 
> > concept, and a cross-cutting project like traversal modes.
> > 
> > ---
> > 
> > returnStmt(hasAttr()) is definitely nicer in isolation (and in combination 
> > with how decls work).
> > It's definitely potentially confusing to not match the AST. The AST is 
> > unlikely to be fixed because (IIUC) we don't want to burden each stmt with 
> > tracking if it has attrs.
> > So I think the easy answer is this patch gets it right.
> > 
> > The inconsistency with decls is annoying, and maybe worse it doesn't yield 
> > a simple way to express "a return statement, maybe with an attribute, I 
> > don't care" unless you're searching recursively anyway, and this should 
> > almost be the default.
> > `returnStmt(hasAttr())` suggests that it would enable this, maybe by 
> > skipping over the AttributedStmt with some fancy traversal mode, and then 
> > looking it up again in the hasAttr matcher from the parent map.
> > 
> > I think this would be a less brittle way to handle mostly-transparent nodes 
> > that you nevertheless want to be able to match the contents of sometimes. 
> > The current options (explicitly unwrap, rely on recursive search, and 
> > traversal modes) all seem to have significant limitations.
> > However this is a pretty general idea (and I guess a pretty large project), 
> > and I don't think it's worth introducing just for AttributedStmt.
> Thanks for the feedback Sam!
> 
> > The AST is unlikely to be fixed because (IIUC) we don't want to burden each 
> > stmt with tracking if it has attrs.
> 
> I'm less convinced of this. We didn't want to do it originally because there 
> were so very few statement attributes. These days, there's quite a few more 
> more statement attributes, so we may very well revisit this. `AttributedStmt` 
> is a pain that has caused us problems in the past with things like 
> `isa()` failing because it didn't expect an attributed `FooStmt`.
> 
> That said, the rest of your points are compelling, so this matcher is fine 
> for me.
> We didn't want to do it originally because there were so very few statement 
> attributes.

Ah, i assumed it was some kind of issue with size or the logistics of 
allocation. Fixing the AST sounds good then! (But I wouldn't block this patch 
on it unless someone's ready to work on it).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120949

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


[PATCH] D118511: Add a warning for not packing non-POD members in packed structs

2022-03-10 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In D118511#3373082 , @dblaikie wrote:

> In D118511#3372728 , @jyknight 
> wrote:
>
>> In D118511#3371432 , @tstellar 
>> wrote:
>>
>>> I'm fine with reverting if you think this is the best solution.  I just 
>>> would like to conclude soon so I can make the final release candidate.
>>
>> ISTM that reverting the ABI change in the 14.x branch makes sense, to avoid 
>> ping-ponging the ABI for packed structs which would become non-packed 
>> (breaking ABI) in 14.x and packed again (breaking ABI) in 
>> https://reviews.llvm.org/D119051.
>
> Yeah - I think it'd be a pretty niche amount of code that'd churn like that, 
> but doesn't seem super important to rush this either.
>
> @tstellar - can/do you want to revert this on the release branch yourself? Is 
> that something I should do? Should I revert this on trunk (would be a bit 
> awkward/more churny for users - maybe not a full revert, but one that leaves 
> the new ABI version flag available as a no-op so users opting out don't need 
> to remove the flag only to add it back in later) so it can be integrated to 
> the release?

I can revert in the release branch.  Is this the commit: 
https://reviews.llvm.org/rG277123376ce08c98b07c154bf83e4092a5d4d3c6?

It doesn't seem necessary to me to revert in the main branch, but I think that 
can be your call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118511

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


[PATCH] D121380: Pragma `clang fp eval_method` needs to take as input a supported value.

2022-03-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 414424.

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

https://reviews.llvm.org/D121380

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/test/Sema/fp-eval-pragma.cpp


Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+  // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp 
eval_method'; expected 'source' or 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 
'assume_safety'}1 or 'disable'">;


Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+  // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp eval_method'; expected 'source' or 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 'assume_safety'}1 or 'disable'">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120949: [clang][AST matchers] adding attributedStmt AST matcher

2022-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2733
+/// \endcode
+AST_MATCHER_P(AttributedStmt, isAttr, attr::Kind, AttrKind) {
+  return llvm::any_of(Node.getAttrs(),

sammccall wrote:
> This definitely seems more like `hasAttr` than `isAttr` to me. An 
> AttributedStmt *is* the (sugar) statement, and *has* the attribute(s).
> 
> Maybe rather `describesAttr` so people don't confuse this for one that walks 
> up, though?
Good point on the `isAttr` name!

I'm not sure `describeAttr` works (the statement doesn't describe attributes, 
it... has/contains/uses the attribute). Maybe.. `specifiesAttr()`?

Or are we making this harder than it needs to be and we should use `hasAttr()` 
for parity with other things that have attributes associated with them?



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2713-2714
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher
+attributedStmt;
+

sammccall wrote:
> jdoerfert wrote:
> > aaron.ballman wrote:
> > > Design-wise, I'm on the fence here. AST matchers match the AST nodes that 
> > > Clang produces, and from that perspective, this makes a lot of sense. But 
> > > `AttributedStmt` is a bit of a hack in some ways, and do we want to 
> > > expose that hack to AST matcher users? e.g., is there a reason we 
> > > shouldn't make `returnStmt(hasAttr(attr::Likely))` work directly rather 
> > > than making the user pick their way through the `AttributedStmt`? This is 
> > > more in line with how you check for a declaration with a particular 
> > > attribute and seems like the more natural way to surface this.
> > > 
> > > For the moment, since this is following the current AST structure in 
> > > Clang, I think this is fine. But I'm curious if @klimek or perhaps 
> > > @sammccall has an opinion here.
> > I think a way to find any kind of statement (or expression) that has a 
> > specific attribute is very useful. How that should look, idk.
> TL;DR: I think this matcher fits the current design best. 
> `returnStmt(hasAttr())` sounds awesome, but I think it's a significant new 
> concept, and a cross-cutting project like traversal modes.
> 
> ---
> 
> returnStmt(hasAttr()) is definitely nicer in isolation (and in combination 
> with how decls work).
> It's definitely potentially confusing to not match the AST. The AST is 
> unlikely to be fixed because (IIUC) we don't want to burden each stmt with 
> tracking if it has attrs.
> So I think the easy answer is this patch gets it right.
> 
> The inconsistency with decls is annoying, and maybe worse it doesn't yield a 
> simple way to express "a return statement, maybe with an attribute, I don't 
> care" unless you're searching recursively anyway, and this should almost be 
> the default.
> `returnStmt(hasAttr())` suggests that it would enable this, maybe by skipping 
> over the AttributedStmt with some fancy traversal mode, and then looking it 
> up again in the hasAttr matcher from the parent map.
> 
> I think this would be a less brittle way to handle mostly-transparent nodes 
> that you nevertheless want to be able to match the contents of sometimes. The 
> current options (explicitly unwrap, rely on recursive search, and traversal 
> modes) all seem to have significant limitations.
> However this is a pretty general idea (and I guess a pretty large project), 
> and I don't think it's worth introducing just for AttributedStmt.
Thanks for the feedback Sam!

> The AST is unlikely to be fixed because (IIUC) we don't want to burden each 
> stmt with tracking if it has attrs.

I'm less convinced of this. We didn't want to do it originally because there 
were so very few statement attributes. These days, there's quite a few more 
more statement attributes, so we may very well revisit this. `AttributedStmt` 
is a pain that has caused us problems in the past with things like 
`isa()` failing because it didn't expect an attributed `FooStmt`.

That said, the rest of your points are compelling, so this matcher is fine for 
me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120949

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

2022-03-10 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added a comment.

In D121078#3373081 , @SimplyDanny 
wrote:

> I'm happy that you found a reasonable compromise. I like it too. ;)
>
> Now, I ask you to help me a little bit with the workflow and the test 
> failures. The review comments are all taken care of as far as I see. One 
> reviewer approved the changes, others are still in a "needs changes"  or an 
> undecided state. Are approvals of all reviewers required? I guess, the test 
> failures have nothing to do with my changes, or have they? Can we just ignore 
> them if they are unrelated?

Please wait for libunwind and libc++ approval. I won't approve, because I'm not 
familiar with the documentation stuff.
If the test failures are unrelated you can ignore them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

2022-03-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D121078#3373081 , @SimplyDanny 
wrote:

> I'm happy that you found a reasonable compromise. I like it too. ;)
>
> Now, I ask you to help me a little bit with the workflow and the test 
> failures. The review comments are all taken care of as far as I see. One 
> reviewer approved the changes, others are still in a "needs changes"  or an 
> undecided state. Are approvals of all reviewers required?

You don't need all reviewers to approve a patch before landing it, but you do 
need to determine if there's consensus amongst the active reviewers that it's 
okay to land.

I think all the review comments have been addressed here, as far as I can tell, 
but it's usually good to double-check just to be sure when someone has 
explicitly marked the review as requesting changes. I usually do that by 
pinging the people who marked as requesting changes (or anyone else who I'm 
uncertain about) and giving them a day or two to respond. If there are no 
responses after a few days, land the changes. If it turns out there are still 
comments they'd like to see addressed after the patch landed, they can 
generally be handled post commit (or if they're a major concern, we can always 
revert the changes while debating what to do). A patch is not blocked by people 
who are in an undecided state and haven't been active in the review at all.

@ldionne @tonic -- do things look reasonable to you now?

(btw, we have some documentation on that, in case you're not seen it: 
https://llvm.org/docs/CodeReview.html#code-review-workflow)

> I guess, the test failures have nothing to do with my changes, or have they? 
> Can we just ignore them if they are unrelated?

I looked at the test failures and they look unrelated, so it's fine to ignore 
them.

Btw, do you have commit rights for the project? If not, what name and email 
address would you like used for patch attribution?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

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


[PATCH] D121380: Pragma `clang fp eval_method` needs to take as input a supported value.

2022-03-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 414416.

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

https://reviews.llvm.org/D121380

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/test/Sema/fp-eval-pragma.cpp


Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+ // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp 
eval_method'; expected 'source' or 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 
'assume_safety'}1 or 'disable'">;


Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+ // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp eval_method'; expected 'source' or 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 'assume_safety'}1 or 'disable'">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118511: Add a warning for not packing non-POD members in packed structs

2022-03-10 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D118511#3372728 , @jyknight wrote:

> In D118511#3371432 , @tstellar 
> wrote:
>
>> I'm fine with reverting if you think this is the best solution.  I just 
>> would like to conclude soon so I can make the final release candidate.
>
> ISTM that reverting the ABI change in the 14.x branch makes sense, to avoid 
> ping-ponging the ABI for packed structs which would become non-packed 
> (breaking ABI) in 14.x and packed again (breaking ABI) in 
> https://reviews.llvm.org/D119051.

Yeah - I think it'd be a pretty niche amount of code that'd churn like that, 
but doesn't seem super important to rush this either.

@tstellar - can/do you want to revert this on the release branch yourself? Is 
that something I should do? Should I revert this on trunk (would be a bit 
awkward/more churny for users - maybe not a full revert, but one that leaves 
the new ABI version flag available as a no-op so users opting out don't need to 
remove the flag only to add it back in later) so it can be integrated to the 
release?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118511

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

2022-03-10 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny added a comment.

I'm happy that you found a reasonable compromise. I like it too. ;)

Now, I ask you to help me a little bit with the workflow and the test failures. 
The review comments are all taken care of as far as I see. One reviewer 
approved the changes, others are still in a "needs changes"  or an undecided 
state. Are approvals of all reviewers required? I guess, the test failures have 
nothing to do with my changes, or have they? Can we just ignore them if they 
are unrelated?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

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


[PATCH] D121380: Pragma `clang fp eval_method` needs to take as input a supported value.

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

LGTM with a tiny tweak to the diagnostic.




Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1493
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source' or 'double' or 'extended'}2">;
 

Slight tweak here to use a list instead of multiple `or`s.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121380

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


[PATCH] D121100: [clang][DebugInfo] clang should not generate DW_TAG_subprogram entry without DW_AT_name

2022-03-10 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Yeah, happy to hear other perspectives - but my rough reaction is similar: 
putting mangled names in the "name" field seems problematic (consumer wouldn't 
necessarily know that the name should be demangled, for instance? Maybe?). So 
at the IR level maybe it's better to leave those in the linkage name - and 
maybe we workaround it in the backend when tuning for gdb - putting it in the 
DW_AT_name field because it's not ideal but the best we can do for GDB? (anyone 
filed a bug with GDB and/or DWARF for this? (I'd start with GDB and see if 
they're open to the idea directly - don't use the DWARF committee as an 
indirect way to request feature work for GDB unless they'd prefer it to be 
formalized before implementing it))

The various _ and __ names are probably OK as names, but the tests that end up 
producing mangled names into linkage names seem like not the right direction - 
maybe those entities need/are missing real names anyway? Might be worth 
comparing/contrasting with GCC's behavior for similar entities (at a glance at 
the tests, looks like some thunks are in this situation?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121100

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


[PATCH] D120610: [DebugInfo] Include DW_TAG_skeleton_unit when looking for parent UnitDie

2022-03-10 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Fixes in LLVM require tests in LLVM - probably taking the clang test and 
compiling that to llvm IR (include the original C++ source in a comment in the 
IR test case) and then testing it in LLVM instead of clang.

Also looks like the test could be simplified a bit more:

  void f1();
  
  template 
  void f2() {
f1();
  }
  
  void f3() {
f2();
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120610

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


[PATCH] D121387: [analyzer] ClangSA should tablegen doc urls refering to the main doc page

2022-03-10 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: aaron.ballman, NoQ, Szelethus, whisperity, martong.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

AFAIK we should prefer
https://clang.llvm.org/docs/analyzer/checkers.html to 
https://clang-analyzer.llvm.org/{available_checks,alpha_checks}.html

This patch will ensure that the doc urls produced by tablegen for the
ClangSA, will use the new url. Nothing else will be changed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121387

Files:
  
clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
  clang/utils/TableGen/ClangSACheckersEmitter.cpp

Index: clang/utils/TableGen/ClangSACheckersEmitter.cpp
===
--- clang/utils/TableGen/ClangSACheckersEmitter.cpp
+++ clang/utils/TableGen/ClangSACheckersEmitter.cpp
@@ -24,37 +24,39 @@
 // Static Analyzer Checkers Tables generation
 //===--===//
 
-static std::string getPackageFullName(const Record *R);
+static std::string getPackageFullName(const Record *R, StringRef Sep = ".");
 
-static std::string getParentPackageFullName(const Record *R) {
-  std::string name;
+static std::string getParentPackageFullName(const Record *R,
+StringRef Sep = ".") {
   if (DefInit *DI = dyn_cast(R->getValueInit("ParentPackage")))
-name = getPackageFullName(DI->getDef());
-  return name;
+return getPackageFullName(DI->getDef());
+  return "";
 }
 
-static std::string getPackageFullName(const Record *R) {
-  std::string name = getParentPackageFullName(R);
-  if (!name.empty())
-name += ".";
-  assert(!R->getValueAsString("PackageName").empty());
-  name += R->getValueAsString("PackageName");
-  return name;
+static std::string getPackageFullName(const Record *R, StringRef Sep) {
+  std::string ParentPkgName = getParentPackageFullName(R, Sep);
+  StringRef PackageName = R->getValueAsString("PackageName");
+  assert(!PackageName.empty());
+
+  if (ParentPkgName.empty())
+return PackageName.str();
+  return (Twine{ParentPkgName} + Sep + PackageName).str();
 }
 
-static std::string getCheckerFullName(const Record *R) {
-  std::string name = getParentPackageFullName(R);
-  if (!name.empty())
-name += ".";
-  assert(!R->getValueAsString("CheckerName").empty());
-  name += R->getValueAsString("CheckerName");
-  return name;
+static std::string getCheckerFullName(const Record *R, StringRef Sep = ".") {
+  std::string ParentPkgName = getParentPackageFullName(R, Sep);
+  StringRef CheckerName = R->getValueAsString("CheckerName");
+  assert(!CheckerName.empty());
+
+  if (ParentPkgName.empty())
+return CheckerName.str();
+  return (Twine{ParentPkgName} + Sep + CheckerName).str();
 }
 
 static std::string getStringValue(const Record , StringRef field) {
   if (StringInit *SI = dyn_cast(R.getValueInit(field)))
 return std::string(SI->getValue());
-  return std::string();
+  return "";
 }
 
 // Calculates the integer value representing the BitsInit object
@@ -74,20 +76,19 @@
 }
 
 static std::string getCheckerDocs(const Record ) {
-  StringRef LandingPage;
-  if (BitsInit *BI = R.getValueAsBitsInit("Documentation")) {
-uint64_t V = getValueFromBitsInit(BI, R);
-if (V == 1)
-  LandingPage = "available_checks.html";
-else if (V == 2)
-  LandingPage = "alpha_checks.html";
-  }
-  
-  if (LandingPage.empty())
+  const BitsInit *BI = R.getValueAsBitsInit("Documentation");
+  if (!BI)
+PrintFatalError(R.getLoc(),
+"missing Documentation for " + getCheckerFullName());
+
+  // Ignore 'Documentation' checkers.
+  if (getValueFromBitsInit(BI, R) == 0)
 return "";
 
-  return (llvm::Twine("https://clang-analyzer.llvm.org/;) + LandingPage + "#" +
-  getCheckerFullName())
+  std::string CheckerFullName = StringRef(getCheckerFullName(, "-")).lower();
+
+  return (llvm::Twine("https://clang.llvm.org/docs/analyzer/checkers.html#;) +
+  CheckerFullName)
   .str();
 }
 
Index: clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
===
--- clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
+++ clang/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
@@ -451,7 +451,7 @@
   "fullDescription": {
 "text": "Check for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers)"
   },
-  "helpUri": 

[PATCH] D121378: [clang][dataflow] Model the behavior of various optional members

2022-03-10 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev marked an inline comment as done.
sgatev added inline comments.



Comment at: 
clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp:33
 static constexpr char StdTypeTraitsHeader[] = R"(
+#ifndef TYPE_TRAITS_H
+#define TYPE_TRAITS_H

xazax.hun wrote:
> I wonder if it is more sustainable in the long term to have these headers in 
> a separate file and `#include` them here (and build the raw string literal 
> with a macro if that is possible at all).
Yeap, I agree that would be better. I'll consider some options and send a patch 
to move them out of here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121378

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


[PATCH] D121378: [clang][dataflow] Model the behavior of various optional members

2022-03-10 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 414396.
sgatev marked an inline comment as done.
sgatev added a comment.

Address reviewers' comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121378

Files:
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -29,9 +29,23 @@
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
 
+// FIXME: Move header definitions in separate file(s).
 static constexpr char StdTypeTraitsHeader[] = R"(
+#ifndef TYPE_TRAITS_H
+#define TYPE_TRAITS_H
+
 namespace std {
 
+typedef decltype(sizeof(char)) size_t;
+
+template 
+struct integral_constant {
+  static constexpr T value = V;
+};
+
+using true_type = integral_constant;
+using false_type = integral_constant;
+
 template< class T > struct remove_reference  {typedef T type;};
 template< class T > struct remove_reference  {typedef T type;};
 template< class T > struct remove_reference {typedef T type;};
@@ -39,21 +53,135 @@
 template 
   using remove_reference_t = typename remove_reference::type;
 
+template 
+struct remove_extent {
+  typedef T type;
+};
+
+template 
+struct remove_extent {
+  typedef T type;
+};
+
+template 
+struct remove_extent {
+  typedef T type;
+};
+
+template 
+struct is_array : false_type {};
+
+template 
+struct is_array : true_type {};
+
+template 
+struct is_array : true_type {};
+
+template 
+struct is_function : false_type {};
+
+template 
+struct is_function : true_type {};
+
+namespace detail {
+
+template 
+struct type_identity {
+  using type = T;
+};  // or use type_identity (since C++20)
+
+template 
+auto try_add_pointer(int) -> type_identity::type*>;
+template 
+auto try_add_pointer(...) -> type_identity;
+
+}  // namespace detail
+
+template 
+struct add_pointer : decltype(detail::try_add_pointer(0)) {};
+
+template 
+struct conditional {
+  typedef T type;
+};
+
+template 
+struct conditional {
+  typedef F type;
+};
+
+template 
+struct remove_cv {
+  typedef T type;
+};
+template 
+struct remove_cv {
+  typedef T type;
+};
+template 
+struct remove_cv {
+  typedef T type;
+};
+template 
+struct remove_cv {
+  typedef T type;
+};
+
+template 
+struct decay {
+ private:
+  typedef typename remove_reference::type U;
+
+ public:
+  typedef typename conditional<
+  is_array::value, typename remove_extent::type*,
+  typename conditional::value, typename add_pointer::type,
+   typename remove_cv::type>::type>::type type;
+};
+
 } // namespace std
+
+#endif // TYPE_TRAITS_H
 )";
 
 static constexpr char StdUtilityHeader[] = R"(
+#ifndef UTILITY_H
+#define UTILITY_H
+
 #include "std_type_traits.h"
 
 namespace std {
 
 template 
-constexpr std::remove_reference_t&& move(T&& x);
+constexpr remove_reference_t&& move(T&& x);
+
+} // namespace std
+
+#endif // UTILITY_H
+)";
+
+static constexpr char StdInitializerListHeader[] = R"(
+#ifndef INITIALIZER_LIST_H
+#define INITIALIZER_LIST_H
+
+namespace std {
+
+template 
+class initializer_list {
+ public:
+  initializer_list() noexcept;
+};
 
 } // namespace std
+
+#endif // INITIALIZER_LIST_H
 )";
 
 static constexpr char StdOptionalHeader[] = R"(
+#include "std_initializer_list.h"
+#include "std_type_traits.h"
+#include "std_utility.h"
+
 namespace std {
 
 template 
@@ -74,13 +202,41 @@
   const T&& value() const&&;
   T&& value() &&;
 
+  template 
+  constexpr T value_or(U&& v) const&;
+  template 
+  T value_or(U&& v) &&;
+
+  template 
+  T& emplace(Args&&... args);
+
+  template 
+  T& emplace(std::initializer_list ilist, Args&&... args);
+
+  void reset() noexcept;
+
+  constexpr explicit operator bool() const noexcept;
   constexpr bool has_value() const noexcept;
 };
 
+template 
+constexpr optional::type> make_optional(T&& v);
+
+template 
+constexpr optional make_optional(Args&&... args);
+
+template 
+constexpr optional make_optional(std::initializer_list il,
+Args&&... args);
+
 } // namespace std
 )";
 
 static constexpr char AbslOptionalHeader[] = R"(
+#include "std_initializer_list.h"
+#include "std_type_traits.h"
+#include "std_utility.h"
+
 namespace absl {
 
 template 
@@ -101,13 +257,41 @@
   const T&& value() const&&;
   T&& value() &&;
 
+  template 
+  constexpr T value_or(U&& v) const&;
+  template 
+  T value_or(U&& v) &&;
+
+  template 
+  T& emplace(Args&&... args);
+
+  template 
+  T& emplace(std::initializer_list ilist, Args&&... args);
+
+  void reset() noexcept;
+
+  constexpr explicit operator bool() const noexcept;
   constexpr bool 

[PATCH] D121378: [clang][dataflow] Model the behavior of various optional members

2022-03-10 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:64
 static BoolValue *getHasValue(Value *Val) {
-  if (auto *OptionalVal = cast_or_null(Val)) {
+  if (auto *OptionalVal = cast_or_null(Val))
 return cast(OptionalVal->getProperty("has_value"));

Nit: unintended change?



Comment at: 
clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp:33
 static constexpr char StdTypeTraitsHeader[] = R"(
+#ifndef TYPE_TRAITS_H
+#define TYPE_TRAITS_H

I wonder if it is more sustainable in the long term to have these headers in a 
separate file and `#include` them here (and build the raw string literal with a 
macro if that is possible at all).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121378

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


[PATCH] D121380: Pragma `clang fp eval_method` needs to take as input a supported value.

2022-03-10 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam created this revision.
zahiraam added reviewers: aaron.ballman, andrew.w.kaylor.
Herald added a project: All.
zahiraam requested review of this revision.
Herald added a project: clang.

Diagnose when `#pragma clang fp eval_method` doesn't have a supported value. 
Currently the compiler is crashing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121380

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/test/Sema/fp-eval-pragma.cpp


Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+ // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp 
eval_method'; expected 'source' or 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source' or 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 
'assume_safety'}1 or 'disable'">;


Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- clang/test/Sema/fp-eval-pragma.cpp
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+ // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp eval_method'; expected 'source' or 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source' or 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 'assume_safety'}1 or 'disable'">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120989: Support debug info for alias variable

2022-03-10 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

This looks mostly fine to me, I have a couple of superficial comments inline.




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3914
 
+  // imported declaration
+  auto IE = ImportedDeclCache.find(D->getCanonicalDecl());

Nit: The LLVM coding style wants all comments to be full sentences, including a 
trailing `.`



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3921
+  return cast(GVE);
+return dyn_cast_or_null(N);
+  }

When would we enter a nullptr into the cache?



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:5496
+  if (!AliaseeDecl)
+/* FIXME: Aliasee not declared yet - possibly declared later
+ * For example,

See LLVM coding style



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1502
+const GlobalDecl CodeGenModule::getMangledNameDecl(StringRef Name) {
+  auto it = MangledDeclNames.begin();
+  while (it != MangledDeclNames.end()) {

std::find()?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120989

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


[PATCH] D118511: Add a warning for not packing non-POD members in packed structs

2022-03-10 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In D118511#3371432 , @tstellar wrote:

> I'm fine with reverting if you think this is the best solution.  I just would 
> like to conclude soon so I can make the final release candidate.

ISTM that reverting the ABI change in the 14.x branch makes sense, to avoid 
ping-ponging the ABI for packed structs which would become non-packed (breaking 
ABI) in 14.x and packed again (breaking ABI) in 
https://reviews.llvm.org/D119051.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118511

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


[PATCH] D121378: [clang][dataflow] Model the behavior of various optional members

2022-03-10 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev created this revision.
sgatev added reviewers: ymandel, xazax.hun, gribozavr2.
Herald added subscribers: tschuett, steakhal, rnkovacs.
Herald added a project: All.
sgatev requested review of this revision.
Herald added a project: clang.

Model `make_optional`, optional's default constructor, `emplace`,
`reset`, and `operator bool` members.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121378

Files:
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -30,8 +30,21 @@
 using ::testing::UnorderedElementsAre;
 
 static constexpr char StdTypeTraitsHeader[] = R"(
+#ifndef TYPE_TRAITS_H
+#define TYPE_TRAITS_H
+
 namespace std {
 
+typedef decltype(sizeof(char)) size_t;
+
+template 
+struct integral_constant {
+  static constexpr T value = V;
+};
+
+using true_type = integral_constant;
+using false_type = integral_constant;
+
 template< class T > struct remove_reference  {typedef T type;};
 template< class T > struct remove_reference  {typedef T type;};
 template< class T > struct remove_reference {typedef T type;};
@@ -39,21 +52,135 @@
 template 
   using remove_reference_t = typename remove_reference::type;
 
+template 
+struct remove_extent {
+  typedef T type;
+};
+
+template 
+struct remove_extent {
+  typedef T type;
+};
+
+template 
+struct remove_extent {
+  typedef T type;
+};
+
+template 
+struct is_array : false_type {};
+
+template 
+struct is_array : true_type {};
+
+template 
+struct is_array : true_type {};
+
+template 
+struct is_function : false_type {};
+
+template 
+struct is_function : true_type {};
+
+namespace detail {
+
+template 
+struct type_identity {
+  using type = T;
+};  // or use type_identity (since C++20)
+
+template 
+auto try_add_pointer(int) -> type_identity::type*>;
+template 
+auto try_add_pointer(...) -> type_identity;
+
+}  // namespace detail
+
+template 
+struct add_pointer : decltype(detail::try_add_pointer(0)) {};
+
+template 
+struct conditional {
+  typedef T type;
+};
+
+template 
+struct conditional {
+  typedef F type;
+};
+
+template 
+struct remove_cv {
+  typedef T type;
+};
+template 
+struct remove_cv {
+  typedef T type;
+};
+template 
+struct remove_cv {
+  typedef T type;
+};
+template 
+struct remove_cv {
+  typedef T type;
+};
+
+template 
+struct decay {
+ private:
+  typedef typename remove_reference::type U;
+
+ public:
+  typedef typename conditional<
+  is_array::value, typename remove_extent::type*,
+  typename conditional::value, typename add_pointer::type,
+   typename remove_cv::type>::type>::type type;
+};
+
 } // namespace std
+
+#endif // TYPE_TRAITS_H
 )";
 
 static constexpr char StdUtilityHeader[] = R"(
+#ifndef UTILITY_H
+#define UTILITY_H
+
 #include "std_type_traits.h"
 
 namespace std {
 
 template 
-constexpr std::remove_reference_t&& move(T&& x);
+constexpr remove_reference_t&& move(T&& x);
 
 } // namespace std
+
+#endif // UTILITY_H
+)";
+
+static constexpr char StdInitializerListHeader[] = R"(
+#ifndef INITIALIZER_LIST_H
+#define INITIALIZER_LIST_H
+
+namespace std {
+
+template 
+class initializer_list {
+ public:
+  initializer_list() noexcept;
+};
+
+} // namespace std
+
+#endif // INITIALIZER_LIST_H
 )";
 
 static constexpr char StdOptionalHeader[] = R"(
+#include "std_type_traits.h"
+#include "std_utility.h"
+#include "std_initializer_list.h"
+
 namespace std {
 
 template 
@@ -74,13 +201,41 @@
   const T&& value() const&&;
   T&& value() &&;
 
+  template 
+  constexpr T value_or(U&& v) const&;
+  template 
+  T value_or(U&& v) &&;
+
+  template 
+  T& emplace(Args&&... args);
+
+  template 
+  T& emplace(std::initializer_list ilist, Args&&... args);
+
+  void reset() noexcept;
+
+  constexpr explicit operator bool() const noexcept;
   constexpr bool has_value() const noexcept;
 };
 
+template 
+constexpr optional::type> make_optional(T&& v);
+
+template 
+constexpr optional make_optional(Args&&... args);
+
+template 
+constexpr optional make_optional(std::initializer_list il,
+Args&&... args);
+
 } // namespace std
 )";
 
 static constexpr char AbslOptionalHeader[] = R"(
+#include "std_type_traits.h"
+#include "std_utility.h"
+#include "std_initializer_list.h"
+
 namespace absl {
 
 template 
@@ -101,13 +256,41 @@
   const T&& value() const&&;
   T&& value() &&;
 
+  template 
+  constexpr T value_or(U&& v) const&;
+  template 
+  T value_or(U&& v) &&;
+
+  template 
+  T& emplace(Args&&... args);
+
+  template 
+  T& emplace(std::initializer_list ilist, Args&&... args);
+
+  void reset() noexcept;
+
+  constexpr 

[PATCH] D119590: exclude openembedded distributions from setting rpath on openmp executables

2022-03-10 Thread Khem Raj via Phabricator via cfe-commits
raj.khem added a comment.
Herald added a project: All.

In D119590#3316050 , @JonChesterfield 
wrote:

> Cross compilers are a hazard here. I'd expect there to be a fairly long list 
> of magic flags you need to pass to clang to get it to find the right 
> libraries. Can you add fno-openmp-implicit-rpath to that list instead?

hmmm, I would say the original patch made assumption about native compile is 
the only option, clang claims to be inherently cross compiler.  Anyway adding 
`-fno-openmp-implicit-rpath` would mean that all SDKs generated by 
OpenEmbedded/Yocto project will have to somehow specify this option by default 
as well. it might work for system builds by specifying in global CFLAGS or 
adding to CC var itself.

> A better solution might be a cmake flag to specify where to use for the 
> implicit rpath directory instead of deriving it from sys::path::parent_path. 
> That would let your target set up a cross compiling toolchain that creates 
> binaries that are able to find libomp et al in whatever directory they're 
> located, without assuming a whole llvm toolchain installed onto the target.

right. Cmake flag route seems a good one. I will explore it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119590

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


[PATCH] D120727: [libc++] Overhaul how we select the ABI library

2022-03-10 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D120727#3372594 , @mstorsjo wrote:

> FWIW I think D116689  interacts with this 
> somewhat. I think D116689  is useful for 
> the fixes I want to do wrt libcxxabi integration on Windows (but I haven't 
> studied it, nor this one, closely yet though). @phosek Do you see anything in 
> this one that isn't compatible with D116689 
> ?

It does interact a lot, in fact. If we land this patch, I suspect that the 
libc++abi parts of D116689  may not be 
necessary anymore. And I also had a plan (not concrete) to use a similar 
approach for deciding how the unwind library is picked up, which may be worth 
exploring. As far as I can tell, the main thing that is nicer with D116689 
's approach over this patch is that we can 
get rid of logic around `"-Wl,-force_load"` for merging the static library into 
libc++, but I think the approach proposed here would be compatible with that 
too.

The thing I like about this approach is that it simplifies the amount of logic 
we need by properly encoding dependencies in the `libcxx-abi-shared|static` 
targets.




Comment at: libcxx/src/CMakeLists.txt:233-239
 if (APPLE)
-  target_link_libraries(cxx_shared PRIVATE "-Wl,-force_load" 
"${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
+  target_link_libraries(cxx_shared PRIVATE "-Wl,-force_load" 
"$")
 else()
-  target_link_libraries(cxx_shared PRIVATE "-Wl,--whole-archive,-Bstatic" 
"${LIBCXX_CXX_STATIC_ABI_LIBRARY}" "-Wl,-Bdynamic,--no-whole-archive")
+  target_link_libraries(cxx_shared PRIVATE "-Wl,--whole-archive,-Bstatic" 
"$" "-Wl,-Bdynamic,--no-whole-archive")
 endif()
   else()
+target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)

This part would become nicer if we had an `OBJECT` library like in D116689. I 
think this approach does not preclude improving this in the future by using an 
object library.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120727

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


[PATCH] D121165: [pseudo] Add crude heuristics to choose taken preprocessor branches.

2022-03-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Pseudo/DirectiveMap.h:123
+/// The choices are stored in Conditional::Taken nodes.
+void chooseConditionalBranches(DirectiveMap &, const TokenStream );
+

off-topic: a random idea on the name of `DirectiveMap` came up to my mind when 
reading the code, how about `DirectiveTree`, the comment of it says the 
structure is a tree, and the `BranchChooser` is actually a tree-visiting 
pattern.



Comment at: clang/include/clang/Tooling/Syntax/Pseudo/Token.h:84
+  /// Returns the next token in the stream, skipping over comments.
+  const Token _nc() const {
+const Token *T = this;

nit: the name doesn't match the LLVM code-style.



Comment at: clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp:210
+namespace {
+class BranchChooser {
+public:

We evaluate each conditional directive *independently*, I wonder whether it is 
important to use any low-hanging tricks to ensure consistent choices are made 
among different conditional directives. (my gut feeling is that it is nice to 
have, but we should not worry too much about it at the moment).

For example,

```
#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif
```

If we enable the first #if, and the second one should be enabled as well. (this 
example is a trivial and common pattern, it has been handled by the existing 
code).



Comment at: clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp:218
+  // Describes the code seen by making particular branch choices.
+  struct Score {
+unsigned Tokens = 0; // excluding comments and directives

nit: add a comment saying `higher is better`.



Comment at: clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp:225
+  // Seeing errors is bad, other things are good.
+  return std::tie(Other.Errors, Tokens, Directives) >
+ std::tie(Errors, Other.Tokens, Other.Directives);

Maybe `(-Errors, Tokens, Directives) > (-Other.Errors, ...)`



Comment at: clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp:295
+  // Is this the best branch so far? (Including if it's #if 1).
+  if (TookTrivial || !C.Taken || BranchScore > Best) {
+Best = BranchScore;

nit: `!C.Taken` => `!C.Token.hasValue()`, which is clearer.



Comment at: clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp:305
+  // false if the branch is never taken, and None otherwise.
+  llvm::Optional isTriviallyTaken(const DirectiveMap::Directive ) {
+switch (Dir.Kind) {

nit: instead of using `trivially`, I think `confidently` fits better what the 
method does.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121165

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


[PATCH] D120272: [CUDA] Add driver support for compiling CUDA with the new driver

2022-03-10 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 414371.
jhuber6 added a comment.
Herald added subscribers: abrachet, phosek.

Fix architecture parsing and still include the GPU binary so cuobjcopy can use 
them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120272

Files:
  clang/include/clang/Basic/Cuda.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cuda-openmp-driver.cu

Index: clang/test/Driver/cuda-openmp-driver.cu
===
--- /dev/null
+++ clang/test/Driver/cuda-openmp-driver.cu
@@ -0,0 +1,16 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu -nocudalib -ccc-print-bindings -fgpu-rdc \
+// RUN:-foffload-new-driver --offload-arch=sm_35 --offload-arch=sm_70 %s 2>&1 \
+// RUN: | FileCheck -check-prefix CHECK %s
+
+// CHECK: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[PTX_SM_35:.+]]"
+// CHECK: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[PTX_SM_35]]"], output: "[[CUBIN_SM_35:.+]]"
+// CHECK: "nvptx64-nvidia-cuda" - "NVPTX::Linker", inputs: ["[[CUBIN_SM_35]]", "[[PTX_SM_35]]"], output: "[[FATBIN_SM_35:.+]]"
+// CHECK: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]"], output: "[[PTX_SM_70:.+]]"
+// CHECK: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[PTX_SM_70:.+]]"], output: "[[CUBIN_SM_70:.+]]"
+// CHECK: "nvptx64-nvidia-cuda" - "NVPTX::Linker", inputs: ["[[CUBIN_SM_70]]", "[[PTX_SM_70:.+]]"], output: "[[FATBIN_SM_70:.+]]"
+// CHECK: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT]]", "[[FATBIN_SM_35]]", "[[FATBIN_SM_70]]"], output: "[[HOST_OBJ:.+]]"
+// CHECK: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -71,8 +71,8 @@
   if (Args.hasArg(options::OPT_static))
 if (const Arg *A =
 Args.getLastArg(options::OPT_dynamic, options::OPT_mdynamic_no_pic))
-  D.Diag(diag::err_drv_argument_not_allowed_with) << A->getAsString(Args)
-  << "-static";
+  D.Diag(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "-static";
 }
 
 // Add backslashes to escape spaces and other backslashes.
@@ -157,8 +157,8 @@
 /// parameter in reciprocal argument strings. Return false if there is an error
 /// parsing the refinement step. Otherwise, return true and set the Position
 /// of the refinement step in the input string.
-static bool getRefinementStep(StringRef In, const Driver ,
-  const Arg , size_t ) {
+static bool getRefinementStep(StringRef In, const Driver , const Arg ,
+  size_t ) {
   const char RefinementStepToken = ':';
   Position = In.find(RefinementStepToken);
   if (Position != StringRef::npos) {
@@ -510,7 +510,7 @@
 }
 
 static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple ) {
-  switch (Triple.getArch()){
+  switch (Triple.getArch()) {
   default:
 return false;
   case llvm::Triple::arm:
@@ -705,7 +705,7 @@
 
 /// Add a CC1 and CC1AS option to specify the coverage file path prefix map.
 static void addCoveragePrefixMapArg(const Driver , const ArgList ,
-   ArgStringList ) {
+ArgStringList ) {
   for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
 options::OPT_fcoverage_prefix_map_EQ)) {
 StringRef Map = A->getValue();
@@ -801,13 +801,12 @@
   CSPGOGenerateArg->getOption().matches(options::OPT_fno_profile_generate))
 CSPGOGenerateArg = nullptr;
 
-  auto *ProfileGenerateArg = Args.getLastArg(
-  options::OPT_fprofile_instr_generate,
-  options::OPT_fprofile_instr_generate_EQ,
-  options::OPT_fno_profile_instr_generate);
-  if (ProfileGenerateArg &&
-  ProfileGenerateArg->getOption().matches(
-  options::OPT_fno_profile_instr_generate))
+  auto *ProfileGenerateArg =
+  Args.getLastArg(options::OPT_fprofile_instr_generate,
+  options::OPT_fprofile_instr_generate_EQ,
+  options::OPT_fno_profile_instr_generate);
+  if (ProfileGenerateArg && ProfileGenerateArg->getOption().matches(
+options::OPT_fno_profile_instr_generate))
 ProfileGenerateArg = nullptr;
 
   if (PGOGenerateArg && ProfileGenerateArg)
@@ -1334,8 +1333,8 @@
   }
 
   if (ThroughHeader.empty()) {
-CmdArgs.push_back(Args.MakeArgString(
-

[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-03-10 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/Format.cpp:2685
 const char CppIncludeRegexPattern[] =
-R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
+R"(^[\t\ ]*[@#]?[\t\ ]*(import|include)[^"<]*[\t\n\ 
\\]*("[^"]+"|<[^>]+>|[^"<>;]+;))";
 

curdeius wrote:
> I'd rather see handling separately the `#import`/`#include` case on one hand 
> and `@import` on the other.
> IIUC, `@import` is followed by `ns1.ns2.something` without quotes nor `<>`. 
> And it ends with a `;`.
> Trying to put everything together is IMO error-prone and not very readable.
> 
> You could just do (pseudo-code):
> ```
> CppIncludeRegexPattern = (current_regex) | "@\s*import\s+[^;]+;"
> ```
> (`\s` is probably not supported, but we could use character class `[:space:]` 
> for clarity, cf. llvm\lib\Support\regcomp.c)
> 
> Not sure whether whitespace is allowed after `@`.
> Could you please post a link to the specification of `@import` syntax?
> 
> Not sure fixing `<"` / `">` issue is worth it, but in all cases I'd prefer 
> seeing it in a different patch.
`[:space:]` would match newlines and we don't want this in all cases, but 
`[:blank:]` should be a good replacement for `[\t ]`.

On a different note, why there's a new line `\n` and backslash `\\` in `[\t\n\ 
\\]`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

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


[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-03-10 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/Format.cpp:2685
 const char CppIncludeRegexPattern[] =
-R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
+R"(^[\t\ ]*[@#]?[\t\ ]*(import|include)[^"<]*[\t\n\ 
\\]*("[^"]+"|<[^>]+>|[^"<>;]+;))";
 

I'd rather see handling separately the `#import`/`#include` case on one hand 
and `@import` on the other.
IIUC, `@import` is followed by `ns1.ns2.something` without quotes nor `<>`. And 
it ends with a `;`.
Trying to put everything together is IMO error-prone and not very readable.

You could just do (pseudo-code):
```
CppIncludeRegexPattern = (current_regex) | "@\s*import\s+[^;]+;"
```
(`\s` is probably not supported, but we could use character class `[:space:]` 
for clarity, cf. llvm\lib\Support\regcomp.c)

Not sure whether whitespace is allowed after `@`.
Could you please post a link to the specification of `@import` syntax?

Not sure fixing `<"` / `">` issue is worth it, but in all cases I'd prefer 
seeing it in a different patch.



Comment at: clang/lib/Format/Format.cpp:2759
+  IncludeName =
+  StringRef(Twine("<", IncludeName).concat(Twine(">")).str());
+}

HazardyKnusperkeks wrote:
> How does that not go out of scope and I have a dangling reference?
Why not doing it the other way round, i.e. trimming `<>"` from include name?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

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


[PATCH] D121374: [flang][driver] Add support for `-mllvm`

2022-03-10 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: flang/test/Driver/mllvm.f90:1
+! Test the `-mlvm` option
+

xbolva00 wrote:
> awarzynski wrote:
> > xbolva00 wrote:
> > > mllvm
> > Does it matter? `-mllvm` is consistent with other tests in this directory 
> > (e.g. 
> > https://github.com/llvm/llvm-project/blob/main/flang/test/Driver/emit-llvm.f90#L1).
> Just typo “mlvm”
Sorry, I misread that :/ I thought that you meant `mllvm` instead of `-mllvm`. 
My bad, thanks for pointing this out! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121374

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


  1   2   >