[PATCH] D78441: Delete NaCl support

2023-08-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D78441#4074689 , @MaskRay wrote:

> In D78441#4067440 , @dschuff wrote:
>
>> Sorry, no :)
>
> Is there a timeline for the removal?

@dschuff :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78441

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


[PATCH] D157485: [X86][RFC] Support new feature AVX10

2023-08-15 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:927
+  !STI.hasFeature(X86::FeatureAVX10_512bit))
+report_fatal_error("ZMM registers are not supported without AVX10-512BIT");
   switch (TSFlags & X86II::OpPrefixMask) {

skan wrote:
> -mavx10.1 does not work for assembler. So if such instruction is generated 
> w/o AVX10-512BIT support, it must be compiler's issue instead of user's. An 
> `assert` should be more appropriate here.
> -mavx10.1 does not work for assembler. So if such instruction is generated 
> w/o AVX10-512BIT support, it must be compiler's issue instead of user's. An 
> `assert` should be more appropriate here.

Reference: https://llvm.org/docs/CodingStandards.html#assert-liberally


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157485

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


[PATCH] D142660: [AIX] supporting -X options for llvm-ranlib in AIX OS

2023-08-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/include/llvm/Object/ArchiveWriter.h:43
 
+enum SymtabWritingMode {
+  NoSymtab, // Do not write symbol table.

Below you use `SymtabWritingMode::` for all members, so just make this enum 
scoped.



Comment at: llvm/tools/llvm-ar/llvm-ar.cpp:1452
+  fail(
+  Twine("the specified object mode is not valid. Specify -X32, 
"
+"-X64, -X32_64, or -Xany"));

Remove `Twine(` and `)`. 



Comment at: llvm/tools/llvm-ar/llvm-ar.cpp:1474
+if (!HasAIXXOption) {
+  char *EnvObjectMode = getenv("OBJECT_MODE");
+  if (EnvObjectMode) {

C++17 allows `if (char *EnvObjectMode = getenv("OBJECT_MODE"))`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142660

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


[PATCH] D157151: [Driver] Refactor to use llvm Option's new Visibility flags

2023-08-15 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

To avoid a full revert, I removed the deprecations in this patch in 
https://github.com/llvm/llvm-project/commit/348d36f1a2c8c776ce87e038bf15fc4cabd62702.
 Please do not deprecate methods that have remaining in-tree users and make 
sure that `-Werror=deprecated-declarations` builds work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157151

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


[PATCH] D156891: [CodeGen] Remove Constant arguments from linkage functions, NFCI.

2023-08-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

ping - this one is the only prerequisite left for three of my patches that were 
accepted yesterday...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156891

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


[PATCH] D157485: [X86][RFC] Support new feature AVX10

2023-08-15 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:2581
+ unsigned VectorWidth) {
+  if (!getTarget().getTriple().isX86() || VectorWidth < 512)
+return;

Minor suggestion. The code here may be refined to be better extended by other 
targets, like
```
  llvm::Triple::ArchType ArchType =
  getContext().getTargetInfo().getTriple().getArch();

  switch (ArchType) {
  case llvm::Triple::x86:
  case llvm::Triple::x86_64: {
 
   }
   default:
return;

```



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:925
   Prefix.setL2(TSFlags & X86II::EVEX_L2);
+  if (Prefix.getL2() && STI.hasFeature(X86::FeatureAVX10_1) &&
+  !STI.hasFeature(X86::FeatureAVX10_512bit))

I think what you need here is `TSFlags & X86II::EVEX_L2` instead of `getL2()`. 
The class `X86OpcodePrefixHelper` is designed for encoding only. The bit `L2` 
can be set in other cases so it may blur the meaning of 512-bit here you use 
the getter.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:927
+  !STI.hasFeature(X86::FeatureAVX10_512bit))
+report_fatal_error("ZMM registers are not supported without AVX10-512BIT");
   switch (TSFlags & X86II::OpPrefixMask) {

-mavx10.1 does not work for assembler. So if such instruction is generated w/o 
AVX10-512BIT support, it must be compiler's issue instead of user's. An 
`assert` should be more appropriate here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157485

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


[PATCH] D142660: [AIX] supporting -X options for llvm-ranlib in AIX OS

2023-08-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

`# REQUIRES: system-aix` in llvm/test/tools/llvm-ranlib/aix-X-option.test 
unfortunately makes most -X tests only work on AIX, which most contributors 
don't have access to.

Ideally `-X` is usable when the user specifies `--format=bigarchive`.

The environment variable `OBJECT_MODE` can be made AIX specific, though.




Comment at: llvm/test/tools/llvm-ranlib/aix-X-option.test:1
+## REQUIRES: system-aix
+## Test the -X option.

`# REQUIRES: system-aix`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142660

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


[PATCH] D158045: [clang][SVE] Rename isVLSTBuiltinType, NFC

2023-08-15 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan updated this revision to Diff 550627.
jacquesguan added a comment.

fix compile


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158045

Files:
  clang/include/clang/AST/Type.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp

Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8363,7 +8363,7 @@
   }
 
   // Attribute can only be attached to a single SVE vector or predicate type.
-  if (!CurType->isVLSTBuiltinType()) {
+  if (!CurType->isSVEVLSTBuiltinType()) {
 S.Diag(Attr.getLoc(), diag::err_attribute_invalid_sve_type)
 << Attr << CurType;
 Attr.setInvalid();
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6305,7 +6305,7 @@
 
 static bool isValidSizelessVectorForConditionalCondition(ASTContext &Ctx,
  QualType CondTy) {
-  if (!CondTy->isVLSTBuiltinType())
+  if (!CondTy->isSVEVLSTBuiltinType())
 return false;
   const QualType EltTy =
   cast(CondTy.getCanonicalType())->getSveEltType(Ctx);
@@ -6417,10 +6417,10 @@
 
   QualType LHSType = LHS.get()->getType();
   const auto *LHSBT =
-  LHSType->isVLSTBuiltinType() ? LHSType->getAs() : nullptr;
+  LHSType->isSVEVLSTBuiltinType() ? LHSType->getAs() : nullptr;
   QualType RHSType = RHS.get()->getType();
   const auto *RHSBT =
-  RHSType->isVLSTBuiltinType() ? RHSType->getAs() : nullptr;
+  RHSType->isSVEVLSTBuiltinType() ? RHSType->getAs() : nullptr;
 
   QualType ResultType;
 
@@ -6462,7 +6462,7 @@
 RHS = ImpCastExprToType(RHS.get(), ResultType, CK_VectorSplat);
   }
 
-  assert(!ResultType.isNull() && ResultType->isVLSTBuiltinType() &&
+  assert(!ResultType.isNull() && ResultType->isSVEVLSTBuiltinType() &&
  "Result should have been a vector type");
   auto *ResultBuiltinTy = ResultType->castAs();
   QualType ResultElementTy = ResultBuiltinTy->getSveEltType(Context);
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -5945,7 +5945,7 @@
 if (Combined != MemberQuals)
   ResultType = Context.getQualifiedType(ResultType, Combined);
   } else if (LHSTy->isBuiltinType() &&
- LHSTy->getAs()->isVLSTBuiltinType()) {
+ LHSTy->getAs()->isSVEVLSTBuiltinType()) {
 const BuiltinType *BTy = LHSTy->getAs();
 if (BTy->isSVEBool())
   return ExprError(Diag(LLoc, diag::err_subscript_svbool_t)
@@ -10934,7 +10934,7 @@
 assert(!isa(VT) &&
"ExtVectorTypes should not be handled here!");
 VectorEltTy = VT->getElementType();
-  } else if (VectorTy->isVLSTBuiltinType()) {
+  } else if (VectorTy->isSVEVLSTBuiltinType()) {
 VectorEltTy =
 VectorTy->castAs()->getSveEltType(S.getASTContext());
   } else {
@@ -11297,25 +11297,25 @@
   if (Context.hasSameType(LHSType, RHSType))
 return LHSType;
 
-  if (LHSType->isVLSTBuiltinType() && !RHSType->isVLSTBuiltinType()) {
+  if (LHSType->isSVEVLSTBuiltinType() && !RHSType->isSVEVLSTBuiltinType()) {
 if (!tryGCCVectorConvertAndSplat(*this, &RHS, &LHS))
   return LHSType;
   }
-  if (RHSType->isVLSTBuiltinType() && !LHSType->isVLSTBuiltinType()) {
+  if (RHSType->isSVEVLSTBuiltinType() && !LHSType->isSVEVLSTBuiltinType()) {
 if (LHS.get()->isLValue() ||
 !tryGCCVectorConvertAndSplat(*this, &LHS, &RHS))
   return RHSType;
   }
 
-  if ((!LHSType->isVLSTBuiltinType() && !LHSType->isRealType()) ||
-  (!RHSType->isVLSTBuiltinType() && !RHSType->isRealType())) {
+  if ((!LHSType->isSVEVLSTBuiltinType() && !LHSType->isRealType()) ||
+  (!RHSType->isSVEVLSTBuiltinType() && !RHSType->isRealType())) {
 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
 << LHSType << RHSType << LHS.get()->getSourceRange()
 << RHS.get()->getSourceRange();
 return QualType();
   }
 
-  if (LHSType->isVLSTBuiltinType() && RHSType->isVLSTBuiltinType() &&
+  if (LHSType->isSVEVLSTBuiltinType() && RHSType->isSVEVLSTBuiltinType() &&
   Context.getBuiltinVectorTypeInfo(LHSBuiltinTy).EC !=
   Context.getBuiltinVectorTypeInfo(RHSBuiltinTy).EC) {
 Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
@@ -11324,11 +11324,11 @@
 return QualType();
   }
 
-  if (LHSType->isVLSTBuiltinType() || RHSType->isVLSTBuiltinType()) {
-QualType Scalar = LHSType->isVLSTBuiltinType() ? RHSType : LHSType;
-QualType Vector = LHSType->isVLSTBuiltinType() ? LH

[PATCH] D157485: [X86][RFC] Support new feature AVX10

2023-08-15 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

Ping~ It looks to me there's no concern about this solution in the RFC 
. I 
think we can move forward to land it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157485

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


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a subscriber: aaron.ballman.
pengfei added a comment.

BTW, maybe @aaron.ballman knows why we don't support such syntax in C++.


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

https://reviews.llvm.org/D157297

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


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D157297

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


[PATCH] D158050: [RISCV] RISCV vector calling convention (2/2)

2023-08-15 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
4vtomat requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, eopXD, MaskRay.
Herald added a project: clang.

This patch handles vector type and tuple type arguments
calling convention. Vector type arguments can be passed
directly by register or by reference, however tuple type
arguments are split into multiple vector type arguments,
all of these arguments should be either passed by references
or passed by registers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158050

Files:
  clang/include/clang/AST/Type.h
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/test/CodeGen/RISCV/riscv-vector-callingconv-llvm-ir.c

Index: clang/test/CodeGen/RISCV/riscv-vector-callingconv-llvm-ir.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-vector-callingconv-llvm-ir.c
@@ -0,0 +1,26 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v \
+// RUN:   -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-LLVM %s
+
+#include 
+
+// CHECK-LLVM: void @call1( %v0,  %v1.coerce0,  %v1.coerce1,  %v2,  %v3)
+void call1(vint32m2_t v0, vint32m4x2_t v1, vint32m4_t v2, vint32m1_t v3) {}
+
+// CHECK-LLVM: void @call2( %v0.coerce0,  %v0.coerce1,  %v0.coerce2,  %v1.coerce0,  %v1.coerce1,  %v2, ptr noundef %0)
+void call2(vint32m1x3_t v0, vint32m4x2_t v1, vint32m4_t v2, vint32m2_t v3) {}
+
+// CHECK-LLVM: void @call3( %v0.coerce0,  %v0.coerce1, ptr noundef %0,  %v2.coerce0,  %v2.coerce1)
+void call3(vint32m4x2_t v0, vint32m1_t v1, vint32m4x2_t v2) {}
+
+// CHECK-LLVM: void @call4( %v0, ptr noundef %0,  %v2)
+void call4(vint32m8_t v0, vint32m1_t v1, vint32m8_t v2) {}
+
+// CHECK-LLVM: void @call5(ptr noundef %0,  %v1, ptr noundef %1,  %v3)
+void call5(vint32m1_t v0, vint32m8_t v1, vint32m1_t v2, vint32m8_t v3) {}
+
+// CHECK-LLVM: void @call6( %v0,  %v1,  %v2,  %v3)
+void call6(vint8mf8_t v0, vint8m8_t v1, vint32m1_t v2, vint8mf8_t v3) {}
+
+// CHECK-LLVM: void @call7(ptr noundef %0,  %v1,  %v2, ptr noundef %1)
+void call7(vint8mf8_t v0, vint8m8_t v1, vint32m8_t v2, vint8mf8_t v3) {}
Index: clang/lib/CodeGen/Targets/RISCV.cpp
===
--- clang/lib/CodeGen/Targets/RISCV.cpp
+++ clang/lib/CodeGen/Targets/RISCV.cpp
@@ -8,6 +8,7 @@
 
 #include "ABIInfoImpl.h"
 #include "TargetInfo.h"
+#include "llvm/TargetParser/RISCVTargetParser.h"
 
 using namespace clang;
 using namespace clang::CodeGen;
@@ -19,6 +20,9 @@
 namespace {
 class RISCVABIInfo : public DefaultABIInfo {
 private:
+  using ArgRegPair = std::pair;
+  using ArgRegPairs = llvm::SmallVector;
+
   // Size of the integer ('x') registers in bits.
   unsigned XLen;
   // Size of the floating point ('f') registers in bits. Note that the target
@@ -27,11 +31,15 @@
   unsigned FLen;
   static const int NumArgGPRs = 8;
   static const int NumArgFPRs = 8;
+  static const int NumArgVRs = 16;
   bool detectFPCCEligibleStructHelper(QualType Ty, CharUnits CurOff,
   llvm::Type *&Field1Ty,
   CharUnits &Field1Off,
   llvm::Type *&Field2Ty,
   CharUnits &Field2Off) const;
+  unsigned
+  computeMaxAssignedRegs(ArgRegPairs &RVVArgRegPairs,
+ std::vector> &MaxRegs) const;
 
 public:
   RISCVABIInfo(CodeGen::CodeGenTypes &CGT, unsigned XLen, unsigned FLen)
@@ -41,6 +49,9 @@
   // non-virtual, but computeInfo is virtual, so we overload it.
   void computeInfo(CGFunctionInfo &FI) const override;
 
+  ArgRegPairs calculateRVVArgVRegs(CGFunctionInfo &FI) const;
+  void classifyRVVArgumentType(ArgRegPairs RVVArgRegPairs) const;
+
   ABIArgInfo classifyArgumentType(QualType Ty, bool IsFixed, int &ArgGPRsLeft,
   int &ArgFPRsLeft) const;
   ABIArgInfo classifyReturnType(QualType RetTy) const;
@@ -92,9 +103,98 @@
   int ArgNum = 0;
   for (auto &ArgInfo : FI.arguments()) {
 bool IsFixed = ArgNum < NumFixedArgs;
+ArgNum++;
+
+if (ArgInfo.type.getTypePtr()->isRVVType())
+  continue;
+
 ArgInfo.info =
 classifyArgumentType(ArgInfo.type, IsFixed, ArgGPRsLeft, ArgFPRsLeft);
-ArgNum++;
+  }
+
+  classifyRVVArgumentType(calculateRVVArgVRegs(FI));
+}
+
+// Calculate total vregs each RVV argument needs.
+RISCVABIInfo::ArgRegPairs
+RISCVABIInfo::calculateRVVArgVRegs(CGFunctionInfo &FI) const {
+  RISCVABIInfo::ArgRegPairs RVVArgRegPairs;
+  for (auto &ArgInfo : FI.arguments()) {
+const QualType &Ty = ArgInfo.

[PATCH] D155419: [Clang][CMake] Add CSSPGO support to LLVM_BUILD_INSTRUMENTED

2023-08-15 Thread Amir Ayupov via Phabricator via cfe-commits
Amir updated this revision to Diff 550607.
Amir added a comment.

perf2prof


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155419

Files:
  clang/CMakeLists.txt
  clang/cmake/caches/CSSPGO.cmake
  clang/utils/perf-training/CMakeLists.txt
  clang/utils/perf-training/lit.cfg
  clang/utils/perf-training/lit.site.cfg.in
  clang/utils/perf-training/perf-helper.py
  llvm/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake

Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1076,7 +1076,7 @@
 option(LLVM_ENABLE_IR_PGO "Build LLVM and tools with IR PGO instrumentation (deprecated)" Off)
 mark_as_advanced(LLVM_ENABLE_IR_PGO)
 
-set(LLVM_BUILD_INSTRUMENTED OFF CACHE STRING "Build LLVM and tools with PGO instrumentation. May be specified as IR or Frontend")
+set(LLVM_BUILD_INSTRUMENTED OFF CACHE STRING "Build LLVM and tools with PGO instrumentation. May be specified as IR, Frontend, CSIR, CSSPGO")
 set(LLVM_VP_COUNTERS_PER_SITE "1.5" CACHE STRING "Value profile counters to use per site for IR PGO with Clang")
 mark_as_advanced(LLVM_BUILD_INSTRUMENTED LLVM_VP_COUNTERS_PER_SITE)
 string(TOUPPER "${LLVM_BUILD_INSTRUMENTED}" uppercase_LLVM_BUILD_INSTRUMENTED)
@@ -1109,6 +1109,15 @@
 CMAKE_EXE_LINKER_FLAGS
 CMAKE_SHARED_LINKER_FLAGS)
 endif()
+  elseif(uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "CSSPGO")
+append("-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fpseudo-probe-for-profiling"
+  CMAKE_CXX_FLAGS
+  CMAKE_C_FLAGS)
+if(NOT LINKER_IS_LLD_LINK)
+  append("-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fpseudo-probe-for-profiling"
+CMAKE_EXE_LINKER_FLAGS
+CMAKE_SHARED_LINKER_FLAGS)
+endif()
   else()
 append("-fprofile-instr-generate=\"${LLVM_PROFILE_FILE_PATTERN}\""
   CMAKE_CXX_FLAGS
@@ -1159,6 +1168,21 @@
   endif()
 endif()
 
+if(LLVM_SPROFDATA_FILE AND EXISTS ${LLVM_SPROFDATA_FILE})
+  if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
+append("-fpseudo-probe-for-profiling -fprofile-sample-use=\"${LLVM_SPROFDATA_FILE}\""
+  CMAKE_CXX_FLAGS
+  CMAKE_C_FLAGS)
+if(NOT LINKER_IS_LLD_LINK)
+  append("-fpseudo-probe-for-profiling -fprofile-sample-use=\"${LLVM_SPROFDATA_FILE}\""
+CMAKE_EXE_LINKER_FLAGS
+CMAKE_SHARED_LINKER_FLAGS)
+endif()
+  else()
+message(FATAL_ERROR "LLVM_SPROFDATA_FILE can only be specified when compiling with clang")
+  endif()
+endif()
+
 option(LLVM_BUILD_INSTRUMENTED_COVERAGE "Build LLVM and tools with Code Coverage instrumentation" Off)
 option(LLVM_INDIVIDUAL_TEST_COVERAGE "Emit individual coverage file for each test case." OFF)
 mark_as_advanced(LLVM_BUILD_INSTRUMENTED_COVERAGE)
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -853,6 +853,9 @@
 set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
   "Profiling data file to use when compiling in order to improve runtime performance.")
 
+set(LLVM_SPROFDATA_FILE "" CACHE FILEPATH
+  "Sampling profiling data file to use when compiling in order to improve runtime performance.")
+
 if(LLVM_INCLUDE_TESTS)
   # Lit test suite requires at least python 3.6
   set(LLVM_MINIMUM_PYTHON_VERSION 3.6)
Index: clang/utils/perf-training/perf-helper.py
===
--- clang/utils/perf-training/perf-helper.py
+++ clang/utils/perf-training/perf-helper.py
@@ -69,11 +69,15 @@
 
 def perf(args):
 parser = argparse.ArgumentParser(
-prog="perf-helper perf", description="perf wrapper for BOLT profile collection"
+prog="perf-helper perf",
+description="perf wrapper for BOLT/CSSPGO profile collection"
 )
 parser.add_argument(
 "--lbr", action="store_true", help="Use perf with branch stacks"
 )
+parser.add_argument(
+"--call-graph", action="store_true", help="Collect call graph"
+)
 parser.add_argument("cmd", nargs="*", help="")
 
 # Use python's arg parser to handle all leading option arguments, but pass
@@ -93,6 +97,8 @@
 ]
 if opts.lbr:
 perf_args += ["--branch-filter=any,u"]
+if opts.call_graph:
+perf_args += ["--call-graph=fp"]
 perf_args.extend(cmd)
 
 start_time = time.time()
@@ -130,6 +136,26 @@
 return 0
 
 
+def perf2prof(args):
+parser = argparse.ArgumentParser(
+prog="perf-helper perf2prof",
+description="perf to CSSPGO prof conversion wrapper",
+)
+parser.add_argument("profgen", help="Path to llvm-profgen binary")
+parser.add_argument("binary", help="Input binary")
+parser.add_argument("path", help="Path containing perf.data f

[PATCH] D158037: [Driver][DXC] Remove a bunch of options from DXC

2023-08-15 Thread Justin Bogner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe17667b33f1f: [Driver][DXC] Remove a bunch of options from 
DXC (authored by bogner).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158037

Files:
  clang/include/clang/Driver/Options.td

Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -195,8 +195,7 @@
 def m_wasm_Features_Driver_Group : OptionGroup<"">,
Group, DocName<"WebAssembly Driver">;
 def m_x86_Features_Group : OptionGroup<"">,
-   Group,
-   Visibility<[ClangOption, CLOption, DXCOption]>,
+   Group, Visibility<[ClangOption, CLOption]>,
DocName<"X86">;
 def m_riscv_Features_Group : OptionGroup<"">,
  Group, DocName<"RISC-V">;
@@ -274,8 +273,7 @@
 // Retired with clang-16.0, to provide a deprecation period; it should
 // be removed in Clang 18 or later.
 def enable_trivial_var_init_zero : Flag<["-"], "enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
-  Flags<[NoArgumentUnused]>,
-  Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
+  Flags<[NoArgumentUnused]>, Visibility<[ClangOption, CC1Option, CLOption]>,
   Group;
 
 // Group that ignores all gcc optimizations that won't be implemented
@@ -1079,7 +1077,7 @@
   Visibility<[ClangOption, CLOption, DXCOption]>,
   HelpText<"User directory for configuration files">;
 def coverage : Flag<["-", "--"], "coverage">, Group,
-  Visibility<[ClangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, CLOption]>;
 def cpp_precomp : Flag<["-"], "cpp-precomp">, Group;
 def current__version : JoinedOrSeparate<["-"], "current_version">;
 def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group,
@@ -1449,7 +1447,7 @@
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption, CLOption, DXCOption]>>;
+  BothFlags<[], [ClangOption, CLOption]>>;
 
 def fassume_sane_operator_new : Flag<["-"], "fassume-sane-operator-new">, Group;
 def fastcp : Flag<["-"], "fastcp">, Group;
@@ -1488,7 +1486,7 @@
 
 defm experimental_library : BoolFOption<"experimental-library",
   LangOpts<"ExperimentalLibrary">, DefaultFalse,
-  PosFlag>;
 
 def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group,
-Visibility<[ClangOption, CLOption, DXCOption]>;
+Visibility<[ClangOption, CLOption]>;
 def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, Group,
-Visibility<[ClangOption, CLOption, DXCOption]>;
+Visibility<[ClangOption, CLOption]>;
 def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
 Group, Flags<[NoXarchOption]>,
 Visibility<[ClangOption, CC1Option]>,
@@ -1568,8 +1566,7 @@
 Visibility<[ClangOption, CC1Option, CC1AsOption, CLOption, DXCOption]>,
 Alias;
 def fcoverage_compilation_dir_EQ : Joined<["-"], "fcoverage-compilation-dir=">,
-Group,
-Visibility<[ClangOption, CC1Option, CC1AsOption, CLOption, DXCOption]>,
+Group, Visibility<[ClangOption, CC1Option, CC1AsOption, CLOption]>,
 HelpText<"The compilation directory to embed in the coverage mapping.">,
 MarshallingInfoString>;
 def ffile_compilation_dir_EQ : Joined<["-"], "ffile-compilation-dir=">, Group,
@@ -1581,19 +1578,18 @@
   "Emit extra debug info to make sample profile more accurate">,
   NegFlag>;
 def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
-Group, Visibility<[ClangOption, CLOption, DXCOption]>,
+Group, Visibility<[ClangOption, CLOption]>,
 HelpText<"Generate instrumented code to collect execution counts into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var)">;
 def fprofile_instr_generate_EQ : Joined<["-"], "fprofile-instr-generate=">,
-Group, Visibility<[ClangOption, CLOption, DXCOption]>,
-MetaVarName<"">,
+Group, Visibility<[ClangOption, CLOption]>, MetaVarName<"">,
 HelpText<"Generate instrumented code to collect execution counts into  (overridden by LLVM_PROFILE_FILE env var)">;
 def fprofile_instr_use : Flag<["-"], "fprofile-instr-use">, Group,
-Visibility<[ClangOption, CLOption, DXCOption]>;
+Visibility<[ClangOption, CLOption]>;
 def fprofile_instr_use_EQ : Joined<["-"], "fprofile-instr-use=">,
-Group, Visibility<[ClangOption, CLOption, DXCOption]>,
+Group, Visibility<[ClangOption, CLOption]>,
 HelpText<"Use instrumentation data for profile-guided optimization">;
 def fprofile_remapping_file_EQ : Joined<["-"], "fprofile-remapping-file=">,
-Group, Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
+Group, Visibility<[ClangOption, CC1Option, CLOption]>,
 MetaVarName<"">,
 HelpText<"Use the remappings described in  t

[clang] e17667b - [Driver][DXC] Remove a bunch of options from DXC

2023-08-15 Thread Justin Bogner via cfe-commits

Author: Justin Bogner
Date: 2023-08-15T21:38:20-07:00
New Revision: e17667b33f1f37354a19be6b09d6812a61a66e2a

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

LOG: [Driver][DXC] Remove a bunch of options from DXC

Remove DXCOption from a whole bunch of options that we probably won't
support in the DXC driver. The initial clang-dxc support just made
everything that was a "CoreOption" available, regardless of whether it
made sense. Here I don't remove all of them, but this makes a dent on
making the list a bit more sensible. We can easily add or remove more
if they make sense later.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 4ba3b237b80e58..85ce340255d99a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -195,8 +195,7 @@ def m_wasm_Features_Group : OptionGroup<"">,
 def m_wasm_Features_Driver_Group : OptionGroup<"">,
Group, DocName<"WebAssembly 
Driver">;
 def m_x86_Features_Group : OptionGroup<"">,
-   Group,
-   Visibility<[ClangOption, CLOption, DXCOption]>,
+   Group, Visibility<[ClangOption, CLOption]>,
DocName<"X86">;
 def m_riscv_Features_Group : OptionGroup<"">,
  Group, DocName<"RISC-V">;
@@ -274,8 +273,7 @@ def mno_mpx : Flag<["-"], "mno-mpx">, 
Group;
 // Retired with clang-16.0, to provide a deprecation period; it should
 // be removed in Clang 18 or later.
 def enable_trivial_var_init_zero : Flag<["-"], 
"enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
-  Flags<[NoArgumentUnused]>,
-  Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
+  Flags<[NoArgumentUnused]>, Visibility<[ClangOption, CC1Option, CLOption]>,
   Group;
 
 // Group that ignores all gcc optimizations that won't be implemented
@@ -1079,7 +1077,7 @@ def config_user_dir_EQ : Joined<["--"], 
"config-user-dir=">,
   Visibility<[ClangOption, CLOption, DXCOption]>,
   HelpText<"User directory for configuration files">;
 def coverage : Flag<["-", "--"], "coverage">, Group,
-  Visibility<[ClangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, CLOption]>;
 def cpp_precomp : Flag<["-"], "cpp-precomp">, Group;
 def current__version : JoinedOrSeparate<["-"], "current_version">;
 def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group,
@@ -1449,7 +1447,7 @@ defm assume_unique_vtables : 
BoolFOption<"assume-unique-vtables",
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption, CLOption, DXCOption]>>;
+  BothFlags<[], [ClangOption, CLOption]>>;
 
 def fassume_sane_operator_new : Flag<["-"], "fassume-sane-operator-new">, 
Group;
 def fastcp : Flag<["-"], "fastcp">, Group;
@@ -1488,7 +1486,7 @@ defm coro_aligned_allocation : 
BoolFOption<"coro-aligned-allocation",
 
 defm experimental_library : BoolFOption<"experimental-library",
   LangOpts<"ExperimentalLibrary">, DefaultFalse,
-  PosFlag>;
 
 def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group,
-Visibility<[ClangOption, CLOption, DXCOption]>;
+Visibility<[ClangOption, CLOption]>;
 def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, 
Group,
-Visibility<[ClangOption, CLOption, DXCOption]>;
+Visibility<[ClangOption, CLOption]>;
 def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
 Group, Flags<[NoXarchOption]>,
 Visibility<[ClangOption, CC1Option]>,
@@ -1568,8 +1566,7 @@ def fdebug_compilation_dir : Separate<["-"], 
"fdebug-compilation-dir">,
 Visibility<[ClangOption, CC1Option, CC1AsOption, CLOption, DXCOption]>,
 Alias;
 def fcoverage_compilation_dir_EQ : Joined<["-"], "fcoverage-compilation-dir=">,
-Group,
-Visibility<[ClangOption, CC1Option, CC1AsOption, CLOption, DXCOption]>,
+Group, Visibility<[ClangOption, CC1Option, CC1AsOption, 
CLOption]>,
 HelpText<"The compilation directory to embed in the coverage mapping.">,
 MarshallingInfoString>;
 def ffile_compilation_dir_EQ : Joined<["-"], "ffile-compilation-dir=">, 
Group,
@@ -1581,19 +1578,18 @@ defm debug_info_for_profiling : 
BoolFOption<"debug-info-for-profiling",
   "Emit extra debug info to make sample profile more accurate">,
   NegFlag>;
 def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
-Group, Visibility<[ClangOption, CLOption, DXCOption]>,
+Group, Visibility<[ClangOption, CLOption]>,
 HelpText<"Generate instrumented code to collect execution counts into 
default.profraw file (overridden by '=' form of option or LLVM_PROFILE

[PATCH] D155610: [Clang][Sema] Fix display of characters on static assertion failure

2023-08-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16867-16868
 
+/// Convert character's code unit value to a string.
+/// The code point needs to be zero-extended to 32-bits.
+static void WriteCharValueForDiagnostic(uint32_t Value, const BuiltinType *BTy,

Suggest wording tweaks.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16894-16895
+if (llvm::ConvertCodePointToUTF8(Value, Ptr)) {
+  for (char *I = Arr; I != Ptr; ++I)
+OS << *I;
+} else {

Try using `StringRef`.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16897
+} else {
+  // FIXME: This assumes Unicode literal encodings
+  OS << "\\x"

Since the function interface has been clarified, this part actually doesn't 
need a FIXME. The FIXME should instead be added to the comment above the 
function declaration.


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

https://reviews.llvm.org/D155610

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


[PATCH] D157813: [VE][Clang] Change to enable VPU flag by default

2023-08-15 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 marked 3 inline comments as done.
kaz7 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:5166
+// VE feature flags
+let Flags = [TargetSpecific, CC1Option] in {
+def mvevpu : Flag<["-"], "mvevpu">, Group,

MaskRay wrote:
> Other feature group options  don't set CC1Option: we do not need them as CC1 
> options (e.g. `-Xclang -msse4`)
Thank you.  I was wondering which group options are required here.



Comment at: clang/include/clang/Driver/Options.td:5169
+  HelpText<"Emit VPU instructions for VE">;
+def mno_vevpu : Flag<["-"], "mno-vevpu">, Group,
+  HelpText<"Do not emit VPU instructions for VE">;

MaskRay wrote:
> In general, we just need documentation for the non-default option (let's say 
> `-mvevpu`). Documentation for the opposite `-mno-mvevpu` is just boilerplate 
> and not very useful.
I see.  Changed.



Comment at: clang/test/Driver/ve-features.c:1
+// RUN: %clang -target ve-unknown-linux-gnu -### %s -mvevpu 2>&1 | FileCheck 
%s -check-prefix=VEVPU
+// RUN: %clang -target ve-unknown-linux-gnu -### %s -mno-vevpu 2>&1 | 
FileCheck %s -check-prefix=NO-VEVPU

MaskRay wrote:
> `-target ` has been deprecated since Clang 3.4. Use `--target=`
I didn't know that.  Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

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


[PATCH] D157813: [VE][Clang] Change to enable VPU flag by default

2023-08-15 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 updated this revision to Diff 550588.
kaz7 added a comment.

Update to follow suggestions.  Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/VE.cpp
  clang/test/Driver/ve-features.c


Index: clang/test/Driver/ve-features.c
===
--- /dev/null
+++ clang/test/Driver/ve-features.c
@@ -0,0 +1,7 @@
+// RUN: %clang --target=ve-unknown-linux-gnu -### %s -mvevpu 2>&1 | FileCheck 
%s -check-prefix=VEVPU
+// RUN: %clang --target=ve-unknown-linux-gnu -### %s -mno-vevpu 2>&1 | 
FileCheck %s -check-prefix=NO-VEVPU
+// RUN: %clang --target=ve-unknown-linux-gnu -### %s 2>&1 | FileCheck %s 
-check-prefix=DEFAULT
+
+// VEVPU: "-target-feature" "+vpu"
+// NO-VEVPU-NOT: "-target-feature" "+vpu"
+// DEFAULT: "-target-feature" "+vpu"
Index: clang/lib/Driver/ToolChains/Arch/VE.cpp
===
--- clang/lib/Driver/ToolChains/Arch/VE.cpp
+++ clang/lib/Driver/ToolChains/Arch/VE.cpp
@@ -18,4 +18,17 @@
 using namespace llvm::opt;
 
 void ve::getVETargetFeatures(const Driver &D, const ArgList &Args,
- std::vector &Features) {}
+ std::vector &Features) {
+  // Defaults.
+  bool EnableVPU = true;
+
+  // Whether to enable VPU registers and isel.
+  if (auto *A = Args.getLastArg(options::OPT_mvevpu, options::OPT_mno_vevpu)) {
+if (A->getOption().matches(options::OPT_mno_vevpu))
+  EnableVPU = false;
+  }
+
+  // VVP
+  if (EnableVPU)
+Features.push_back("+vpu");
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -202,6 +202,8 @@
Group, Flags<[CoreOption]>, DocName<"X86">;
 def m_riscv_Features_Group : OptionGroup<"">,
  Group, DocName<"RISC-V">;
+def m_ve_Features_Group : OptionGroup<"">,
+  Group, DocName<"VE">;
 
 def m_libc_Group : OptionGroup<"">, Group,
Flags<[HelpHidden]>;
@@ -5160,6 +5162,13 @@
 def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, 
Group;
 } // let Flags = [TargetSpecific]
 
+// VE feature flags
+let Flags = [TargetSpecific] in {
+def mvevpu : Flag<["-"], "mvevpu">, Group,
+  HelpText<"Emit VPU instructions for VE">;
+def mno_vevpu : Flag<["-"], "mno-vevpu">, Group;
+} // let Flags = [TargetSpecific]
+
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag
 // style of double-dash and equals-joined flags.


Index: clang/test/Driver/ve-features.c
===
--- /dev/null
+++ clang/test/Driver/ve-features.c
@@ -0,0 +1,7 @@
+// RUN: %clang --target=ve-unknown-linux-gnu -### %s -mvevpu 2>&1 | FileCheck %s -check-prefix=VEVPU
+// RUN: %clang --target=ve-unknown-linux-gnu -### %s -mno-vevpu 2>&1 | FileCheck %s -check-prefix=NO-VEVPU
+// RUN: %clang --target=ve-unknown-linux-gnu -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+
+// VEVPU: "-target-feature" "+vpu"
+// NO-VEVPU-NOT: "-target-feature" "+vpu"
+// DEFAULT: "-target-feature" "+vpu"
Index: clang/lib/Driver/ToolChains/Arch/VE.cpp
===
--- clang/lib/Driver/ToolChains/Arch/VE.cpp
+++ clang/lib/Driver/ToolChains/Arch/VE.cpp
@@ -18,4 +18,17 @@
 using namespace llvm::opt;
 
 void ve::getVETargetFeatures(const Driver &D, const ArgList &Args,
- std::vector &Features) {}
+ std::vector &Features) {
+  // Defaults.
+  bool EnableVPU = true;
+
+  // Whether to enable VPU registers and isel.
+  if (auto *A = Args.getLastArg(options::OPT_mvevpu, options::OPT_mno_vevpu)) {
+if (A->getOption().matches(options::OPT_mno_vevpu))
+  EnableVPU = false;
+  }
+
+  // VVP
+  if (EnableVPU)
+Features.push_back("+vpu");
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -202,6 +202,8 @@
Group, Flags<[CoreOption]>, DocName<"X86">;
 def m_riscv_Features_Group : OptionGroup<"">,
  Group, DocName<"RISC-V">;
+def m_ve_Features_Group : OptionGroup<"">,
+  Group, DocName<"VE">;
 
 def m_libc_Group : OptionGroup<"">, Group,
Flags<[HelpHidden]>;
@@ -5160,6 +5162,13 @@
 def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, Group;
 } // let Flags = [TargetSpecific]
 
+// VE feature flags
+let Flags = [TargetSpecific] in {
+def mvevpu : Flag<["-"],

[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Yonggang Luo via Phabricator via cfe-commits
lygstate updated this revision to Diff 550587.
lygstate added a comment.

Revert to version 1


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

https://reviews.llvm.org/D157297

Files:
  clang/lib/Headers/bmiintrin.h


Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -19,7 +19,7 @@
to use it as a potentially faster version of BSF. */
 #define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 
-#define _tzcnt_u16(a) (__tzcnt_u16((a)))
+#define _tzcnt_u16 __tzcnt_u16
 
 /// Counts the number of trailing zero bits in the operand.
 ///
@@ -71,7 +71,7 @@
   return (int)__builtin_ia32_tzcnt_u32(__X);
 }
 
-#define _tzcnt_u32(a) (__tzcnt_u32((a)))
+#define _tzcnt_u32 __tzcnt_u32
 
 #ifdef __x86_64__
 
@@ -109,7 +109,7 @@
   return (long long)__builtin_ia32_tzcnt_u64(__X);
 }
 
-#define _tzcnt_u64(a) (__tzcnt_u64((a)))
+#define _tzcnt_u64 __tzcnt_u64
 
 #endif /* __x86_64__ */
 
@@ -121,14 +121,14 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("bmi")))
 
-#define _andn_u32(a, b)   (__andn_u32((a), (b)))
+#define _andn_u32 __andn_u32
 
 /* _bextr_u32 != __bextr_u32 */
-#define _blsi_u32(a)  (__blsi_u32((a)))
+#define _blsi_u32 __blsi_u32
 
-#define _blsmsk_u32(a)(__blsmsk_u32((a)))
+#define _blsmsk_u32 __blsmsk_u32
 
-#define _blsr_u32(a)  (__blsr_u32((a)))
+#define _blsr_u32 __blsr_u32
 
 /// Performs a bitwise AND of the second operand with the one's
 ///complement of the first operand.
@@ -272,14 +272,14 @@
 
 #ifdef __x86_64__
 
-#define _andn_u64(a, b)   (__andn_u64((a), (b)))
+#define _andn_u64 __andn_u64
 
 /* _bextr_u64 != __bextr_u64 */
-#define _blsi_u64(a)  (__blsi_u64((a)))
+#define _blsi_u64 __blsi_u64
 
-#define _blsmsk_u64(a)(__blsmsk_u64((a)))
+#define _blsmsk_u64 __blsmsk_u64
 
-#define _blsr_u64(a)  (__blsr_u64((a)))
+#define _blsr_u64 __blsr_u64
 
 /// Performs a bitwise AND of the second operand with the one's
 ///complement of the first operand.


Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -19,7 +19,7 @@
to use it as a potentially faster version of BSF. */
 #define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 
-#define _tzcnt_u16(a) (__tzcnt_u16((a)))
+#define _tzcnt_u16 __tzcnt_u16
 
 /// Counts the number of trailing zero bits in the operand.
 ///
@@ -71,7 +71,7 @@
   return (int)__builtin_ia32_tzcnt_u32(__X);
 }
 
-#define _tzcnt_u32(a) (__tzcnt_u32((a)))
+#define _tzcnt_u32 __tzcnt_u32
 
 #ifdef __x86_64__
 
@@ -109,7 +109,7 @@
   return (long long)__builtin_ia32_tzcnt_u64(__X);
 }
 
-#define _tzcnt_u64(a) (__tzcnt_u64((a)))
+#define _tzcnt_u64 __tzcnt_u64
 
 #endif /* __x86_64__ */
 
@@ -121,14 +121,14 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))
 
-#define _andn_u32(a, b)   (__andn_u32((a), (b)))
+#define _andn_u32 __andn_u32
 
 /* _bextr_u32 != __bextr_u32 */
-#define _blsi_u32(a)  (__blsi_u32((a)))
+#define _blsi_u32 __blsi_u32
 
-#define _blsmsk_u32(a)(__blsmsk_u32((a)))
+#define _blsmsk_u32 __blsmsk_u32
 
-#define _blsr_u32(a)  (__blsr_u32((a)))
+#define _blsr_u32 __blsr_u32
 
 /// Performs a bitwise AND of the second operand with the one's
 ///complement of the first operand.
@@ -272,14 +272,14 @@
 
 #ifdef __x86_64__
 
-#define _andn_u64(a, b)   (__andn_u64((a), (b)))
+#define _andn_u64 __andn_u64
 
 /* _bextr_u64 != __bextr_u64 */
-#define _blsi_u64(a)  (__blsi_u64((a)))
+#define _blsi_u64 __blsi_u64
 
-#define _blsmsk_u64(a)(__blsmsk_u64((a)))
+#define _blsmsk_u64 __blsmsk_u64
 
-#define _blsr_u64(a)  (__blsr_u64((a)))
+#define _blsr_u64 __blsr_u64
 
 /// Performs a bitwise AND of the second operand with the one's
 ///complement of the first operand.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D157297#4590692 , @lygstate wrote:

> In D157297#4590580 , @pengfei wrote:
>
>> 
>
>
>
>> I'd prefer macro to duplicated definitions. We have such precedents, e.g., 
>> https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/xmmintrin.h#L2994
>
> Do you means revert to the first version?

Yes.

>> Besides, you should update the summary as well.
>
> I don't know what kind of summary you want, I can give me that so I can 
> update it

A reliable source about double colon operator cannot resolve function with 
parentheses in C++ is the best I expect, however I haven't find one so far.
Maybe a short description about the phenomenon on GCC/Clang is better than just 
giving error message. I don't have strong request for this.


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

https://reviews.llvm.org/D157297

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


[PATCH] D158047: [clang][ASTImporter] Add import of 'BitIntType'

2023-08-15 Thread Timo Stripf via Phabricator via cfe-commits
strimo378 added a comment.

I think the ASTImporter class has in general a completion problem. What do you 
think about rewriting it that any missing Visit* function for Type, Decl and 
Stmt produces an compiler error?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158047

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


[PATCH] D158047: [clang][ASTImporter] Add import of 'BitIntType'

2023-08-15 Thread Timo Stripf via Phabricator via cfe-commits
strimo378 created this revision.
strimo378 added a reviewer: aaron.ballman.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
strimo378 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158047

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -583,6 +583,13 @@
   functionDecl(hasDescendant(typedefDecl(has(atomicType());
 }
 
+TEST_P(ImportType, ImportBitIntType) {
+  MatchVerifier Verifier;
+  testImport("void declToImport() { typedef _BitInt(10) bit_int; }", 
Lang_CXX11,
+ "", Lang_CXX11, Verifier,
+ functionDecl(hasDescendant(typedefDecl(has(bitIntType());
+}
+
 TEST_P(ImportType, ImportUsingType) {
   MatchVerifier Verifier;
   testImport("struct C {};"
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -419,6 +419,7 @@
 ExpectedType VisitObjCInterfaceType(const ObjCInterfaceType *T);
 ExpectedType VisitObjCObjectType(const ObjCObjectType *T);
 ExpectedType VisitObjCObjectPointerType(const ObjCObjectPointerType *T);
+ExpectedType VisitBitIntType(const BitIntType *T);
 
 // Importing declarations
 Error ImportDeclParts(NamedDecl *D, DeclarationName &Name, NamedDecl *&ToD,
@@ -1701,6 +1702,11 @@
   return Importer.getToContext().getObjCObjectPointerType(*ToPointeeTypeOrErr);
 }
 
+ExpectedType clang::ASTNodeImporter::VisitBitIntType(const BitIntType *T) {
+  return Importer.getToContext().getBitIntType(T->isUnsigned(),
+   T->getNumBits());
+}
+
 //
 // Import Declarations
 //
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7025,6 +7025,16 @@
 AST_TYPELOC_TRAVERSE_MATCHER_DECL(hasValueType, getValue,
   AST_POLYMORPHIC_SUPPORTED_TYPES(AtomicType));
 
+/// Matches bitint types.
+///
+/// Given
+/// \code
+///   _BitInt(10) i;
+/// \endcode
+/// bitIntType()
+///   matches "_BitInt(10) i"
+extern const AstTypeMatcher bitIntType;
+
 /// Matches types nodes representing C++11 auto types.
 ///
 /// Given:


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -583,6 +583,13 @@
   functionDecl(hasDescendant(typedefDecl(has(atomicType());
 }
 
+TEST_P(ImportType, ImportBitIntType) {
+  MatchVerifier Verifier;
+  testImport("void declToImport() { typedef _BitInt(10) bit_int; }", Lang_CXX11,
+ "", Lang_CXX11, Verifier,
+ functionDecl(hasDescendant(typedefDecl(has(bitIntType());
+}
+
 TEST_P(ImportType, ImportUsingType) {
   MatchVerifier Verifier;
   testImport("struct C {};"
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -419,6 +419,7 @@
 ExpectedType VisitObjCInterfaceType(const ObjCInterfaceType *T);
 ExpectedType VisitObjCObjectType(const ObjCObjectType *T);
 ExpectedType VisitObjCObjectPointerType(const ObjCObjectPointerType *T);
+ExpectedType VisitBitIntType(const BitIntType *T);
 
 // Importing declarations
 Error ImportDeclParts(NamedDecl *D, DeclarationName &Name, NamedDecl *&ToD,
@@ -1701,6 +1702,11 @@
   return Importer.getToContext().getObjCObjectPointerType(*ToPointeeTypeOrErr);
 }
 
+ExpectedType clang::ASTNodeImporter::VisitBitIntType(const BitIntType *T) {
+  return Importer.getToContext().getBitIntType(T->isUnsigned(),
+   T->getNumBits());
+}
+
 //
 // Import Declarations
 //
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7025,6 +7025,16 @@
 AST_TYPELOC_TRAVERSE_MATCHER_DECL(hasValueType, getValue,
 

[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Yonggang Luo via Phabricator via cfe-commits
lygstate added a comment.

In D157297#4590580 , @pengfei wrote:

> 



> I'd prefer macro to duplicated definitions. We have such precedents, e.g., 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/xmmintrin.h#L2994

Do you means revert to the first version?

> Besides, you should update the summary as well.

I don't know what kind of summary you want, I can give me that so I can update 
it


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

https://reviews.llvm.org/D157297

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


[PATCH] D158046: [X86] Support -march=gracemont

2023-08-15 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe created this revision.
Herald added subscribers: Enna1, pengfei, hiraditya.
Herald added a project: All.
FreddyYe requested review of this revision.
Herald added projects: clang, Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits.

gracemont has some different tuning features from alderlake.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158046

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/test/CodeGen/attr-cpuspecific-cpus.c
  clang/test/CodeGen/attr-target-mv.c
  clang/test/CodeGen/target-builtin-noerror.c
  clang/test/Driver/x86-march.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/predefined-arch-macros.c
  compiler-rt/lib/builtins/cpu_model.c
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/Host.cpp
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -36,6 +36,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=arrowlake-s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=arrowlake_s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=lunarlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=gracemont 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -98,6 +99,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=arrowlake-s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=arrowlake_s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=lunarlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=gracemont 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 define void @foo() {
   ret void
Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -430,6 +430,8 @@
   { {"arrowlake_s"}, CK_ArrowlakeS, FEATURE_AVX2, FeaturesArrowlakeS, 'p', true },
   // Lunarlake microarchitecture based processors.
   { {"lunarlake"}, CK_Lunarlake, FEATURE_AVX2, FeaturesArrowlakeS, 'p', false },
+  // Gracemont microarchitecture based processors.
+  { {"gracemont"}, CK_Gracemont, FEATURE_AVX2, FeaturesAlderlake, 'p', false },
   // Sierraforest microarchitecture based processors.
   { {"sierraforest"}, CK_Sierraforest, FEATURE_AVX2, FeaturesSierraforest, 'p', false },
   // Grandridge microarchitecture based processors.
Index: llvm/lib/TargetParser/Host.cpp
===
--- llvm/lib/TargetParser/Host.cpp
+++ llvm/lib/TargetParser/Host.cpp
@@ -822,6 +822,8 @@
 // Alderlake:
 case 0x97:
 case 0x9a:
+// Gracemont
+case 0xbe:
 // Raptorlake:
 case 0xb7:
 case 0xba:
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1200,6 +1200,18 @@
   list ADLFeatures =
 !listconcat(TRMFeatures, ADLAdditionalFeatures);
 
+  // Gracemont
+  list GRTTuning = [TuningMacroFusion,
+  TuningSlow3OpsLEA,
+  TuningSlowDivide32,
+  TuningSlowDivide64,
+  TuningFastScalarFSQRT,
+  TuningFastVectorFSQRT,
+  TuningFast15ByteNOP,
+  TuningFastVariablePerLaneShuffle,
+  TuningPOPCNTFalseDeps,
+  TuningInsertVZEROUPPER];
+
   // Sierraforest
   list SRFAdditionalFeatures = [FeatureCMPCCXADD,
   FeatureAVXIFMA,
@@ -1721,6 +1733,9 @@
 ProcessorFeatures.SPRFeatures, ProcessorFeatures.SPRTuning>;
 def : ProcModel<"alderlake", AlderlakePModel,
 ProcessorFeatures.ADLFeatures, Pro

[PATCH] D152793: [RISCV] Add MC layer support for Zicfiss.

2023-08-15 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 updated this revision to Diff 550578.
fakepaper56 added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152793

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/zicfiss-invalid.s
  llvm/test/MC/RISCV/zicfiss-valid.s

Index: llvm/test/MC/RISCV/zicfiss-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zicfiss-valid.s
@@ -0,0 +1,110 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zicfiss,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zicfiss,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zicfiss,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfiss -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zicfiss,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfiss -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv32 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: ssload ra
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload x1
+
+# CHECK-ASM-AND-OBJ: ssload ra
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload ra
+
+# CHECK-ASM-AND-OBJ: ssload t0
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload x5
+
+# CHECK-ASM-AND-OBJ: ssload t0
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload t0
+
+# CHECK-ASM-AND-OBJ: sspopchk ra
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk x1
+
+# CHECK-ASM-AND-OBJ: sspopchk ra
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk ra
+
+# CHECK-ASM-AND-OBJ: sspopchk t0
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk x5
+
+# CHECK-ASM-AND-OBJ: sspopchk t0
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk t0
+
+# CHECK-ASM-AND-OBJ: sspinc 4
+# CHECK-ASM: encoding: [0x73,0x40,0xd2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspinc 4
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush x1
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush ra
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush x5
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush t0
+
+# CHECK-ASM-AND-OBJ: ssprr ra
+# CHECK-ASM: encoding: [0xf3,0x40,0x00,0x86]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssprr ra
+
+# CHECK-ASM-AND-OBJ: ssamoswap t0, zero, (a0)
+# CHECK-ASM: encoding: [0xf3,0x42,0x05,0x82]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssamoswap t0, x0, (a0)
+
+# CHECK-ASM-AND-OBJ: c.sspush ra
+# CHECK-ASM: encoding: [0x81,0x60]
+# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, exc

[PATCH] D158045: [clang][SVE] Rename isVLSTBuiltinType, NFC

2023-08-15 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan created this revision.
jacquesguan added reviewers: DavidTruby, efriedma, peterwaller-arm, 
paulwalker-arm, bsmith, c-rhodes, sdesmalen, rsandifo-arm, ctetreau, 
cameron.mcinally, aaron.ballman.
Herald added a subscriber: psnobl.
Herald added a project: All.
jacquesguan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Since we also have VLST for rvv now, it is not clear to keep using 
`isVLSTBuiltinType`, so I added prefix SVE to it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158045

Files:
  clang/include/clang/AST/Type.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp

Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8363,7 +8363,7 @@
   }
 
   // Attribute can only be attached to a single SVE vector or predicate type.
-  if (!CurType->isVLSTBuiltinType()) {
+  if (!CurType->isSVEVLSTBuiltinType()) {
 S.Diag(Attr.getLoc(), diag::err_attribute_invalid_sve_type)
 << Attr << CurType;
 Attr.setInvalid();
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6305,7 +6305,7 @@
 
 static bool isValidSizelessVectorForConditionalCondition(ASTContext &Ctx,
  QualType CondTy) {
-  if (!CondTy->isVLSTBuiltinType())
+  if (!CondTy->isSVEVLSTBuiltinType())
 return false;
   const QualType EltTy =
   cast(CondTy.getCanonicalType())->getSveEltType(Ctx);
@@ -6417,10 +6417,10 @@
 
   QualType LHSType = LHS.get()->getType();
   const auto *LHSBT =
-  LHSType->isVLSTBuiltinType() ? LHSType->getAs() : nullptr;
+  LHSType->isSVEVLSTBuiltinType() ? LHSType->getAs() : nullptr;
   QualType RHSType = RHS.get()->getType();
   const auto *RHSBT =
-  RHSType->isVLSTBuiltinType() ? RHSType->getAs() : nullptr;
+  RHSType->isSVEVLSTBuiltinType() ? RHSType->getAs() : nullptr;
 
   QualType ResultType;
 
@@ -6462,7 +6462,7 @@
 RHS = ImpCastExprToType(RHS.get(), ResultType, CK_VectorSplat);
   }
 
-  assert(!ResultType.isNull() && ResultType->isVLSTBuiltinType() &&
+  assert(!ResultType.isNull() && ResultType->isSVEVLSTBuiltinType() &&
  "Result should have been a vector type");
   auto *ResultBuiltinTy = ResultType->castAs();
   QualType ResultElementTy = ResultBuiltinTy->getSveEltType(Context);
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14827,7 +14827,7 @@
 
   // Strip vector types.
   if (isa(Source)) {
-if (Target->isVLSTBuiltinType() &&
+if (Target->isSVEVLSTBuiltinType() &&
 (S.Context.areCompatibleSveTypes(QualType(Target, 0),
  QualType(Source, 0)) ||
  S.Context.areLaxCompatibleSveTypes(QualType(Target, 0),
@@ -14878,7 +14878,7 @@
   const BuiltinType *TargetBT = dyn_cast(Target);
 
   // Strip SVE vector types
-  if (SourceBT && SourceBT->isVLSTBuiltinType()) {
+  if (SourceBT && SourceBT->isSVEVLSTBuiltinType()) {
 // Need the original target type for vector type checks
 const Type *OriginalTarget = S.Context.getCanonicalType(T).getTypePtr();
 // Handle conversion from scalable to fixed when msve-vector-bits is
@@ -14897,7 +14897,7 @@
 Source = SourceBT->getSveEltType(S.Context).getTypePtr();
   }
 
-  if (TargetBT && TargetBT->isVLSTBuiltinType())
+  if (TargetBT && TargetBT->isSVEVLSTBuiltinType())
 Target = TargetBT->getSveEltType(S.Context).getTypePtr();
 
   // If the source is floating point...
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -1798,7 +1798,7 @@
   // careful, because the base of a vector subscript is occasionally an rvalue,
   // so we can't get it as an lvalue.
   if (!E->getBase()->getType()->isVectorType() &&
-  !E->getBase()->getType()->isVLSTBuiltinType())
+  !E->getBase()->getType()->isSVEVLSTBuiltinType())
 return EmitLoadOfLValue(E);
 
   // Handle the vector case.  The base must be a vector, the index must be an
@@ -4858,7 +4858,7 @@
   }
 
   if (condExpr->getType()->isVectorType() ||
-  condExpr->getType()->isVLSTBuiltinType()) {
+  condExpr->getType()->isSVEVLSTBuiltinType()) {
 CGF.incrementProfileCounter(E);
 
 llvm::Value *CondV = CGF.EmitScalarExpr(condExpr);
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ cla

[PATCH] D151730: [RISCV] Support target attribute for function

2023-08-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:417
+  continue;
+} else if (Feature.startswith("no-"))
+  Ret.Features.push_back("-" + Feature.split("-").second.str());

Is this tested? I don't see any "no-" in the the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151730

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


[PATCH] D152423: [RISCV] Add function that check extension name with version

2023-08-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D152423/new/

https://reviews.llvm.org/D152423

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


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

I'd prefer macro to duplicated definitions. We have such precedents, e.g., 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/xmmintrin.h#L2994
Besides, you should update the summary as well.


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

https://reviews.llvm.org/D157297

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


[PATCH] D152793: [RISCV] Add MC layer support for Zicfiss.

2023-08-15 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td:88
+
+let Predicates = [HasStdExtZicfiss, HasStdExtC] in {
+let Uses = [SSP], Defs = [SSP], hasSideEffects = 0, mayLoad = 0, mayStore = 1 
in

craig.topper wrote:
> Is it compatible with Zca?
The spec does not mention it is incompatible with Zca. I think I need to enable 
c.push/c.popchk for Zca.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152793

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


[PATCH] D157362: [RISCV] Add MC layer support for Zicfilp.

2023-08-15 Thread Yeting Kuo via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG818e76d6f2dd: [RISCV] Add MC layer support for Zicfilp. 
(authored by fakepaper56).

Changed prior to commit:
  https://reviews.llvm.org/D157362?vs=550089&id=550562#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157362

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/zicfilp-invalid.s
  llvm/test/MC/RISCV/zicfilp-valid.s

Index: llvm/test/MC/RISCV/zicfilp-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zicfilp-valid.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zicfilp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zicfilp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zicfilp < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfilp -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zicfilp < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfilp -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv32 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: lpad 22
+# CHECK-ASM: auipc zero, 22
+# CHECK-ASM: encoding: [0x17,0x60,0x01,0x00]
+# CHECK-NO-EXT: instruction requires the following: 'Zicfilp' (Landing pad)
+lpad 22
Index: llvm/test/MC/RISCV/zicfilp-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zicfilp-invalid.s
@@ -0,0 +1,7 @@
+# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zicfilp -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 -mattr=+experimental-zicfilp -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-NO-EXT: immediate must be an integer in the range [0, 1048575]
+lpad 1048576
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -299,3 +299,6 @@
 
 .attribute arch, "rv32i_xcvbi"
 # CHECK: attribute  5, "rv32i2p1_xcvbi1p0"
+
+.attribute arch, "rv32i_zicfilp0p2"
+# CHECK: attribute  5, "rv32i2p1_zicfilp0p2"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -86,6 +86,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFMIN %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFWMA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zacas %s -o - | FileCheck --check-prefix=RV32ZACAS %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zicfilp %s -o - | FileCheck --check-prefix=RV32ZICFILP %s
 
 ; RUN: llc -mtriple=riscv64 %s -o - | FileCheck %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefixes=CHECK,RV64M %s
@@ -174,6 +175,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFMIN %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFWMA %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zacas %s -o - | FileCheck --check-prefix=RV64ZACAS %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zicfilp %s -o - | FileCheck --check-prefix=RV64ZICFILP %s
 
 ; CHECK: .attribute 4, 16
 
@@ -262,6 +264,7 @@
 ; RV32ZVFBFMIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin0p8_zve32f1p0_zve32x1p0_zvfbfmin0p8_zvl32b1p0"
 ; RV32ZVFBFWMA: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin0p8_zve32f1p0_zve32x1p0_zvfbfmin0p8_zvfbfwma0p8_zvl32b1p0"
 ; RV32ZACAS: .attribute 5, "rv32i2p1_a2p1_zacas1p0"
+; RV32ZICFILP: .attribute 5, "rv32i2p1_zicfilp0p2"
 
 ; RV64M: .attribute 5, "rv64i2p1_m2p0"
 ; RV64ZMMUL: .attribute 5, "rv64i2p1_zmmul1p0"
@@ -349,6 +352,7 @@
 ; RV64ZVFBFMIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_z

[clang] 818e76d - [RISCV] Add MC layer support for Zicfilp.

2023-08-15 Thread Yeting Kuo via cfe-commits

Author: Yeting Kuo
Date: 2023-08-16T08:52:51+08:00
New Revision: 818e76d6f2dd90362e71e84f492c167958ef3257

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

LOG: [RISCV] Add MC layer support for Zicfilp.

This adds extension Zicfilp and support pseudo instruction lpad.

Reviewed By: craig.topper

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

Added: 
llvm/test/MC/RISCV/zicfilp-invalid.s
llvm/test/MC/RISCV/zicfilp-valid.s

Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/MC/RISCV/attribute-arch.s

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 3f91d0d99f2290..c2722fb34a1a72 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -71,6 +71,7 @@
 // CHECK-NOT: __riscv_zvfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zvfbfwma {{.*$}}
 // CHECK-NOT: __riscv_zacas {{.*$}}
+// CHECK-NOT: __riscv_zicfilp {{.*$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
 // RUN: -o - | FileCheck %s
@@ -774,3 +775,11 @@
 // RUN: -march=rv64i_zacas1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
 // CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp0p2 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFILP-EXT %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64i_zicfilp0p2 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFILP-EXT %s
+// CHECK-ZICFILP-EXT: __riscv_zicfilp 2000{{$}}

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 4d319fc6dc6a4b..51d5c2922c6dde 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -202,6 +202,9 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-zfbfmin``, ``experimental-zvfbfmin``, ``experimental-zvfbfwma``
   LLVM implements assembler support for the `0.8.0 draft specification 
`_.
 
+``experimental-zicfilp``
+  LLVM implements the `0.2 draft specification 
`__.
+
 ``experimental-zicond``
   LLVM implements the `1.0-rc1 draft specification 
`__.
 

diff  --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 007166a518cb3c..594b8ba28424dd 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -168,6 +168,7 @@ static const RISCVSupportedExtension 
SupportedExperimentalExtensions[] = {
 {"zfa", RISCVExtensionVersion{0, 2}},
 {"zfbfmin", RISCVExtensionVersion{0, 8}},
 
+{"zicfilp", RISCVExtensionVersion{0, 2}},
 {"zicond", RISCVExtensionVersion{1, 0}},
 
 {"ztso", RISCVExtensionVersion{0, 1}},

diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 6ef7f1078aa3ca..ce1d3f53ffe6f7 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -660,6 +660,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
   bool isUImm6() const { return IsUImm<6>(); }
   bool isUImm7() const { return IsUImm<7>(); }
   bool isUImm8() const { return IsUImm<8>(); }
+  bool isUImm20() const { return IsUImm<20>(); }
 
   bool isUImm8GE32() const {
 int64_t Imm;
@@ -1478,6 +1479,8 @@ bool RISCVAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, 
unsigned &Opcode,
   "operand must be a symbol with "
   "%hi/%tprel_hi modifier or an integer in 
"
   "the range");
+  case Match_InvalidUImm20:
+return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 20) - 1);
   case Match_InvalidUImm20AUIPC:
 return generateImmOutOfRangeError(
 Operands, ErrorInfo, 0, (1 << 20) - 1,

diff  --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index fb33b1e3a6d5f1..8cce9dc4742b92 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -648,6 +648,13 @@ def FeatureStdExtZvksg
"other extensions: Zvks and Zvkg.",
[FeatureStdExtZ

[PATCH] D157829: [clang-tidy] Added a new option to lambda-function-name to ignore warnings in macro expansion

2023-08-15 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 added a comment.

HI @PiotrZSL, I do not have the rights to commit to the LLVM repository. Could 
you please commit those changes for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157829

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


[PATCH] D157829: [clang-tidy] Added a new option to lambda-function-name to ignore warnings in macro expansion

2023-08-15 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 updated this revision to Diff 550559.
felix642 added a comment.

Updated format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157829

Files:
  clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s bugprone-lambda-function-name %t
+// RUN: %check_clang_tidy -check-suffixes=,NO-CONFIG %s bugprone-lambda-function-name %t
+// RUN: %check_clang_tidy %s bugprone-lambda-function-name %t -- -config="{CheckOptions: [{key: bugprone-lambda-function-name.IgnoreMacros, value: true}]}" --
+
 
 void Foo(const char* a, const char* b, int c) {}
 
@@ -12,11 +14,11 @@
   [] { __FUNCTION__; }();
   // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { FUNC_MACRO; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { FUNCTION_MACRO; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { EMBED_IN_ANOTHER_MACRO1; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
 }
 
 #define FUNC_MACRO_WITH_FILE_AND_LINE Foo(__func__, __FILE__, __LINE__)
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
@@ -25,3 +25,11 @@
 
   Called from FancyFunction
   Now called from FancyFunction
+
+Options
+---
+
+.. option::  IgnoreMacros
+
+  The value `true` specifies that attempting to get the name of a function from
+  within a macro should not be diagnosed. The default value is `false`.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -173,6 +173,10 @@
   `, so that it does not warn
   on macros starting with underscore and lowercase letter.
 
+- Improved :doc:`bugprone-lambda-function-name
+  ` check by adding option
+  `IgnoreMacros` to ignore warnings in macros.
+
 - Improved :doc:`cppcoreguidelines-avoid-non-const-global-variables
   ` check
   to ignore ``static`` variables declared within the scope of
Index: clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
@@ -31,8 +31,9 @@
   };
   using SourceRangeSet = std::set;
 
-  LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context);
+
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP

[PATCH] D158006: [Clang][WIP]Experimental implementation of data member packs in dependent context.

2023-08-15 Thread Denis Nikitin via Phabricator via cfe-commits
denik added inline comments.



Comment at: clang/lib/Sema/SemaExprMember.cpp:528-529
+if (Field->getDeclName() == NameInfo.getName()) {
+  if (const PackExpansionType *PET =
+  dyn_cast(Field->getType())) {
+isMemberPack = true;

if (isa(Field->getType())) { ...



Comment at: clang/lib/Sema/SemaExprMember.cpp:1018
   if (R.empty()) {
+// The member is expaned from member pack if its name has `@` in it. In 
this
+// case a failed name lookup is not an error, but represents it's at the 
end

expanded



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:3289
+  // Rename the expanded fields to avoid ambiguous names in
+  // name lookup. The renamed fields need to be invisible to users so 
an
+  // `@` is added to the name.

nit: Maybe `inaccessible by`?



Comment at: clang/lib/Sema/TreeTransform.h:4177
+   "trying to expand non-pack member access");
+std::string UnExpanedNameStr =
+MemberExpr->getMemberNameInfo().getName().getAsString();

Expanded



Comment at: clang/lib/Sema/TreeTransform.h:4198-4199
+  MemberExpr->getMemberNameInfo().getInfo());
+  TemplateArgumentListInfo TemplateArgs = TemplateArgumentListInfo();
+  MemberExpr->copyTemplateArgumentsInto(TemplateArgs);
+  auto *ExpandedMemberExpr = CXXDependentScopeMemberExpr::Create(

Why is this in a loop?



Comment at: clang/lib/Sema/TreeTransform.h:4208
+
+  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), Arg);
+  ExprResult Out = getDerived().TransformExpr(ExpandedMemberExpr);

Can we add a check that Arg never exceeds the number of arguments in the full 
expansion (is it Expansion->getNumExpansions()?)



Comment at: clang/test/CodeGenCXX/data_member_packs.cpp:76
+  // CHECK: double @_Z3sumIJilfdEEDaDpT_(i32 noundef %ts, i64 noundef %ts1, 
float noundef %ts3, double noundef %ts5)
+  S4{}.sum_pack(s7);
+  return 0;

This is a good test case!
I would also add a test for the partial expansion of the member pack. And also 
checking the right order of the fields. Something like:
```
template constexpr auto foo(T t) { return t; }
template constexpr auto foo(T t, Ts ... ts) { 
return t + 2 * foo(ts...); }

S1 s = {1,2,3};
static_assert(foo(s.ts...) == 17);
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158006

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


[PATCH] D157767: [Driver] move Haiku header search path management to the driver

2023-08-15 Thread Brad Smith via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa2c701b5dc0: [Driver] move Haiku header search path 
management to the driver (authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157767

Files:
  clang/lib/Driver/ToolChains/Haiku.cpp
  clang/lib/Driver/ToolChains/Haiku.h
  clang/lib/Lex/InitHeaderSearch.cpp

Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -279,42 +279,6 @@
 AddPath(P, System, false);
 break;
   }
-
-  case llvm::Triple::Haiku:
-AddPath("/boot/system/non-packaged/develop/headers", System, false);
-AddPath("/boot/system/develop/headers/os", System, false);
-AddPath("/boot/system/develop/headers/os/app", System, false);
-AddPath("/boot/system/develop/headers/os/arch", System, false);
-AddPath("/boot/system/develop/headers/os/device", System, false);
-AddPath("/boot/system/develop/headers/os/drivers", System, false);
-AddPath("/boot/system/develop/headers/os/game", System, false);
-AddPath("/boot/system/develop/headers/os/interface", System, false);
-AddPath("/boot/system/develop/headers/os/kernel", System, false);
-AddPath("/boot/system/develop/headers/os/locale", System, false);
-AddPath("/boot/system/develop/headers/os/mail", System, false);
-AddPath("/boot/system/develop/headers/os/media", System, false);
-AddPath("/boot/system/develop/headers/os/midi", System, false);
-AddPath("/boot/system/develop/headers/os/midi2", System, false);
-AddPath("/boot/system/develop/headers/os/net", System, false);
-AddPath("/boot/system/develop/headers/os/opengl", System, false);
-AddPath("/boot/system/develop/headers/os/storage", System, false);
-AddPath("/boot/system/develop/headers/os/support", System, false);
-AddPath("/boot/system/develop/headers/os/translation", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/graphics", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/input_server", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/mail_daemon", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/registrar", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/screen_saver", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/tracker", System, false);
-AddPath("/boot/system/develop/headers/os/be_apps/Deskbar", System, false);
-AddPath("/boot/system/develop/headers/os/be_apps/NetPositive", System, false);
-AddPath("/boot/system/develop/headers/os/be_apps/Tracker", System, false);
-AddPath("/boot/system/develop/headers/3rdparty", System, false);
-AddPath("/boot/system/develop/headers/bsd", System, false);
-AddPath("/boot/system/develop/headers/glibc", System, false);
-AddPath("/boot/system/develop/headers/posix", System, false);
-AddPath("/boot/system/develop/headers",  System, false);
-break;
   case llvm::Triple::RTEMS:
 break;
   case llvm::Triple::Win32:
@@ -388,6 +352,7 @@
   case llvm::Triple::PS4:
   case llvm::Triple::PS5:
   case llvm::Triple::Fuchsia:
+  case llvm::Triple::Haiku:
   case llvm::Triple::Hurd:
   case llvm::Triple::Linux:
   case llvm::Triple::Solaris:
Index: clang/lib/Driver/ToolChains/Haiku.h
===
--- clang/lib/Driver/ToolChains/Haiku.h
+++ clang/lib/Driver/ToolChains/Haiku.h
@@ -26,6 +26,9 @@
 return getTriple().getArch() == llvm::Triple::x86_64;
   }
 
+  void AddClangSystemIncludeArgs(
+  const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
   void addLibCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
Index: clang/lib/Driver/ToolChains/Haiku.cpp
===
--- clang/lib/Driver/ToolChains/Haiku.cpp
+++ clang/lib/Driver/ToolChains/Haiku.cpp
@@ -8,6 +8,8 @@
 
 #include "Haiku.h"
 #include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -21,6 +23,70 @@
 
 }
 
+void Haiku::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const {
+  const Driver &D = getDriver();
+
+  if (DriverArgs.hasArg(options::OPT_nostdinc))
+return;
+
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+SmallString<128> Dir(D.ResourceDir);
+llvm::sys::path::append(Dir, "include");
+addSystemInclude(DriverArgs, CC1Args, Dir.str());
+  }
+
+  if (DriverArgs.hasArg(options::OPT_no

[clang] aa2c701 - [Driver] move Haiku header search path management to the driver

2023-08-15 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-08-15T19:58:40-04:00
New Revision: aa2c701b5dc04330b8ec4084a94d7cbe9cc938eb

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

LOG: [Driver] move Haiku header search path management to the driver

Also while here sync the header paths with the Haiku GCC configuration.

Added: /boot/system/develop/headers/gnu
Removed: /boot/system/develop/headers/os/arch

https://github.com/haikuports/haikuports/tree/master/sys-devel/gcc/patches

Reviewed By: nielx

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Haiku.cpp
clang/lib/Driver/ToolChains/Haiku.h
clang/lib/Lex/InitHeaderSearch.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Haiku.cpp 
b/clang/lib/Driver/ToolChains/Haiku.cpp
index a79f0f7622addc..201b80177d7512 100644
--- a/clang/lib/Driver/ToolChains/Haiku.cpp
+++ b/clang/lib/Driver/ToolChains/Haiku.cpp
@@ -8,6 +8,8 @@
 
 #include "Haiku.h"
 #include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -21,6 +23,70 @@ Haiku::Haiku(const Driver &D, const llvm::Triple& Triple, 
const ArgList &Args)
 
 }
 
+void Haiku::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const 
{
+  const Driver &D = getDriver();
+
+  if (DriverArgs.hasArg(options::OPT_nostdinc))
+return;
+
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+SmallString<128> Dir(D.ResourceDir);
+llvm::sys::path::append(Dir, "include");
+addSystemInclude(DriverArgs, CC1Args, Dir.str());
+  }
+
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  // Add dirs specified via 'configure --with-c-include-dirs'.
+  StringRef CIncludeDirs(C_INCLUDE_DIRS);
+  if (!CIncludeDirs.empty()) {
+SmallVector dirs;
+CIncludeDirs.split(dirs, ":");
+for (StringRef dir : dirs) {
+  StringRef Prefix =
+llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
+}
+return;
+  }
+
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/non-packaged/develop/headers");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/app");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/device");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/drivers");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/game");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/interface");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/kernel");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/locale");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/mail");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/media");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/midi");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/midi2");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/net");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/opengl");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/storage");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/support");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/translation");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/add-ons/graphics");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/add-ons/input_server");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/add-ons/mail_daemon");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/add-ons/registrar");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/add-ons/screen_saver");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/add-ons/tracker");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/be_apps/Deskbar");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/heade

[clang] 1e4d612 - [CMake] Add a few more missing dependencies on ClangDriverOptions

2023-08-15 Thread Jon Roelofs via cfe-commits

Author: Jon Roelofs
Date: 2023-08-15T16:56:31-07:00
New Revision: 1e4d6122cda6529781ecf467c2ae84e5dd41acdf

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

LOG: [CMake] Add a few more missing dependencies on ClangDriverOptions

This often breaks modules-enabled bootstrap builds.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
clang/tools/clang-fuzzer/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
index 5293f5e0a522d0..0326798e3a1748 100644
--- a/clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
@@ -26,4 +26,5 @@ add_clang_library(clangStaticAnalyzerFrontend
 
   DEPENDS
   omp_gen
+  ClangDriverOptions
   )

diff  --git a/clang/tools/clang-fuzzer/CMakeLists.txt 
b/clang/tools/clang-fuzzer/CMakeLists.txt
index e68ed8bbcb0694..2b9720ee627cb1 100644
--- a/clang/tools/clang-fuzzer/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/CMakeLists.txt
@@ -115,6 +115,9 @@ add_clang_executable(clang-fuzzer
   EXCLUDE_FROM_ALL
   ${DUMMY_MAIN}
   ClangFuzzer.cpp
+
+  DEPENDS
+  ClangDriverOptions
   )
 
 target_link_libraries(clang-fuzzer
@@ -127,6 +130,9 @@ add_clang_executable(clang-objc-fuzzer
   EXCLUDE_FROM_ALL
   ${DUMMY_MAIN}
   ClangObjectiveCFuzzer.cpp
+
+  DEPENDS
+  ClangDriverOptions
   )
 
 target_link_libraries(clang-objc-fuzzer



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


[PATCH] D74094: Reapply: [IRGen] Emit lifetime intrinsics around temporary aggregate argument allocas

2023-08-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74094

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


[PATCH] D152793: [RISCV] Add MC layer support for Zicfiss.

2023-08-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td:32
+
+class RVC_SSInst rs1, RegisterClass reg_class, string opcodestr> :
+  RVInst16<(outs), (ins reg_class:$rs1), opcodestr, "$rs1", [], 
InstFormatOther> {

Can you call this `rs1val` instead of `rs1` since $rs1 is part of the ins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152793

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


[PATCH] D152793: [RISCV] Add MC layer support for Zicfiss.

2023-08-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td:88
+
+let Predicates = [HasStdExtZicfiss, HasStdExtC] in {
+let Uses = [SSP], Defs = [SSP], hasSideEffects = 0, mayLoad = 0, mayStore = 1 
in

Is it compatible with Zca?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152793

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


[PATCH] D157331: [clang] Implement C23

2023-08-15 Thread Zijun Zhao via Phabricator via cfe-commits
ZijunZhao updated this revision to Diff 550547.
ZijunZhao added a comment.

1. rename to .c file
2. create clang/test/C/C2x/n2683.c and add codegen tests and semantic tests
3. update clang/docs/ReleseNotes.rst
4. update clang/www/c_status.html
5. reformat PPDirectives.cpp
6. set __STDC_VERSION__ instead of gnu


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/stdckdint.h
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/test/C/C2x/n2683.c
  clang/test/Headers/stdckdint.c
  clang/test/Modules/Inputs/System/usr/include/module.map
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -886,6 +886,11 @@
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2672.pdf";>N2672
   Yes
 
+
+  Towards Integer Safety
+  https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2683.pdf";>N2683
+  Clang 18
+
 
   Adding Fundamental Type for N-bit Integers
 
Index: clang/test/Modules/Inputs/System/usr/include/module.map
===
--- clang/test/Modules/Inputs/System/usr/include/module.map
+++ clang/test/Modules/Inputs/System/usr/include/module.map
@@ -14,6 +14,11 @@
 header "stdbool.h"
   }
 
+  // In both directories (compiler support version wins, does not forward)
+  module stdckdint {
+header "stdckdint.h"
+  }
+
   // In both directories (compiler support version wins, forwards)
   module stdint {
 header "stdint.h"
Index: clang/test/Headers/stdckdint.c
===
--- /dev/null
+++ clang/test/Headers/stdckdint.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -emit-llvm -verify -fgnuc-version=4.2.1 -std=c23 %s -o - | FileCheck %s
+// expected-no-diagnostics
+#include 
+
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add() #0 {
+// CHECK:  entry:
+// CHECK:%result = alloca i32, align 4
+// CHECK:%0 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 -1073741826, i32 -1073741826)
+// CHECK:%1 = extractvalue { i32, i1 } %0, 1
+// CHECK:%2 = extractvalue { i32, i1 } %0, 0
+// CHECK:store i32 %2, ptr %result, align 4
+// CHECK:ret i1 %1
+// CHECK:}
+// CHECK:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+// CHECK:declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #1
+bool test_ckd_add() {
+  int result;
+  return ckd_add(&result, -1073741826, -1073741826);
+}
+
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_sub() #0 {
+// CHECK:  entry:
+// CHECK:%result = alloca i32, align 4
+// CHECK:%0 = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 -1073741826, i32 1073741826)
+// CHECK:%1 = extractvalue { i32, i1 } %0, 1
+// CHECK:%2 = extractvalue { i32, i1 } %0, 0
+// CHECK:store i32 %2, ptr %result, align 4
+// CHECK:ret i1 %1
+// CHECK:}
+// CHECK:declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) #1
+bool test_ckd_sub() {
+  int result;
+  return ckd_sub(&result, -1073741826, 1073741826);
+}
+
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_mul() #0 {
+// CHECK:  entry:
+// CHECK:%result = alloca i32, align 4
+// CHECK:%0 = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 -1073741826, i32 2)
+// CHECK:%1 = extractvalue { i32, i1 } %0, 1
+// CHECK:%2 = extractvalue { i32, i1 } %0, 0
+// CHECK:store i32 %2, ptr %result, align 4
+// CHECK:ret i1 %1
+// CHECK:}
+// CHECK:declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) #1
+bool test_ckd_mul() {
+  int result;
+  return ckd_mul(&result, -1073741826, 2);
+}
Index: clang/test/C/C2x/n2683.c
===
--- /dev/null
+++ clang/test/C/C2x/n2683.c
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -ffreestanding -std=c23 %s
+// RUN: %clang_cc1 -verify -emit-llvm -o - -std=c23 %s | FileCheck %s
+
+/* WG14 N2683: Clang 18
+ * Define several macros for performing checked integer arithmetic
+ */
+#include 
+#include 
+
+// CHECK-LABEL: define dso_local void @test_add_overflow_to64() #0 {
+// CHECK:  entry:
+// CHECK:%result64 = alloca i64, align 8
+// CHECK:%flag_add = alloca i8, align 1
+// CHECK:store i64 0, ptr %result64, align 8
+// CHECK:%0 = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 2147483647, i64 1)
+// CHECK:%1 = extractvalue { i64, i1 } %0, 1 
+// CHECK:%2 = extractvalue { i64, i1 } %0, 0
+// CHECK:store i64 %2, ptr %result64, align 8
+// CHECK:%frombool = zext i1 %1 to i8
+// CHECK:store i8 %frombool, ptr %flag_add, align 1
+// CHECK:ret void
+// CHECK:  }
+void test_add_overflow_to64() {
+int64_t result64 = 0;
+bo

[PATCH] D157362: [RISCV] Add MC layer support for Zicfilp.

2023-08-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D157362/new/

https://reviews.llvm.org/D157362

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


[PATCH] D157582: [Driver][DXC] Handle -Fo and -Fc flags

2023-08-15 Thread Justin Bogner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb6fe61be3de: [Driver][DXC] Handle -Fo and -Fc flags 
(authored by bogner).

Changed prior to commit:
  https://reviews.llvm.org/D157582?vs=548879&id=550545#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157582

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.def
  clang/include/clang/Driver/Types.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/lib/Driver/Types.cpp
  clang/test/Driver/dxc_dxv_path.hlsl
  clang/test/Driver/dxc_output.hlsl
  llvm/lib/MC/MCParser/AsmParser.cpp

Index: llvm/lib/MC/MCParser/AsmParser.cpp
===
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -807,7 +807,7 @@
 PlatformParser.reset(createXCOFFAsmParser());
 break;
   case MCContext::IsDXContainer:
-llvm_unreachable("DXContainer is not supported yet");
+report_fatal_error("DXContainer is not supported yet");
 break;
   }
 
Index: clang/test/Driver/dxc_output.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_output.hlsl
@@ -0,0 +1,42 @@
+// With no output args, we emit assembly to stdout.
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-CC1,CHECK-CC1-STDOUT
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -ccc-print-phases 2>&1 | FileCheck %s --check-prefixes=CHECK-PHASES,CHECK-PHASES-ASM
+
+// Same if we explicitly ask for assembly (-Fc) to stdout.
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -Fc - -### 2>&1 | FileCheck %s --check-prefixes=CHECK-CC1,CHECK-CC1-STDOUT
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -Fc - -ccc-print-phases 2>&1 | FileCheck %s --check-prefixes=CHECK-PHASES,CHECK-PHASES-ASM
+
+// DXIL Assembly to a file.
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -Fc x.asm -### 2>&1 | FileCheck %s --check-prefixes=CHECK-CC1,CHECK-CC1-ASM
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -Fcx.asm -### 2>&1 | FileCheck %s --check-prefixes=CHECK-CC1,CHECK-CC1-ASM
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -Fc x.asm -ccc-print-phases 2>&1 | FileCheck %s --check-prefixes=CHECK-PHASES,CHECK-PHASES-ASM
+
+// DXIL Object code to a file.
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -Fo x.obj -### 2>&1 | FileCheck %s --check-prefixes=CHECK-CC1,CHECK-CC1-OBJ
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -Fox.obj -### 2>&1 | FileCheck %s --check-prefixes=CHECK-CC1,CHECK-CC1-OBJ
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -Fo x.obj -ccc-print-phases 2>&1 | FileCheck %s --check-prefixes=CHECK-PHASES,CHECK-PHASES-OBJ
+
+// If both -Fc and -Fo are provided, we generate both files.
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -Fc x.asm -Fo x.obj -### 2>&1 | FileCheck %s --check-prefixes=CHECK-CC1,CHECK-CC1-ASM,CHECK-CC1-BOTH
+// RUN: %clang_dxc -T lib_6_7 -Vd %s -Fc x.asm -Fo x.obj -ccc-print-phases 2>&1 | FileCheck %s --check-prefixes=CHECK-PHASES,CHECK-PHASES-OBJ
+
+// CHECK-PHASES: 0: input, {{.*}}, hlsl
+// CHECK-PHASES: 1: preprocessor, {0}, c++-cpp-output
+// CHECK-PHASES: 2: compiler, {1}, ir
+// CHECK-PHASES: 3: backend, {2}, assembler
+// CHECK-PHASES-ASM-NOT: 4: assembler, {3}, object
+// CHECK-PHASES-OBJ: 4: assembler, {3}, object
+
+// CHECK-CC1: "-cc1"
+// CHECK-CC1-STDOUT-SAME: "-o" "-"
+
+// CHECK-CC1-ASM-SAME: "-S"
+// CHECK-CC1-ASM-SAME: "-o" "x.asm"
+
+// CHECK-CC1-OBJ-SAME: "-emit-obj"
+// CHECK-CC1-OBJ-SAME: "-o" "x.obj"
+
+// For the case where we specify both -Fc and -Fo, we emit the asm as part of
+// cc1 and invoke cc1as for the object.
+// CHECK-CC1-BOTH: "-cc1as"
+// CHECK-CC1-BOTH-SAME: "-o" "x.obj"
Index: clang/test/Driver/dxc_dxv_path.hlsl
===
--- clang/test/Driver/dxc_dxv_path.hlsl
+++ clang/test/Driver/dxc_dxv_path.hlsl
@@ -12,7 +12,7 @@
 
 // RUN: %clang_dxc -Tlib_6_3 -ccc-print-bindings --dxv-path=%T -Fo %t.dxo  %s 2>&1 | FileCheck %s --check-prefix=BINDINGS
 // BINDINGS: "dxil-unknown-shadermodel6.3-library" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[DXC:.+]].dxo"
-// BINDINGS-NEXT: "dxil-unknown-shadermodel6.3-library" - "hlsl::Validator", inputs: ["[[DXC]].dxo"], output: "[[DXC]].dxo"
+// BINDINGS-NEXT: "dxil-unknown-shadermodel6.3-library" - "hlsl::Validator", inputs: ["[[DXC]].dxo"]
 
 // RUN: %clang_dxc -Tlib_6_3 -ccc-print-phases --dxv-path=%T -Fo %t.dxc  %s 2>&1 | FileCheck %s --check-prefix=PHASES
 
@@ -20,4 +20,5 @@
 // PHASES-NEXT: 1: preprocessor, {0}, c++-cpp-output
 // PHASES-NEXT: 2: compiler, {1}, ir
 // PHASES-NEXT: 3: backend, {2}, assembler
-// PHASES-NEXT: 4: binary-analyzer, {3}, dx-container
+// PHASES-NEXT: 4: assembler, {3}, object
+// PHASES-NEXT: 5: binary-analyzer, {4}, dx-container
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/

[clang] cb6fe61 - [Driver][DXC] Handle -Fo and -Fc flags

2023-08-15 Thread Justin Bogner via cfe-commits

Author: Justin Bogner
Date: 2023-08-15T16:37:17-07:00
New Revision: cb6fe61be3dee67bb8b080c73dd2c48f2d0ce2c7

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

LOG: [Driver][DXC] Handle -Fo and -Fc flags

This splits the backend and assemble actions for HLSL inputs and
handles the options in GetNamedOutputPath instead of aliasing `-o`.
This also moves how we default to emitting asm to stdout, since doing
this in the HLSL toolchain rather than the driver pollutes how the
clang driver works as well.

When both options are specified we disable collapsing the assemble
action and attempt to generate both outputs. Note that while this
handles the driver aspects, we can't actually run in that mode for now
since -cc1as doesn't understand DXIL as an input yet.

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

Added: 
clang/test/Driver/dxc_output.hlsl

Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/Types.def
clang/include/clang/Driver/Types.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/HLSL.cpp
clang/lib/Driver/Types.cpp
clang/test/Driver/dxc_dxv_path.hlsl
llvm/lib/MC/MCParser/AsmParser.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e0c5c6c0c2ff49..4ba3b237b80e58 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8146,8 +8146,10 @@ class DXCJoinedOrSeparate : Option<["/", 
"-"], name,
 
 def dxc_no_stdinc : DXCFlag<"hlsl-no-stdinc">,
   HelpText<"HLSL only. Disables all standard includes containing non-native 
compiler types and functions.">;
-def Fo : DXCJoinedOrSeparate<"Fo">, Alias,
+def dxc_Fo : DXCJoinedOrSeparate<"Fo">,
   HelpText<"Output object file">;
+def dxc_Fc : DXCJoinedOrSeparate<"Fc">,
+  HelpText<"Output assembly listing file">;
 def dxil_validator_version : Option<["/", "-"], "validator-version", 
KIND_SEPARATE>,
   Group, Flags<[NoXarchOption, HelpHidden]>,
   Visibility<[DXCOption, ClangOption, CC1Option]>,

diff  --git a/clang/include/clang/Driver/Types.def 
b/clang/include/clang/Driver/Types.def
index aaea3ec0f9c888..519d51f8ad1e5f 100644
--- a/clang/include/clang/Driver/Types.def
+++ b/clang/include/clang/Driver/Types.def
@@ -54,7 +54,7 @@ TYPE("objective-c++-cpp-output", PP_ObjCXX,INVALID,   
  "mii",phases
 TYPE("objc++-cpp-output",PP_ObjCXX_Alias, INVALID,  "mii",
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("objective-c++",ObjCXX,   PP_ObjCXX,   "mm", 
phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, 
phases::Link)
 TYPE("renderscript", RenderScript, PP_C,"rs", 
phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, 
phases::Link)
-TYPE("hlsl", HLSL, PP_CXX,  "hlsl",   
phases::Preprocess, phases::Compile, phases::Backend)
+TYPE("hlsl", HLSL, PP_CXX,  "hlsl",   
phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble)
 
 // C family input files to precompile.
 TYPE("c-header-cpp-output",  PP_CHeader,   INVALID, "i",  
phases::Precompile)

diff  --git a/clang/include/clang/Driver/Types.h 
b/clang/include/clang/Driver/Types.h
index 4a21af3534deba..121b58a6b477d9 100644
--- a/clang/include/clang/Driver/Types.h
+++ b/clang/include/clang/Driver/Types.h
@@ -43,7 +43,7 @@ namespace types {
 
   /// getTypeTempSuffix - Return the suffix to use when creating a
   /// temp file of this type, or null if unspecified.
-  const char *getTypeTempSuffix(ID Id, bool CLMode = false);
+  const char *getTypeTempSuffix(ID Id, bool CLStyle = false);
 
   /// onlyPrecompileType - Should this type only be precompiled.
   bool onlyPrecompileType(ID Id);

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 3947ae949014d7..ede9967d8cef26 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -484,6 +484,10 @@ DerivedArgList *Driver::TranslateInputArgs(const 
InputArgList &Args) const {
 DAL->append(A);
   }
 
+  // DXC mode quits before assembly if an output object file isn't specified.
+  if (IsDXCMode() && !Args.hasArg(options::OPT_dxc_Fo))
+DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_S));
+
   // Enforce -static if -miamcu is present.
   if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false))
 DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_static));
@@ -5023,7 +5027,8 @@ class ToolSelector final {
 return TC.useIntegratedAs() && !SaveTemps &&
!C.getArgs().hasArg(options::OPT_via_file_asm) &&
!C.getArgs().hasArg(options::OPT__SLASH_FA

[PATCH] D158037: [Driver][DXC] Remove a bunch of options from DXC

2023-08-15 Thread Justin Bogner via Phabricator via cfe-commits
bogner created this revision.
bogner added reviewers: beanz, python3kgae.
Herald added a subscriber: mcrosier.
Herald added a reviewer: sscalpone.
Herald added a project: All.
bogner requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove DXCOption from a whole bunch of options that we probably won't
support in the DXC driver. The initial clang-dxc support just made
everything that was a "CoreOption" available, regardless of whether it
made sense. Here I don't remove all of them, but this makes a dent on
making the list a bit more sensible. We can easily add or remove more
if they make sense later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158037

Files:
  clang/include/clang/Driver/Options.td

Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -195,8 +195,7 @@
 def m_wasm_Features_Driver_Group : OptionGroup<"">,
Group, DocName<"WebAssembly Driver">;
 def m_x86_Features_Group : OptionGroup<"">,
-   Group,
-   Visibility<[ClangOption, CLOption, DXCOption]>,
+   Group, Visibility<[ClangOption, CLOption]>,
DocName<"X86">;
 def m_riscv_Features_Group : OptionGroup<"">,
  Group, DocName<"RISC-V">;
@@ -274,8 +273,7 @@
 // Retired with clang-16.0, to provide a deprecation period; it should
 // be removed in Clang 18 or later.
 def enable_trivial_var_init_zero : Flag<["-"], "enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
-  Flags<[NoArgumentUnused]>,
-  Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
+  Flags<[NoArgumentUnused]>, Visibility<[ClangOption, CC1Option, CLOption]>,
   Group;
 
 // Group that ignores all gcc optimizations that won't be implemented
@@ -1079,7 +1077,7 @@
   Visibility<[ClangOption, CLOption, DXCOption]>,
   HelpText<"User directory for configuration files">;
 def coverage : Flag<["-", "--"], "coverage">, Group,
-  Visibility<[ClangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, CLOption]>;
 def cpp_precomp : Flag<["-"], "cpp-precomp">, Group;
 def current__version : JoinedOrSeparate<["-"], "current_version">;
 def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group,
@@ -1449,7 +1447,7 @@
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption, CLOption, DXCOption]>>;
+  BothFlags<[], [ClangOption, CLOption]>>;
 
 def fassume_sane_operator_new : Flag<["-"], "fassume-sane-operator-new">, Group;
 def fastcp : Flag<["-"], "fastcp">, Group;
@@ -1488,7 +1486,7 @@
 
 defm experimental_library : BoolFOption<"experimental-library",
   LangOpts<"ExperimentalLibrary">, DefaultFalse,
-  PosFlag>;
 
 def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group,
-Visibility<[ClangOption, CLOption, DXCOption]>;
+Visibility<[ClangOption, CLOption]>;
 def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, Group,
-Visibility<[ClangOption, CLOption, DXCOption]>;
+Visibility<[ClangOption, CLOption]>;
 def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
 Group, Flags<[NoXarchOption]>,
 Visibility<[ClangOption, CC1Option]>,
@@ -1568,8 +1566,7 @@
 Visibility<[ClangOption, CC1Option, CC1AsOption, CLOption, DXCOption]>,
 Alias;
 def fcoverage_compilation_dir_EQ : Joined<["-"], "fcoverage-compilation-dir=">,
-Group,
-Visibility<[ClangOption, CC1Option, CC1AsOption, CLOption, DXCOption]>,
+Group, Visibility<[ClangOption, CC1Option, CC1AsOption, CLOption]>,
 HelpText<"The compilation directory to embed in the coverage mapping.">,
 MarshallingInfoString>;
 def ffile_compilation_dir_EQ : Joined<["-"], "ffile-compilation-dir=">, Group,
@@ -1581,19 +1578,18 @@
   "Emit extra debug info to make sample profile more accurate">,
   NegFlag>;
 def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
-Group, Visibility<[ClangOption, CLOption, DXCOption]>,
+Group, Visibility<[ClangOption, CLOption]>,
 HelpText<"Generate instrumented code to collect execution counts into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var)">;
 def fprofile_instr_generate_EQ : Joined<["-"], "fprofile-instr-generate=">,
-Group, Visibility<[ClangOption, CLOption, DXCOption]>,
-MetaVarName<"">,
+Group, Visibility<[ClangOption, CLOption]>, MetaVarName<"">,
 HelpText<"Generate instrumented code to collect execution counts into  (overridden by LLVM_PROFILE_FILE env var)">;
 def fprofile_instr_use : Flag<["-"], "fprofile-instr-use">, Group,
-Visibility<[ClangOption, CLOption, DXCOption]>;
+Visibility<[ClangOption, CLOption]>;
 def fprofile_instr_use_EQ : Joined<["-"], "fprofile-instr-use=">,
-Group, Visibility<[ClangOption, CLOptio

[PATCH] D155419: [Clang][CMake] Add CSSPGO support to LLVM_BUILD_INSTRUMENTED

2023-08-15 Thread Amir Ayupov via Phabricator via cfe-commits
Amir updated this revision to Diff 550532.
Amir added a comment.

Append to PGO_OPT


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155419

Files:
  clang/CMakeLists.txt
  clang/cmake/caches/CSSPGO.cmake
  clang/utils/perf-training/CMakeLists.txt
  clang/utils/perf-training/lit.cfg
  clang/utils/perf-training/lit.site.cfg.in
  clang/utils/perf-training/perf-helper.py
  llvm/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake

Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1071,7 +1071,7 @@
 option(LLVM_ENABLE_IR_PGO "Build LLVM and tools with IR PGO instrumentation (deprecated)" Off)
 mark_as_advanced(LLVM_ENABLE_IR_PGO)
 
-set(LLVM_BUILD_INSTRUMENTED OFF CACHE STRING "Build LLVM and tools with PGO instrumentation. May be specified as IR or Frontend")
+set(LLVM_BUILD_INSTRUMENTED OFF CACHE STRING "Build LLVM and tools with PGO instrumentation. May be specified as IR, Frontend, CSIR, CSSPGO")
 set(LLVM_VP_COUNTERS_PER_SITE "1.5" CACHE STRING "Value profile counters to use per site for IR PGO with Clang")
 mark_as_advanced(LLVM_BUILD_INSTRUMENTED LLVM_VP_COUNTERS_PER_SITE)
 string(TOUPPER "${LLVM_BUILD_INSTRUMENTED}" uppercase_LLVM_BUILD_INSTRUMENTED)
@@ -1104,6 +1104,15 @@
 CMAKE_EXE_LINKER_FLAGS
 CMAKE_SHARED_LINKER_FLAGS)
 endif()
+  elseif(uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "CSSPGO")
+append("-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fpseudo-probe-for-profiling"
+  CMAKE_CXX_FLAGS
+  CMAKE_C_FLAGS)
+if(NOT LINKER_IS_LLD_LINK)
+  append("-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fpseudo-probe-for-profiling"
+CMAKE_EXE_LINKER_FLAGS
+CMAKE_SHARED_LINKER_FLAGS)
+endif()
   else()
 append("-fprofile-instr-generate=\"${LLVM_PROFILE_FILE_PATTERN}\""
   CMAKE_CXX_FLAGS
@@ -1154,6 +1163,21 @@
   endif()
 endif()
 
+if(LLVM_SPROFDATA_FILE AND EXISTS ${LLVM_SPROFDATA_FILE})
+  if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
+append("-fpseudo-probe-for-profiling -fprofile-sample-use=\"${LLVM_SPROFDATA_FILE}\""
+  CMAKE_CXX_FLAGS
+  CMAKE_C_FLAGS)
+if(NOT LINKER_IS_LLD_LINK)
+  append("-fpseudo-probe-for-profiling -fprofile-sample-use=\"${LLVM_SPROFDATA_FILE}\""
+CMAKE_EXE_LINKER_FLAGS
+CMAKE_SHARED_LINKER_FLAGS)
+endif()
+  else()
+message(FATAL_ERROR "LLVM_SPROFDATA_FILE can only be specified when compiling with clang")
+  endif()
+endif()
+
 option(LLVM_BUILD_INSTRUMENTED_COVERAGE "Build LLVM and tools with Code Coverage instrumentation" Off)
 mark_as_advanced(LLVM_BUILD_INSTRUMENTED_COVERAGE)
 append_if(LLVM_BUILD_INSTRUMENTED_COVERAGE "-fprofile-instr-generate=\"${LLVM_PROFILE_FILE_PATTERN}\" -fcoverage-mapping"
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -849,6 +849,9 @@
 set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
   "Profiling data file to use when compiling in order to improve runtime performance.")
 
+set(LLVM_SPROFDATA_FILE "" CACHE FILEPATH
+  "Sampling profiling data file to use when compiling in order to improve runtime performance.")
+
 if(LLVM_INCLUDE_TESTS)
   # Lit test suite requires at least python 3.6
   set(LLVM_MINIMUM_PYTHON_VERSION 3.6)
Index: clang/utils/perf-training/perf-helper.py
===
--- clang/utils/perf-training/perf-helper.py
+++ clang/utils/perf-training/perf-helper.py
@@ -69,11 +69,15 @@
 
 def perf(args):
 parser = argparse.ArgumentParser(
-prog="perf-helper perf", description="perf wrapper for BOLT profile collection"
+prog="perf-helper perf",
+description="perf wrapper for BOLT/CSSPGO profile collection"
 )
 parser.add_argument(
 "--lbr", action="store_true", help="Use perf with branch stacks"
 )
+parser.add_argument(
+"--call-graph", action="store_true", help="Collect call graph"
+)
 parser.add_argument("cmd", nargs="*", help="")
 
 # Use python's arg parser to handle all leading option arguments, but pass
@@ -93,6 +97,8 @@
 ]
 if opts.lbr:
 perf_args += ["--branch-filter=any,u"]
+if opts.call_graph:
+perf_args += ["--call-graph=fp"]
 perf_args.extend(cmd)
 
 start_time = time.time()
@@ -130,6 +136,26 @@
 return 0
 
 
+def perf2prof(args):
+parser = argparse.ArgumentParser(
+prog="perf-helper perf2prof",
+description="perf to CSSPGO prof conversion wrapper",
+)
+parser.add_argument("profgen", help="Path to llvm-profgen binary")
+parser.add_argument("binary", help="Input binary")
+parser.add_argument("path

[PATCH] D150262: Disable sanitizer's on ifunc resolvers.

2023-08-15 Thread Farzon Lotfi via Phabricator via cfe-commits
farzon added a comment.

I feel like this change will break our use case and do so in a nontransparent 
way. We want to be able to use sanitizers even if IFUNC indirection is defined.

So if the compiler toolchain is now going to disable santizer instrumentation 
overriding the preferences of the person building the software then that is 
going to regress https://bugs.chromium.org/p/chromium/issues/detail?id=1454613 
again and make it so we can't fuzz on arm64.

Instead can we not just fail the build? That way the CI will be the enforcer 
and the next developer that comes along will have to create a happy path to 
support sanitizer builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150262

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


[PATCH] D157334: [clang] Define _MSC_EXTENSIONS on -gnu if -fms-extensions is set

2023-08-15 Thread Aiden Grossman via Phabricator via cfe-commits
aidengrossman updated this revision to Diff 550529.
aidengrossman added a comment.

Hoist _MSC_EXTENSIONS macro logic even further and add release note on chages.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157334

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/predefined-win-macros.c


Index: clang/test/Preprocessor/predefined-win-macros.c
===
--- clang/test/Preprocessor/predefined-win-macros.c
+++ clang/test/Preprocessor/predefined-win-macros.c
@@ -120,6 +120,11 @@
 // CHECK-AMD64-MINGW: #define _WIN32 1
 // CHECK-AMD64-MINGW: #define _WIN64 1
 
+// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - -fms-extensions \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW-MSE
+
+// CHECK-AMD64-MINGW-MSE: #define _MSC_EXTENSIONS 1
+
 // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW
 
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -926,11 +926,19 @@
 Builder.defineMacro("__private_extern__", "extern");
 
   if (LangOpts.MicrosoftExt) {
+Builder.defineMacro("_MSC_EXTENSIONS");
+
 if (LangOpts.WChar) {
   // wchar_t supported as a keyword.
   Builder.defineMacro("_WCHAR_T_DEFINED");
   Builder.defineMacro("_NATIVE_WCHAR_T_DEFINED");
 }
+
+if (LangOpts.CPlusPlus11) {
+  Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED");
+  Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED");
+  Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED");
+}
   }
 
   // Macros to help identify the narrow and wide character sets
Index: clang/lib/Basic/Targets/OSTargets.cpp
===
--- clang/lib/Basic/Targets/OSTargets.cpp
+++ clang/lib/Basic/Targets/OSTargets.cpp
@@ -226,16 +226,6 @@
 }
   }
 
-  if (Opts.MicrosoftExt) {
-Builder.defineMacro("_MSC_EXTENSIONS");
-
-if (Opts.CPlusPlus11) {
-  Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED");
-  Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED");
-  Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED");
-}
-  }
-
   if (!Opts.MSVolatile)
 Builder.defineMacro("_ISO_VOLATILE");
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -110,6 +110,9 @@
 
 Modified Compiler Flags
 ---
+- ``-fms-extensions`` now defines the ``_MSC_EXTENSIONS`` macro regardless of
+  whether or not the ``-fms-compatibility`` flag is set and regardless of the
+  target triple.
 
 Removed Compiler Flags
 -


Index: clang/test/Preprocessor/predefined-win-macros.c
===
--- clang/test/Preprocessor/predefined-win-macros.c
+++ clang/test/Preprocessor/predefined-win-macros.c
@@ -120,6 +120,11 @@
 // CHECK-AMD64-MINGW: #define _WIN32 1
 // CHECK-AMD64-MINGW: #define _WIN64 1
 
+// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - -fms-extensions \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW-MSE
+
+// CHECK-AMD64-MINGW-MSE: #define _MSC_EXTENSIONS 1
+
 // RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW
 
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -926,11 +926,19 @@
 Builder.defineMacro("__private_extern__", "extern");
 
   if (LangOpts.MicrosoftExt) {
+Builder.defineMacro("_MSC_EXTENSIONS");
+
 if (LangOpts.WChar) {
   // wchar_t supported as a keyword.
   Builder.defineMacro("_WCHAR_T_DEFINED");
   Builder.defineMacro("_NATIVE_WCHAR_T_DEFINED");
 }
+
+if (LangOpts.CPlusPlus11) {
+  Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED");
+  Builder.defineMacro("_RVALUE_REFERENCES_SUPPORTED");
+  Builder.defineMacro("_NATIVE_NULLPTR_SUPPORTED");
+}
   }
 
   // Macros to help identify the narrow and wide character sets
Index: clang/lib/Basic/Targets/OSTargets.cpp
===
--- clang/lib/Basic/Targets/OSTargets.cpp
+++ clang/lib/Basic/Targets/OSTargets.cpp
@@ -226,16 +226,6 @@
 }
   }
 
-  if (Opts.MicrosoftExt) {
-Builder.defineMacro("_MSC_EXTENSIONS");
-
-if (Opts.CPlusPlus11) {
-  Builder.defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED

[PATCH] D155647: [RISCV] Add C intrinsics for scalar bitmanip and crypto

2023-08-15 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu added a comment.

LGTM, But waiting for other reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155647

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


[clang] 95ab1cd - [Driver][DXC] Use the existing help and macro definition options. NFC

2023-08-15 Thread Justin Bogner via cfe-commits

Author: Justin Bogner
Date: 2023-08-15T16:04:50-07:00
New Revision: 95ab1cd712c27fc0c56f7b88a53e95e6e714ff36

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

LOG: [Driver][DXC] Use the existing help and macro definition options. NFC

Rather than redefine --help, /help, -D, and /D, just use the existing
options.

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d8d11497ea11e1..e0c5c6c0c2ff49 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -777,7 +777,7 @@ def C : Flag<["-"], "C">, Visibility<[ClangOption, 
CC1Option]>,
 HelpText<"Include comments in preprocessed output">,
 MarshallingInfoFlag>;
 def D : JoinedOrSeparate<["-"], "D">, Group,
-Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
+Visibility<[ClangOption, CC1Option, FlangOption, FC1Option, DXCOption]>,
 MetaVarName<"=">,
 HelpText<"Define  to  (or 1 if  omitted)">;
 def E : Flag<["-"], "E">, Flags<[NoXarchOption]>,
@@ -4058,7 +4058,8 @@ def gno_embed_source : Flag<["-"], "gno-embed-source">, 
Group,
 HelpText<"Restore the default behavior of not embedding source text in 
DWARF debug sections">;
 def headerpad__max__install__names : Joined<["-"], 
"headerpad_max_install_names">;
 def help : Flag<["-", "--"], "help">,
-Visibility<[ClangOption, CC1Option, CC1AsOption, FC1Option, FlangOption]>,
+Visibility<[ClangOption, CC1Option, CC1AsOption,
+FC1Option, FlangOption, DXCOption]>,
 HelpText<"Display available options">,
 MarshallingInfoFlag>;
 def ibuiltininc : Flag<["-"], "ibuiltininc">, Group,
@@ -7665,8 +7666,8 @@ def _SLASH_diagnostics_column : 
CLFlag<"diagnostics:column">,
   HelpText<"Disable caret diagnostics but keep column info">;
 def _SLASH_diagnostics_classic : CLFlag<"diagnostics:classic">,
   HelpText<"Disable column and caret diagnostics">;
-def _SLASH_D : CLJoinedOrSeparate<"D">, HelpText<"Define macro">,
-  MetaVarName<"">, Alias;
+def _SLASH_D : CLJoinedOrSeparate<"D", [CLOption, DXCOption]>,
+  HelpText<"Define macro">, MetaVarName<"">, Alias;
 def _SLASH_E : CLFlag<"E">, HelpText<"Preprocess to stdout">, Alias;
 def _SLASH_external_COLON_I : CLJoinedOrSeparate<"external:I">, Alias,
   HelpText<"Add directory to include search path with warnings suppressed">,
@@ -7705,7 +7706,7 @@ def _SLASH_Gw : CLFlag<"Gw">, HelpText<"Put each data 
item in its own section">,
 def _SLASH_Gw_ : CLFlag<"Gw-">,
   HelpText<"Do not put each data item in its own section (default)">,
   Alias;
-def _SLASH_help : CLFlag<"help">, Alias,
+def _SLASH_help : CLFlag<"help", [CLOption, DXCOption]>, Alias,
   HelpText<"Display available options">;
 def _SLASH_HELP : CLFlag<"HELP">, Alias;
 def _SLASH_hotpatch : CLFlag<"hotpatch">, Alias,
@@ -8143,10 +8144,6 @@ class DXCJoinedOrSeparate : Option<["/", 
"-"], name,
   KIND_JOINED_OR_SEPARATE>, Group, Flags<[NoXarchOption]>,
   Visibility<[DXCOption]>;
 
-def dxc_help : Option<["/", "-", "--"], "help", KIND_JOINED>,
-  Group, Flags<[NoXarchOption]>, Visibility<[DXCOption]>,
-  Alias,
-  HelpText<"Display available options">;
 def dxc_no_stdinc : DXCFlag<"hlsl-no-stdinc">,
   HelpText<"HLSL only. Disables all standard includes containing non-native 
compiler types and functions.">;
 def Fo : DXCJoinedOrSeparate<"Fo">, Alias,
@@ -8168,8 +8165,6 @@ def target_profile : DXCJoinedOrSeparate<"T">, 
MetaVarName<"">,
  "lib_6_3, lib_6_4, lib_6_5, lib_6_6, lib_6_7, lib_6_x,"
  "ms_6_5, ms_6_6, ms_6_7,"
  "as_6_5, as_6_6, as_6_7">;
-def dxc_D : Option<["--", "/", "-"], "D", KIND_JOINED_OR_SEPARATE>,
-  Group, Flags<[NoXarchOption]>, Visibility<[DXCOption]>, Alias;
 def emit_pristine_llvm : DXCFlag<"emit-pristine-llvm">,
   HelpText<"Emit pristine LLVM IR from the frontend by not running any LLVM 
passes at all."
"Same as -S + -emit-llvm + -disable-llvm-passes.">;



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


[PATCH] D157933: [OpenMP 5.1] Parsing and Sema support for `scope` construct

2023-08-15 Thread Fazlay Rabbi via Phabricator via cfe-commits
mdfazlay updated this revision to Diff 550521.
mdfazlay added a comment.

Updated nesting of  regions checks.


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

https://reviews.llvm.org/D157933

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/nesting_of_regions.cpp
  clang/test/OpenMP/scope_ast_print.cpp
  clang/test/OpenMP/scope_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -1979,6 +1979,15 @@
 def OMP_EndAssumes : Directive<"end assumes"> {}
 def OMP_BeginDeclareVariant : Directive<"begin declare variant"> {}
 def OMP_EndDeclareVariant : Directive<"end declare variant"> {}
+def OMP_scope : Directive<"scope"> {
+  let allowedClauses = [
+VersionedClause,
+VersionedClause,
+  ];
+  let allowedOnceClauses = [
+VersionedClause
+  ];
+}
 def OMP_ParallelWorkshare : Directive<"parallel workshare"> {
   let allowedClauses = [
 VersionedClause,
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -680,6 +680,9 @@
   case Stmt::OMPSectionDirectiveClass:
 K = CXCursor_OMPSectionDirective;
 break;
+  case Stmt::OMPScopeDirectiveClass:
+K = CXCursor_OMPScopeDirective;
+break;
   case Stmt::OMPSingleDirectiveClass:
 K = CXCursor_OMPSingleDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5889,6 +5889,8 @@
 return cxstring::createRef("OMPSectionsDirective");
   case CXCursor_OMPSectionDirective:
 return cxstring::createRef("OMPSectionDirective");
+  case CXCursor_OMPScopeDirective:
+return cxstring::createRef("OMPScopeDirective");
   case CXCursor_OMPSingleDirective:
 return cxstring::createRef("OMPSingleDirective");
   case CXCursor_OMPMasterDirective:
Index: clang/test/OpenMP/scope_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/scope_messages.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify=expected,omp51
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify=expected,omp51
+
+void test1()
+{
+  int var1;
+  int var2;
+  int var3 = 1;
+
+  // expected-error@+1 {{directive '#pragma omp scope' cannot contain more than one 'nowait' clause}} //omp51-error@+1{{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp scope'}}
+  #pragma omp scope private(var1) firstprivate(var3) nowait nowait
+  { var1 = 123; ++var2; var3 = 2;}
+}
Index: clang/test/OpenMP/scope_ast_print.cpp
===
--- /dev/null
+++ clang/test/OpenMP/scope_ast_print.cpp
@@ -0,0 +1,88 @@
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu\
+//RUN:   -fopenmp -fopenmp-version=51 \
+//RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions   \
+//RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses   \
+//RUN:   -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu\
+//RUN:   -fopenmp -fopenmp-version=51 \
+//RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions   \
+//RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses   \
+//RUN:   -ast-dump %s | FileCheck %s --check-prefix=DUMP
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu\
+//RUN:   -fopenmp -fopenmp-version=51 \
+//RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions   \
+//RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses   \
+//RUN:   -emit-pch -o %t %s
+
+//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu\
+//RUN:   -fopenmp -fopenmp-version=51 \
+//RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions   \
+//RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses   \
+//RUN:   -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
+
+//RUN: %clang_cc1 -triple 

[PATCH] D157452: [RFC][Clang][Codegen] `std::type_info` needs special care with explicit address spaces

2023-08-15 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 550516.
AlexVlx added a comment.

Remove unneeded cast, the dynamic case already emitted a generic pointer to 
`typeinfo`


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

https://reviews.llvm.org/D157452

Files:
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/typeid-cxx11-with-address-space.cpp
  clang/test/CodeGenCXX/typeid-with-address-space.cpp
  clang/test/CodeGenCXX/typeinfo
  clang/test/CodeGenCXX/typeinfo-with-address-space.cpp

Index: clang/test/CodeGenCXX/typeinfo-with-address-space.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/typeinfo-with-address-space.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -I%S %s -triple amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s -check-prefix=AS
+// RUN: %clang_cc1 -I%S %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s -check-prefix=NO-AS
+#include 
+
+class A {
+virtual void f() = 0;
+};
+
+class B : A {
+void f() override;
+};
+
+// AS: @_ZTISt9type_info = external addrspace(1) constant ptr addrspace(1)
+// NO-AS: @_ZTISt9type_info = external constant ptr
+// AS: @_ZTIi = external addrspace(1) constant ptr addrspace(1)
+// NO-AS: @_ZTIi = external constant ptr
+// AS: @_ZTVN10__cxxabiv117__class_type_infoE = external addrspace(1) global ptr addrspace(1)
+// NO-AS: @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr
+// AS: @_ZTS1A = linkonce_odr addrspace(1) constant [3 x i8] c"1A\00", comdat, align 1
+// NO-AS: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
+// AS: @_ZTI1A = linkonce_odr addrspace(1) constant { ptr addrspace(1), ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds (ptr addrspace(1), ptr addrspace(1) @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr addrspace(1) @_ZTS1A }, comdat, align 8
+// NO-AS: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1A }, comdat, align 8
+// AS: @_ZTIf = external addrspace(1) constant ptr addrspace(1)
+// NO-AS: @_ZTIf = external constant ptr
+
+unsigned long Fn(B& b) {
+// AS: %call = call noundef zeroext i1 @_ZNKSt9type_infoeqERKS_(ptr {{.*}} addrspacecast (ptr addrspace(1) @_ZTISt9type_info to ptr), ptr {{.*}} %2)
+// NO-AS: %call = call noundef zeroext i1 @_ZNKSt9type_infoeqERKS_(ptr {{.*}} @_ZTISt9type_info, ptr {{.*}} %2)
+if (typeid(std::type_info) == typeid(b))
+return 42;
+// AS: %call2 = call noundef zeroext i1 @_ZNKSt9type_infoneERKS_(ptr {{.*}} addrspacecast (ptr addrspace(1) @_ZTIi to ptr), ptr {{.*}} %5)
+// NO-AS: %call2 = call noundef zeroext i1 @_ZNKSt9type_infoneERKS_(ptr {{.*}} @_ZTIi, ptr {{.*}} %5)
+if (typeid(int) != typeid(b))
+return 1712;
+// AS: %call5 = call noundef ptr @_ZNKSt9type_info4nameEv(ptr {{.*}} addrspacecast (ptr addrspace(1) @_ZTI1A to ptr))
+// NO-AS: %call5 = call noundef ptr @_ZNKSt9type_info4nameEv(ptr {{.*}} @_ZTI1A)
+// AS: %call7 = call noundef ptr @_ZNKSt9type_info4nameEv(ptr {{.*}} %8)
+// NO-AS: %call7 = call noundef ptr @_ZNKSt9type_info4nameEv(ptr {{.*}} %8)
+if (typeid(A).name() == typeid(b).name())
+return 0;
+// AS: %call11 = call noundef zeroext i1 @_ZNKSt9type_info6beforeERKS_(ptr {{.*}} %11, ptr {{.*}} addrspacecast (ptr addrspace(1) @_ZTIf to ptr))
+// NO-AS:   %call11 = call noundef zeroext i1 @_ZNKSt9type_info6beforeERKS_(ptr {{.*}} %11, ptr {{.*}} @_ZTIf)
+if (typeid(b).before(typeid(float)))
+return 1;
+// AS: %call15 = call noundef i64 @_ZNKSt9type_info9hash_codeEv(ptr {{.*}} %14)
+// NO-AS: %call15 = call noundef i64 @_ZNKSt9type_info9hash_codeEv(ptr {{.*}} %14)
+return typeid(b).hash_code();
+}
Index: clang/test/CodeGenCXX/typeinfo
===
--- clang/test/CodeGenCXX/typeinfo
+++ clang/test/CodeGenCXX/typeinfo
@@ -10,6 +10,14 @@
 bool operator!=(const type_info& __arg) const {
   return !operator==(__arg);
 }
+
+bool before(const type_info& __arg) const {
+  return __name < __arg.__name;
+}
+
+unsigned long hash_code() const {
+  return reinterpret_cast(__name);
+}
   protected:
 const char *__name;
   };
Index: clang/test/CodeGenCXX/typeid-with-address-space.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/typeid-with-address-space.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -I%S %s -triple amdgcn-amd-amdhsa -emit-llvm -fcxx-exceptions -fexceptions -o - | FileCheck %s
+#include 
+
+namespace Test1 {
+
+// PR7400
+struct A { virtual void f(); };
+
+// CHECK: @_ZN5Test16int_tiE ={{.*}} constant ptr addrspacecast (ptr addrspace(1) @_ZTIi to ptr), align 8
+const std::type_info &int_ti = typeid(int);
+
+// CHECK: @_ZN5Test14A_tiE ={{.*}} constant ptr addrspacecast (ptr addrspace(1) @_ZTIN5Test11AE to ptr), align 8
+const std::type_info &

[PATCH] D158031: [clang][ExtractAPI] Refactor C++ method and field visitation

2023-08-15 Thread Erick Velez via Phabricator via cfe-commits
evelez7 created this revision.
evelez7 added a reviewer: dang.
Herald added a reviewer: ributzka.
Herald added a project: All.
evelez7 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Refactor visitation for C++ record children by following the Visitor's CRTP.
Expand VisitCXXField, VisitCXXMethod for non-templates and introduce 
VisitCXXConstructor, VisitCXXDestructor.
Handle relationships by finding the parent's Record via USR from DeclContext.

Depends on D158029 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158031

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/constructor_destructor.cpp
  clang/test/ExtractAPI/methods.cpp

Index: clang/test/ExtractAPI/methods.cpp
===
--- clang/test/ExtractAPI/methods.cpp
+++ clang/test/ExtractAPI/methods.cpp
@@ -64,13 +64,13 @@
 },
 {
   "kind": "memberOf",
-  "source": "c:@S@Foo@F@getFoo#S",
+  "source": "c:@S@Foo@F@getBar#1",
   "target": "c:@S@Foo",
   "targetFallback": "Foo"
 },
 {
   "kind": "memberOf",
-  "source": "c:@S@Foo@F@getBar#1",
+  "source": "c:@S@Foo@F@getFoo#S",
   "target": "c:@S@Foo",
   "targetFallback": "Foo"
 }
@@ -310,11 +310,11 @@
   ]
 },
 {
-  "accessLevel": "public",
+  "accessLevel": "protected",
   "declarationFragments": [
 {
   "kind": "keyword",
-  "spelling": "static"
+  "spelling": "constexpr"
 },
 {
   "kind": "text",
@@ -322,8 +322,8 @@
 },
 {
   "kind": "typeIdentifier",
-  "preciseIdentifier": "c:d",
-  "spelling": "double"
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
 },
 {
   "kind": "text",
@@ -331,34 +331,42 @@
 },
 {
   "kind": "identifier",
-  "spelling": "getFoo"
+  "spelling": "getBar"
 },
 {
   "kind": "text",
-  "spelling": "();"
+  "spelling": "() "
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": ";"
 }
   ],
   "functionSignature": {
 "returns": [
   {
 "kind": "typeIdentifier",
-"preciseIdentifier": "c:d",
-"spelling": "double"
+"preciseIdentifier": "c:I",
+"spelling": "int"
   }
 ]
   },
   "identifier": {
 "interfaceLanguage": "c++",
-"precise": "c:@S@Foo@F@getFoo#S"
+"precise": "c:@S@Foo@F@getBar#1"
   },
   "kind": {
-"displayName": "Static Method",
-"identifier": "c++.type.method"
+"displayName": "Instance Method",
+"identifier": "c++.method"
   },
   "location": {
 "position": {
   "character": 17,
-  "line": 7
+  "line": 10
 },
 "uri": "file://INPUT_DIR/input.h"
   },
@@ -366,28 +374,28 @@
 "navigator": [
   {
 "kind": "identifier",
-"spelling": "getFoo"
+"spelling": "getBar"
   }
 ],
 "subHeading": [
   {
 "kind": "identifier",
-"spelling": "getFoo"
+"spelling": "getBar"
   }
 ],
-"title": "getFoo"
+"title": "getBar"
   },
   "pathComponents": [
 "Foo",
-"getFoo"
+"getBar"
   ]
 },
 {
-  "accessLevel": "protected",
+  "accessLevel": "public",
   "declarationFragments": [
 {
   "kind": "keyword",
-  "spelling": "constexpr"
+  "spelling": "static"
 },
 {
   "kind": "text",
@@ -395,8 +403,8 @@
 },
 {
   "kind": "typeIdentifier",
-  "preciseIdentifier": "c:I",
-  "spelling": "int"
+  "preciseIdentifier": "c:d",
+  "spelling": "double"
 },
 {
   "kind": "text",
@@ -404,42 +412,34 @@
 },
 {
   "kind": "identifier",
-  "spelling": "getBar"
-},
-{
-  "kind": "text",
-  "spelling": "() "
-},
-{
-  "kind": "keyword",
-  "spelling": "const"
+  "spelling": "getFoo"
 },
 {
   "kind": "text",
-  "spelling": ";"
+  "spelling": "();"
 }
   ],
   "functionSignature": {
 "returns": [
   {
 

[PATCH] D157018: [-Wunsafe-buffer-usage] Replace assert that declarations are always found

2023-08-15 Thread Rashmi Mudduluru via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcf1c64b94d94: [-Wunsafe-buffer-usage] Replace assert that 
declarations are always found (authored by t-rasmud).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157018

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp


Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
@@ -66,3 +66,15 @@
   b++;  // expected-note{{used in pointer arithmetic here}} \
 // debug-note{{safe buffers debug: failed to produce fixit for 'b' : 
has an unclaimed use}}
 }
+
+int *a = new int[3];  // expected-warning{{'a' is an unsafe pointer used for 
buffer access}} \
+// debug-note{{safe buffers debug: failed to produce fixit for 'a' : neither 
local nor a parameter}}
+void test_globals() {
+  a[7] = 4;  // expected-note{{used in buffer access here}}
+}
+
+void test_decomp_decl() {
+  int a[2] = {1, 2};
+  auto [x, y] = a;
+  x = 9;
+}
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -888,7 +888,8 @@
 
   const DeclStmt *lookupDecl(const VarDecl *VD) const {
 auto It = Defs.find(VD);
-assert(It != Defs.end() && "Definition never discovered!");
+if (It == Defs.end())
+  return nullptr;
 return It->second;
   }
 };
@@ -2053,7 +2054,10 @@
  ASTContext &Ctx,
  UnsafeBufferUsageHandler &Handler) {
   const DeclStmt *DS = Tracker.lookupDecl(VD);
-  assert(DS && "Fixing non-local variables not implemented yet!");
+  if (!DS) {
+DEBUG_NOTE_DECL_FAIL(VD, " : variables declared this way not implemented 
yet");
+return {};
+  }
   if (!DS->isSingleDecl()) {
 // FIXME: to support handling multiple `VarDecl`s in a single `DeclStmt`
 DEBUG_NOTE_DECL_FAIL(VD, " : multiple VarDecls");


Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
@@ -66,3 +66,15 @@
   b++;  // expected-note{{used in pointer arithmetic here}} \
 // debug-note{{safe buffers debug: failed to produce fixit for 'b' : has an unclaimed use}}
 }
+
+int *a = new int[3];  // expected-warning{{'a' is an unsafe pointer used for buffer access}} \
+// debug-note{{safe buffers debug: failed to produce fixit for 'a' : neither local nor a parameter}}
+void test_globals() {
+  a[7] = 4;  // expected-note{{used in buffer access here}}
+}
+
+void test_decomp_decl() {
+  int a[2] = {1, 2};
+  auto [x, y] = a;
+  x = 9;
+}
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -888,7 +888,8 @@
 
   const DeclStmt *lookupDecl(const VarDecl *VD) const {
 auto It = Defs.find(VD);
-assert(It != Defs.end() && "Definition never discovered!");
+if (It == Defs.end())
+  return nullptr;
 return It->second;
   }
 };
@@ -2053,7 +2054,10 @@
  ASTContext &Ctx,
  UnsafeBufferUsageHandler &Handler) {
   const DeclStmt *DS = Tracker.lookupDecl(VD);
-  assert(DS && "Fixing non-local variables not implemented yet!");
+  if (!DS) {
+DEBUG_NOTE_DECL_FAIL(VD, " : variables declared this way not implemented yet");
+return {};
+  }
   if (!DS->isSingleDecl()) {
 // FIXME: to support handling multiple `VarDecl`s in a single `DeclStmt`
 DEBUG_NOTE_DECL_FAIL(VD, " : multiple VarDecls");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cf1c64b - [-Wunsafe-buffer-usage] Replace assert that declarations are always found

2023-08-15 Thread Rashmi Mudduluru via cfe-commits

Author: Rashmi Mudduluru
Date: 2023-08-15T15:41:56-07:00
New Revision: cf1c64b94d94105f61e308e57eb963b722d22d77

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

LOG: [-Wunsafe-buffer-usage] Replace assert that declarations are always found

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

Added: 


Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 6f9f5f5e7ee7f2..87087686171347 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -888,7 +888,8 @@ class DeclUseTracker {
 
   const DeclStmt *lookupDecl(const VarDecl *VD) const {
 auto It = Defs.find(VD);
-assert(It != Defs.end() && "Definition never discovered!");
+if (It == Defs.end())
+  return nullptr;
 return It->second;
   }
 };
@@ -2053,7 +2054,10 @@ static FixItList fixVariableWithSpan(const VarDecl *VD,
  ASTContext &Ctx,
  UnsafeBufferUsageHandler &Handler) {
   const DeclStmt *DS = Tracker.lookupDecl(VD);
-  assert(DS && "Fixing non-local variables not implemented yet!");
+  if (!DS) {
+DEBUG_NOTE_DECL_FAIL(VD, " : variables declared this way not implemented 
yet");
+return {};
+  }
   if (!DS->isSingleDecl()) {
 // FIXME: to support handling multiple `VarDecl`s in a single `DeclStmt`
 DEBUG_NOTE_DECL_FAIL(VD, " : multiple VarDecls");

diff  --git a/clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp 
b/clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
index 79031cdb7691d3..f0f9a52cc3d0c9 100644
--- a/clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
+++ b/clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
@@ -66,3 +66,15 @@ void implied_unclaimed_var(int *b) {  // 
expected-warning{{'b' is an unsafe poin
   b++;  // expected-note{{used in pointer arithmetic here}} \
 // debug-note{{safe buffers debug: failed to produce fixit for 'b' : 
has an unclaimed use}}
 }
+
+int *a = new int[3];  // expected-warning{{'a' is an unsafe pointer used for 
buffer access}} \
+// debug-note{{safe buffers debug: failed to produce fixit for 'a' : neither 
local nor a parameter}}
+void test_globals() {
+  a[7] = 4;  // expected-note{{used in buffer access here}}
+}
+
+void test_decomp_decl() {
+  int a[2] = {1, 2};
+  auto [x, y] = a;
+  x = 9;
+}



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


[PATCH] D158029: [clang][ExtractAPI] Add support for C++ member templates

2023-08-15 Thread Erick Velez via Phabricator via cfe-commits
evelez7 created this revision.
Herald added a reviewer: ributzka.
Herald added a project: All.
evelez7 requested review of this revision.
Herald added a reviewer: dang.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Visit and serialize C++ fields by checking if a var template's context is a 
CXXRecordDecl in VisitVarTemplateDecl.

Depends on D158027 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158029

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/field_template.cpp

Index: clang/test/ExtractAPI/field_template.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/field_template.cpp
@@ -0,0 +1,206 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+class Foo {
+  template static T Bar;
+};
+
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [
+{
+  "kind": "memberOf",
+  "source": "c:@S@Foo@Bar",
+  "target": "c:@S@Foo",
+  "targetFallback": "Foo"
+}
+  ],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "class"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@S@Foo"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "c++.class"
+  },
+  "location": {
+"position": {
+  "character": 7,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"title": "Foo"
+  },
+  "pathComponents": [
+"Foo"
+  ]
+},
+{
+  "accessLevel": "private",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "template"
+},
+{
+  "kind": "text",
+  "spelling": "<"
+},
+{
+  "kind": "keyword",
+  "spelling": "typename"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "genericParameter",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": "> "
+},
+{
+  "kind": "keyword",
+  "spelling": "static"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:t0.0",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Bar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@S@Foo@Bar"
+  },
+  "kind": {
+"displayName": "Template Property",
+"identifier": "c++.property"
+  },
+  "location": {
+"position": {
+  "character": 33,
+  "line": 2
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "n

[PATCH] D158027: [clang][ExtractAPI] Visit method templates with better scheme

2023-08-15 Thread Erick Velez via Phabricator via cfe-commits
evelez7 updated this revision to Diff 550500.
evelez7 added a comment.

Fix arbitrary include changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158027

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/method_template.cpp
  clang/test/ExtractAPI/method_template_spec.cpp

Index: clang/test/ExtractAPI/method_template_spec.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/method_template_spec.cpp
@@ -0,0 +1,371 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+class Foo {
+  template void Bar(T Fizz);
+
+  template<> void Bar(int Fizz);
+};
+
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [
+{
+  "kind": "memberOf",
+  "source": "c:@S@Foo@FT@>1#TBar#t0.0#v#",
+  "target": "c:@S@Foo",
+  "targetFallback": "Foo"
+},
+{
+  "kind": "memberOf",
+  "source": "c:@S@Foo@F@Bar<#I>#I#",
+  "target": "c:@S@Foo",
+  "targetFallback": "Foo"
+}
+  ],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "class"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@S@Foo"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "c++.class"
+  },
+  "location": {
+"position": {
+  "character": 7,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"title": "Foo"
+  },
+  "pathComponents": [
+"Foo"
+  ]
+},
+{
+  "accessLevel": "private",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "template"
+},
+{
+  "kind": "text",
+  "spelling": "<"
+},
+{
+  "kind": "keyword",
+  "spelling": "typename"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "genericParameter",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": "> "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Bar"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:t0.0",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "Fizz"
+},
+{
+  "kind": "text",
+  "spelling": ");"
+}
+  ],
+  "functionSignature": {
+"parameters": [
+  {
+"declarationFragments": [
+  {
+"kind": "typeIdentifier",
+"preciseIdentifie

[PATCH] D157445: [CodeGen][UBSan] Add support for handling attributed functions in getUBSanFunctionTypeHash.

2023-08-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: clang/test/CodeGen/ubsan-function-attributed.c:3
+
+// CHECK: .long248076293
+void __attribute__((ms_abi)) f(void) {}

It's useful to add `// CHECK-LABEL: f:` interleaving with `.long xxx`. The 
FileCheck error will be better when the hash changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157445

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


[clang] 95ae517 - [Driver] Remove CLDXCFlag by allowing CLFlag to specify visibility. NFC

2023-08-15 Thread Justin Bogner via cfe-commits

Author: Justin Bogner
Date: 2023-08-15T15:00:19-07:00
New Revision: 95ae517bb4c332149b3c45cd7d1e6edf8b40077e

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

LOG: [Driver] Remove CLDXCFlag by allowing CLFlag to specify visibility. NFC

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e1e543be6e179c..d8d11497ea11e1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7603,46 +7603,43 @@ def cl_compile_Group : OptionGroup<"">,
 def cl_ignored_Group : OptionGroup<"">,
   Group;
 
-class CLFlag : Option<["/", "-"], name, KIND_FLAG>,
-  Group, Flags<[NoXarchOption]>, Visibility<[CLOption]>;
+class CLFlag vis = [CLOption]> :
+  Option<["/", "-"], name, KIND_FLAG>,
+  Group, Flags<[NoXarchOption]>, Visibility;
 
-class CLDXCFlag : Option<["/", "-"], name, KIND_FLAG>,
-  Group, Flags<[NoXarchOption]>, Visibility<[CLOption, DXCOption]>;
+class CLCompileFlag vis = [CLOption]> :
+  Option<["/", "-"], name, KIND_FLAG>,
+  Group, Flags<[NoXarchOption]>, Visibility;
 
-class CLCompileFlag : Option<["/", "-"], name, KIND_FLAG>,
-  Group, Flags<[NoXarchOption]>, Visibility<[CLOption]>;
+class CLIgnoredFlag vis = [CLOption]> :
+  Option<["/", "-"], name, KIND_FLAG>,
+  Group, Flags<[NoXarchOption]>, Visibility;
 
-class CLIgnoredFlag : Option<["/", "-"], name, KIND_FLAG>,
-  Group, Flags<[NoXarchOption]>, Visibility<[CLOption]>;
+class CLJoined vis = [CLOption]> :
+  Option<["/", "-"], name, KIND_JOINED>,
+  Group, Flags<[NoXarchOption]>, Visibility;
 
-class CLJoined : Option<["/", "-"], name, KIND_JOINED>,
-  Group, Flags<[NoXarchOption]>, Visibility<[CLOption]>;
+class CLCompileJoined vis = [CLOption]> :
+  Option<["/", "-"], name, KIND_JOINED>,
+  Group, Flags<[NoXarchOption]>, Visibility;
 
-class CLDXCJoined : Option<["/", "-"], name, KIND_JOINED>,
-  Group, Flags<[NoXarchOption]>, Visibility<[CLOption, DXCOption]>;
+class CLIgnoredJoined vis = [CLOption]> :
+  Option<["/", "-"], name, KIND_JOINED>,
+  Group, Flags<[NoXarchOption, HelpHidden]>, Visibility;
 
-class CLCompileJoined : Option<["/", "-"], name, KIND_JOINED>,
-  Group, Flags<[NoXarchOption]>, Visibility<[CLOption]>;
+class CLJoinedOrSeparate vis = [CLOption]> 
:
+  Option<["/", "-"], name, KIND_JOINED_OR_SEPARATE>,
+  Group, Flags<[NoXarchOption]>, Visibility;
 
-class CLIgnoredJoined : Option<["/", "-"], name, KIND_JOINED>,
-  Group, Flags<[NoXarchOption, HelpHidden]>,
-  Visibility<[CLOption]>;
+class CLCompileJoinedOrSeparate vis = [CLOption]> :
+  Option<["/", "-"], name, KIND_JOINED_OR_SEPARATE>,
+  Group, Flags<[NoXarchOption]>, Visibility;
 
-class CLJoinedOrSeparate : Option<["/", "-"], name,
-  KIND_JOINED_OR_SEPARATE>, Group, Flags<[NoXarchOption]>,
-  Visibility<[CLOption]>;
-
-class CLDXCJoinedOrSeparate : Option<["/", "-"], name,
-  KIND_JOINED_OR_SEPARATE>, Group, Flags<[NoXarchOption]>,
-  Visibility<[CLOption, DXCOption]>;
-
-class CLCompileJoinedOrSeparate : Option<["/", "-"], name,
-  KIND_JOINED_OR_SEPARATE>, Group,
-  Flags<[NoXarchOption]>, Visibility<[CLOption]>;
-
-class CLRemainingArgsJoined : Option<["/", "-"], name,
-  KIND_REMAINING_ARGS_JOINED>, Group, Flags<[NoXarchOption]>,
-  Visibility<[CLOption]>;
+class CLRemainingArgsJoined vis = [CLOption]> :
+  Option<["/", "-"], name, KIND_REMAINING_ARGS_JOINED>,
+  Group, Flags<[NoXarchOption]>, Visibility;
 
 // Aliases:
 // (We don't put any of these in cl_compile_Group as the options they alias are
@@ -7713,7 +7710,7 @@ def _SLASH_help : CLFlag<"help">, Alias,
 def _SLASH_HELP : CLFlag<"HELP">, Alias;
 def _SLASH_hotpatch : CLFlag<"hotpatch">, Alias,
   HelpText<"Create hotpatchable image">;
-def _SLASH_I : CLDXCJoinedOrSeparate<"I">,
+def _SLASH_I : CLJoinedOrSeparate<"I", [CLOption, DXCOption]>,
   HelpText<"Add directory to include search path">, MetaVarName<"">,
   Alias;
 def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">,
@@ -7721,7 +7718,7 @@ def _SLASH_J : CLFlag<"J">, HelpText<"Make char type 
unsigned">,
 
 // The _SLASH_O option handles all the /O flags, but we also provide separate
 // aliased options to provide separate help messages.
-def _SLASH_O : CLDXCJoined<"O">,
+def _SLASH_O : CLJoined<"O", [CLOption, DXCOption]>,
   HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">,
   MetaVarName<"">;
 def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>,
@@ -7734,7 +7731,7 @@ def : CLFlag<"Ob1">, Alias<_SLASH_O>, AliasArgs<["b1"]>,
   HelpText<"Only inline functions explicitly or implicitly marked inline">;
 def : CLFlag<"Ob2">, Alias<_SLASH_O>, AliasArgs<["b2"]>,
   HelpText<"Inline functions as deemed beneficial by the compiler">;
-def : CLDX

[PATCH] D158027: [clang][ExtractAPI] Visit method templates with better scheme

2023-08-15 Thread Erick Velez via Phabricator via cfe-commits
evelez7 created this revision.
evelez7 added a reviewer: dang.
Herald added a reviewer: ributzka.
Herald added a project: All.
evelez7 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Visit and serialize method templates and template specializations. Introduces a 
new scheme of visiting child Decls via VisitCXXMethodDecl which will be 
followed in future patches for Fields and non-template methods.

Depends on D157579 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158027

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/method_template.cpp
  clang/test/ExtractAPI/method_template_spec.cpp

Index: clang/test/ExtractAPI/method_template_spec.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/method_template_spec.cpp
@@ -0,0 +1,371 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+class Foo {
+  template void Bar(T Fizz);
+
+  template<> void Bar(int Fizz);
+};
+
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [
+{
+  "kind": "memberOf",
+  "source": "c:@S@Foo@FT@>1#TBar#t0.0#v#",
+  "target": "c:@S@Foo",
+  "targetFallback": "Foo"
+},
+{
+  "kind": "memberOf",
+  "source": "c:@S@Foo@F@Bar<#I>#I#",
+  "target": "c:@S@Foo",
+  "targetFallback": "Foo"
+}
+  ],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "class"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@S@Foo"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "c++.class"
+  },
+  "location": {
+"position": {
+  "character": 7,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"title": "Foo"
+  },
+  "pathComponents": [
+"Foo"
+  ]
+},
+{
+  "accessLevel": "private",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "template"
+},
+{
+  "kind": "text",
+  "spelling": "<"
+},
+{
+  "kind": "keyword",
+  "spelling": "typename"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "genericParameter",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": "> "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Bar"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:t0.0",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "

[clang] 44e6c11 - [Driver] Remove -coverage-notes-file and -coverage-data-file in favor of their Joined = form

2023-08-15 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-08-15T14:58:55-07:00
New Revision: 44e6c114d974c80e4a88c1b93bfe646ac9b6d08d

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

LOG: [Driver] Remove -coverage-notes-file and -coverage-data-file in favor of 
their Joined = form

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 57f06d31ce4177..e1e543be6e179c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6559,16 +6559,10 @@ def fdump_vtable_layouts : Flag<["-"], 
"fdump-vtable-layouts">,
 def fmerge_functions : Flag<["-"], "fmerge-functions">,
   HelpText<"Permit merging of identical functions when optimizing.">,
   MarshallingInfoFlag>;
-def coverage_data_file : Separate<["-"], "coverage-data-file">,
-  HelpText<"Emit coverage data to this filename.">,
+def : Joined<["-"], "coverage-data-file=">,
   MarshallingInfoString>;
-def coverage_data_file_EQ : Joined<["-"], "coverage-data-file=">,
-  Alias;
-def coverage_notes_file : Separate<["-"], "coverage-notes-file">,
-  HelpText<"Emit coverage notes to this filename.">,
+def : Joined<["-"], "coverage-notes-file=">,
   MarshallingInfoString>;
-def coverage_notes_file_EQ : Joined<["-"], "coverage-notes-file=">,
-  Alias;
 def coverage_version_EQ : Joined<["-"], "coverage-version=">,
   HelpText<"Four-byte version string for gcov files.">;
 def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">,



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


[PATCH] D154382: [ClangRepl] support code completion at a REPL

2023-08-15 Thread Fred Fu via Phabricator via cfe-commits
capfredf added a comment.

@sammccall Thank you very much for your valuable input.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

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


[PATCH] D154382: [ClangRepl] support code completion at a REPL

2023-08-15 Thread Fred Fu via Phabricator via cfe-commits
capfredf added inline comments.



Comment at: clang/include/clang/Frontend/ASTUnit.h:901
+SmallVectorImpl &OwnedBuffers,
+std::function 
AfterBeginSourceFile = [](CompilerInstance& CI) -> void {});
 

sammccall wrote:
> capfredf wrote:
> > @v.g.vassilev  Not sure if this is the right solution or idiom to extend 
> > this method.  
> > 
> > we can make this high order function more general, like 
> > `std::unique_ptr<()>`
> There's no need for this to be a SyntaxOnlyAction, you can take 
> FrontendAction here.
> 
> I don't think there's any need to provide a factory, it's safe to assume it 
> will always create one action. (We have FrontendActionFactory in tooling, and 
> it's a pain.)
 Ideally, this method requires a FrontendAction with `hasCodeCompletionSupport` 
returning `true`.  The reason I chose  `SyntaxOnlyAction` are 1. the old code 
used it 2.  `SyntaxOnlyAction::hasCodeCompletionSupport` returns `true`.  
Certainly, right now `SyntaxOnlyAction` does not prevent its subclasses from 
overriding this method. 



Comment at: clang/include/clang/Sema/CodeCompleteConsumer.h:342
+/// Code completion at a top level in a REPL session.
+CCC_ReplTopLevel,
   };

sammccall wrote:
> v.g.vassilev wrote:
> > 
> I don't think this name fits with the others, it describes the client rather 
> than the grammatical/semantic context.
> 
> I would suggest maybe `CCC_TopLevelOrExpression`?
Nice. This one sounds better indeed. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

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


[PATCH] D154382: [ClangRepl] support code completion at a REPL

2023-08-15 Thread Fred Fu via Phabricator via cfe-commits
capfredf updated this revision to Diff 550489.
capfredf marked 7 inline comments as done.
capfredf added a comment.

address @sammccall 's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

Files:
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Interpreter/InterpreterCodeCompletion.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Interpreter/InterpreterCodeCompletion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Interpreter/CodeCompletionTest.cpp

Index: clang/unittests/Interpreter/CodeCompletionTest.cpp
===
--- clang/unittests/Interpreter/CodeCompletionTest.cpp
+++ clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -42,9 +42,9 @@
   Prefix, 1, Prefix.size(), MainInterp.getCompilerInstance(), Results);
 
   std::vector Comps;
-  for (auto c : ConvertToCodeCompleteStrings(Results)) {
-if (c.startswith(Prefix))
-  Comps.push_back(c.substr(Prefix.size()).str());
+  for (auto c : convertToCodeCompleteStrings(Results)) {
+if (c.find(Prefix) == 0)
+  Comps.push_back(c.substr(Prefix.size()));
   }
 
   return Comps;
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -543,7 +543,7 @@
 case CodeCompletionContext::CCC_PreprocessorExpression:
 case CodeCompletionContext::CCC_PreprocessorDirective:
 case CodeCompletionContext::CCC_Attribute:
-case CodeCompletionContext::CCC_ReplTopLevel:
+case CodeCompletionContext::CCC_TopLevelOrExpression:
 case CodeCompletionContext::CCC_TypeQualifiers: {
   //Only Clang results should be accepted, so we'll set all of the other
   //context bits to 0 (i.e. the empty set)
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -129,13 +129,14 @@
 s = Buffer.substr(space_pos + 1);
   }
 
-  for (auto c : ConvertToCodeCompleteStrings(Results)) {
-if (c.startswith(s))
+  for (auto c : convertToCodeCompleteStrings(Results)) {
+if (c.find(s) == 0)
   Comps.push_back(
-  llvm::LineEditor::Completion(c.substr(s.size()).str(), c.str()));
+  llvm::LineEditor::Completion(c.substr(s.size()), c));
   }
   return Comps;
 }
+
 llvm::ExitOnError ExitOnErr;
 int main(int argc, const char **argv) {
   ExitOnErr.setBanner("clang-repl: ");
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -225,7 +225,7 @@
 case CodeCompletionContext::CCC_ObjCMessageReceiver:
 case CodeCompletionContext::CCC_ParenthesizedExpression:
 case CodeCompletionContext::CCC_Statement:
-case CodeCompletionContext::CCC_ReplTopLevel:
+case CodeCompletionContext::CCC_TopLevelOrExpression:
 case CodeCompletionContext::CCC_Recovery:
   if (ObjCMethodDecl *Method = SemaRef.getCurMethodDecl())
 if (Method->isInstanceMethod())
@@ -1851,7 +1851,7 @@
   case Sema::PCC_ObjCInstanceVariableList:
   case Sema::PCC_Expression:
   case Sema::PCC_Statement:
-  case Sema::PCC_TopLevelStmtDecl:
+  case Sema::PCC_TopLevelOrExpression:
   case Sema::PCC_ForInit:
   case Sema::PCC_Condition:
   case Sema::PCC_RecoveryInFunction:
@@ -1909,7 +1909,7 @@
   case Sema::PCC_Type:
   case Sema::PCC_ParenthesizedExpression:
   case Sema::PCC_LocalDeclarationSpecifiers:
-  case Sema::PCC_TopLevelStmtDecl:
+  case Sema::PCC_TopLevelOrExpression:
 return true;
 
   case Sema::PCC_Expression:
@@ -,7 +,7 @@
 break;
 
   case Sema::PCC_RecoveryInFunction:
-  case Sema::PCC_TopLevelStmtDecl:
+  case Sema::PCC_TopLevelOrExpression:
   case Sema::PCC_Statement: {
 if (SemaRef.getLangOpts().CPlusPlus11)
   AddUsingAliasResult(Builder, Results);
@@ -4212,8 +4212,8 @@
 
   case Sema::PCC_LocalDeclarationSpecifiers:
 return CodeCompletionContext::CCC_Type;
-  case Sema::PCC_TopLevelStmtDecl:
-return CodeCompletionContext::CCC_ReplTopLevel;
+  case Sema::PCC_TopLevelOrExpression:
+return CodeCompletionContext::CCC_TopLevelOrExpression;
   }
 
   llvm_unreachable("Invalid ParserCompletionContext!");
@@ -4354,7 +4354,7 @@
 break;
 
   case PCC_Statement:
-  case PCC_TopLevelStmtDecl:
+  case PCC_TopLevelOrExpression:
   case PCC_ParenthesizedExpression:
   case PCC_Expression:
   case PCC_ForInit:
@@ -4392,7

[clang] 64473f1 - [gcov] Use Joined = form for -coverage-notes-file and -coverage-data-file

2023-08-15 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-08-15T14:49:02-07:00
New Revision: 64473f1221fbc16af140407d5ea64d808f5853a7

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

LOG: [gcov] Use Joined = form for -coverage-notes-file and -coverage-data-file

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/attr-function-return.c
clang/test/CodeGen/code-coverage-tsan.c
clang/test/CodeGen/code-coverage.c
clang/test/CodeGen/no_profile.c
clang/test/Driver/coverage.c
clang/test/Driver/cuda-no-pgo-or-coverage.cu
clang/test/Driver/working-directory.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index be3c92162f5bf0..6b2b8507061c21 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -929,8 +929,8 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
   (void)D.getVFS().makeAbsolute(CoverageFilename);
 llvm::sys::path::replace_extension(CoverageFilename, "gcno");
 if (EmitCovNotes) {
-  CmdArgs.push_back("-coverage-notes-file");
-  CmdArgs.push_back(Args.MakeArgString(CoverageFilename));
+  CmdArgs.push_back(
+  Args.MakeArgString("-coverage-notes-file=" + CoverageFilename));
 }
 
 if (EmitCovData) {
@@ -940,8 +940,8 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
 llvm::sys::path::append(CoverageFilename, Gcno);
   }
   llvm::sys::path::replace_extension(CoverageFilename, "gcda");
-  CmdArgs.push_back("-coverage-data-file");
-  CmdArgs.push_back(Args.MakeArgString(CoverageFilename));
+  CmdArgs.push_back(
+  Args.MakeArgString("-coverage-data-file=" + CoverageFilename));
 }
   }
 }

diff  --git a/clang/test/CodeGen/attr-function-return.c 
b/clang/test/CodeGen/attr-function-return.c
index cbb10082651d55..df2cabf28693a3 100644
--- a/clang/test/CodeGen/attr-function-return.c
+++ b/clang/test/CodeGen/attr-function-return.c
@@ -8,7 +8,7 @@
 // RUN:   -Werror=ignored-attributes -mfunction-return=thunk-extern \
 // RUN:   | FileCheck %s --check-prefixes=CHECK,CHECK-EXTERN
 // RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
-// RUN:  -mfunction-return=thunk-extern -coverage-data-file /dev/null \
+// RUN:  -mfunction-return=thunk-extern -coverage-data-file=/dev/null \
 // RUN:   | FileCheck %s --check-prefix=CHECK-GCOV
 // RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
 // RUN:  -mfunction-return=thunk-extern -fsanitize=address \

diff  --git a/clang/test/CodeGen/code-coverage-tsan.c 
b/clang/test/CodeGen/code-coverage-tsan.c
index cb37a38bdaf0a7..8b0676dd454626 100644
--- a/clang/test/CodeGen/code-coverage-tsan.c
+++ b/clang/test/CodeGen/code-coverage-tsan.c
@@ -1,7 +1,7 @@
 /// -fprofile-update=atomic (implied by -fsanitize=thread) requires the
 /// (potentially concurrent) counter updates to be atomic.
 // RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fprofile-update=atomic \
-// RUN:   -coverage-notes-file /dev/null -coverage-data-file /dev/null -o - | 
FileCheck %s
+// RUN:   -coverage-notes-file=/dev/null -coverage-data-file=/dev/null -o - | 
FileCheck %s
 
 // CHECK-LABEL: void @foo()
 /// Two counters are incremented by __tsan_atomic64_fetch_add.

diff  --git a/clang/test/CodeGen/code-coverage.c 
b/clang/test/CodeGen/code-coverage.c
index dbb7e1479290b8..af02a6ddaef990 100644
--- a/clang/test/CodeGen/code-coverage.c
+++ b/clang/test/CodeGen/code-coverage.c
@@ -3,11 +3,11 @@
 /// 4.7 enables cfg_checksum.
 /// 4.8 (default, compatible with gcov 7) emits the exit block the second.
 // RUN: rm -rf %t && mkdir %t && cd %t
-// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file /dev/null 
-coverage-version='304*' %s -o - | \
+// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file=/dev/null 
-coverage-version='304*' %s -o - | \
 // RUN:   FileCheck --check-prefixes=CHECK,304 %s
-// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file /dev/null 
-coverage-version='407*' %s -o - | \
+// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file=/dev/null 
-coverage-version='407*' %s -o - | \
 // RUN:   FileCheck --check-prefixes=CHECK,407 %s
-// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file /dev/null 
%s -o - | \
+// RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-data-file=/dev/null 
%s -o - | \
 // RUN:   FileCheck --check-prefixes=CHECK,408 %s
 
 // RUN: %clang_cc1 -emit-llvm -disable-red-zone -coverage-notes-file=aaa.gcno 
-coverage-data-file=bbb.gcda -debug-info-kind=limited -dwarf-version=4 %s -o - 
| FileCheck %s --check-prefix GCOV_FILE_INFO

diff  --git a/clang/test/CodeGen/no_profile.c b/clang/te

[PATCH] D157350: [clang][ExtractAPI] Add support for C++ variable templates

2023-08-15 Thread Erick Velez via Phabricator via cfe-commits
evelez7 updated this revision to Diff 550485.
evelez7 added a comment.

Get rid of unnecessary function for checking if global var


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157350

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/global_var_template.cpp
  clang/test/ExtractAPI/global_var_template_partial_spec.cpp
  clang/test/ExtractAPI/global_var_template_spec.cpp

Index: clang/test/ExtractAPI/global_var_template_spec.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/global_var_template_spec.cpp
@@ -0,0 +1,207 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+template T Foo = T(3.14);
+
+template<> int Foo;
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "template"
+},
+{
+  "kind": "text",
+  "spelling": "<"
+},
+{
+  "kind": "keyword",
+  "spelling": "typename"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "genericParameter",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": "> "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:t0.0",
+  "spelling": "T"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@Foo"
+  },
+  "kind": {
+"displayName": "Global Variable Template",
+"identifier": "c++.var"
+  },
+  "location": {
+"position": {
+  "character": 24,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"title": "Foo"
+  },
+  "pathComponents": [
+"Foo"
+  ],
+  "swiftGenerics": {
+"parameters": [
+  {
+"depth": 0,
+"index": 0,
+"name": "T"
+  }
+]
+  }
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "template"
+},
+{
+  "kind": "text",
+  "spelling": "<> "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": "<"
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": ">;"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@Foo>#I"

[PATCH] D157917: clang/HIP: Use abs builtins instead of implementing them

2023-08-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

43f314f5e6cebe02ff63d5197c8e5c25204b20d2 



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

https://reviews.llvm.org/D157917

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


[clang] 43f314f - clang/HIP: Use abs builtins instead of implementing them

2023-08-15 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-08-15T17:40:19-04:00
New Revision: 43f314f5e6cebe02ff63d5197c8e5c25204b20d2

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

LOG: clang/HIP: Use abs builtins instead of implementing them

InstCombine already put these back together so there's no visible
change in the -O1 test for the header.

Added: 


Modified: 
clang/lib/Headers/__clang_hip_math.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index 8721167304a665..120961967d840f 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -315,18 +315,15 @@ float __tanf(float __x) {
 #if defined(__cplusplus)
 __DEVICE__
 int abs(int __x) {
-  int __sgn = __x >> (sizeof(int) * CHAR_BIT - 1);
-  return (__x ^ __sgn) - __sgn;
+  return __builtin_abs(__x);
 }
 __DEVICE__
 long labs(long __x) {
-  long __sgn = __x >> (sizeof(long) * CHAR_BIT - 1);
-  return (__x ^ __sgn) - __sgn;
+  return __builtin_labs(__x);
 }
 __DEVICE__
 long long llabs(long long __x) {
-  long long __sgn = __x >> (sizeof(long long) * CHAR_BIT - 1);
-  return (__x ^ __sgn) - __sgn;
+  return __builtin_llabs(__x);
 }
 #endif
 



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


[clang] c49142e - Fix truncated __OPENMP_NVPTX__ preprocessor condition

2023-08-15 Thread Mehdi Amini via cfe-commits

Author: Ryan Burns
Date: 2023-08-15T14:12:34-07:00
New Revision: c49142e4f5c8645a4d741d233f0cb55ef1ef87a2

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

LOG: Fix truncated __OPENMP_NVPTX__ preprocessor condition

I don't have a test case for this but noticed this warning when including 
system headers with `-I` rather than `-isystem`.

```
In file included from :1:
In file included from 
/nix/store/jq6bpm0xmhnbffhs5rkxq4n88g5xi2zg-clang-wrapper-11.0.1/resource-root/include/__clang_cuda_runtime_wrapper.h:157:
/nix/store/jq6bpm0xmhnbffhs5rkxq4n88g5xi2zg-clang-wrapper-11.0.1/resource-root/include/__clang_cuda_math.h:39:25:
 warning: extra tokens at end of #ifdef directive [-Wextra-tokens]
^
```

Reviewed By: tra

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

Added: 


Modified: 
clang/lib/Headers/__clang_cuda_math.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_cuda_math.h 
b/clang/lib/Headers/__clang_cuda_math.h
index c06da2713fd8ce..04019165068668 100644
--- a/clang/lib/Headers/__clang_cuda_math.h
+++ b/clang/lib/Headers/__clang_cuda_math.h
@@ -36,7 +36,7 @@
 // because the OpenMP overlay requires constexpr functions here but prior to
 // c++14 void return functions could not be constexpr.
 #pragma push_macro("__DEVICE_VOID__")
-#ifdef __OPENMP_NVPTX__ && defined(__cplusplus) && __cplusplus < 201402L
+#if defined(__OPENMP_NVPTX__) && defined(__cplusplus) && __cplusplus < 201402L
 #define __DEVICE_VOID__ static __attribute__((always_inline, nothrow))
 #else
 #define __DEVICE_VOID__ __DEVICE__



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


[PATCH] D157445: [CodeGen][UBSan] Add support for handling attributed functions in getUBSanFunctionTypeHash.

2023-08-15 Thread Yeoul Na via Phabricator via cfe-commits
rapidsna accepted this revision.
rapidsna added a comment.
This revision is now accepted and ready to land.

The changes look good to me. Ideally, we could add tests with multiple 
attributes and possibly with other sugar types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157445

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


[PATCH] D157445: [CodeGen][UBSan] Add support for handling attributed functions in getUBSanFunctionTypeHash.

2023-08-15 Thread Usama Hameed via Phabricator via cfe-commits
usama54321 updated this revision to Diff 550477.
usama54321 added a comment.

Updated commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157445

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/ubsan-function-attributed.c


Index: clang/test/CodeGen/ubsan-function-attributed.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-function-attributed.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -S -triple x86_64 -std=c17 -fsanitize=function %s -o - | 
FileCheck %s --check-prefixes=CHECK
+
+// CHECK: .long248076293
+void __attribute__((ms_abi)) f(void) {}
+
+// CHECK: .long905068220
+void g(void) {}
+
+// CHECK: .long1717976574
+void __attribute__((ms_abi)) f_no_prototype() {}
+
+// CHECK: .long1717976574
+void g_no_prototype() {}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -572,7 +572,7 @@
 CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const {
   // Remove any (C++17) exception specifications, to allow calling e.g. a
   // noexcept function through a non-noexcept pointer.
-  if (!isa(Ty))
+  if (!Ty->isFunctionNoProtoType())
 Ty = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
   std::string Mangled;
   llvm::raw_string_ostream Out(Mangled);


Index: clang/test/CodeGen/ubsan-function-attributed.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-function-attributed.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -S -triple x86_64 -std=c17 -fsanitize=function %s -o - | FileCheck %s --check-prefixes=CHECK
+
+// CHECK: .long	248076293
+void __attribute__((ms_abi)) f(void) {}
+
+// CHECK: .long	905068220
+void g(void) {}
+
+// CHECK: .long	1717976574
+void __attribute__((ms_abi)) f_no_prototype() {}
+
+// CHECK: .long	1717976574
+void g_no_prototype() {}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -572,7 +572,7 @@
 CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const {
   // Remove any (C++17) exception specifications, to allow calling e.g. a
   // noexcept function through a non-noexcept pointer.
-  if (!isa(Ty))
+  if (!Ty->isFunctionNoProtoType())
 Ty = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
   std::string Mangled;
   llvm::raw_string_ostream Out(Mangled);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158021: [clang][modules] Mark builtin header 'inttypes.h' for modules

2023-08-15 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir updated this revision to Diff 550474.
benlangmuir added a reviewer: vsapsai.
benlangmuir added a comment.

Add missing test updates: tests using the `Inputs/System/usr/include` should be 
using `-internal-isystem` to get the correct search path order with respect to 
the resource dir. The tests that were previously using `-isystem` were only 
working before because the other headers wrap their `#include_next` in 
`__has_include_next`, which was causing them to silently be missing these 
headers. With inttypes.h the include_next is unguarded, which revealed the 
issue.  Note: even if we someday add the has_include_next guard to inttypes.h 
the test change is still correct.


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

https://reviews.llvm.org/D158021

Files:
  clang/lib/Lex/ModuleMap.cpp
  clang/test/Modules/Inputs/System/usr/include/module.map
  clang/test/Modules/Werror-Wsystem-headers.m
  clang/test/Modules/crash-vfs-include-pch.m
  clang/test/Modules/cstd.m
  clang/test/Modules/pch-used.m

Index: clang/test/Modules/pch-used.m
===
--- clang/test/Modules/pch-used.m
+++ clang/test/Modules/pch-used.m
@@ -1,8 +1,8 @@
 // UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
 // RUN: rm -rf %t
 // RUN: mkdir %t
-// RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h -o %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include
-// RUN: %clang_cc1 %s -include-pch %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h -o %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 -internal-isystem %S/Inputs/System/usr/include
+// RUN: %clang_cc1 %s -include-pch %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 -internal-isystem %S/Inputs/System/usr/include -emit-llvm -o - | FileCheck %s
 
 void f(void) { SPXTrace(); }
 void g(void) { double x = DBL_MAX; }
Index: clang/test/Modules/cstd.m
===
--- clang/test/Modules/cstd.m
+++ clang/test/Modules/cstd.m
@@ -28,3 +28,11 @@
 #  error "bool was not defined!"
 #endif
 
+// Supplied by compiler, which forwards to the "/usr/include" version.
+@import cstd.inttypes;
+#ifndef __CLANG_INTTYPES_H
+#error "__CLANG_INTTYPES_H was not defined!"
+#endif
+#ifndef MY_PRIi32
+#error "MY_PRIi32 was not defined!"
+#endif
Index: clang/test/Modules/crash-vfs-include-pch.m
===
--- clang/test/Modules/crash-vfs-include-pch.m
+++ clang/test/Modules/crash-vfs-include-pch.m
@@ -6,12 +6,12 @@
 // RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h \
 // RUN: -o %t/out/pch-used.h.pch -fmodules -fimplicit-module-maps \
 // RUN: -fmodules-cache-path=%t/cache -O0 \
-// RUN: -isystem %S/Inputs/System/usr/include
+// RUN: -internal-isystem %S/Inputs/System/usr/include
 
 // RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
 // RUN: not %clang %s -E -include-pch %t/out/pch-used.h.pch -fmodules -nostdlibinc \
 // RUN: -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 \
-// RUN: -Xclang -fno-validate-pch -isystem %S/Inputs/System/usr/include \
+// RUN: -Xclang -fno-validate-pch -Xclang -internal-isystem -Xclang %S/Inputs/System/usr/include \
 // RUN: -o %t/output.E 2>&1 | FileCheck %s
 
 // RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
Index: clang/test/Modules/Werror-Wsystem-headers.m
===
--- clang/test/Modules/Werror-Wsystem-headers.m
+++ clang/test/Modules/Werror-Wsystem-headers.m
@@ -4,17 +4,17 @@
 
 // Initial module build
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
-// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify
+// RUN: -internal-isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify
 // RUN: cp %t/cstd.pcm %t-saved/cstd.pcm
 
 // Even with -Werror don't rebuild a system module
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
-// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify -Werror
+// RUN: -internal-isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify -Werror
 // RUN: diff %t/cstd.pcm %t-saved/cstd.pcm
 
 // Unless -Wsystem-headers is on
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
-// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify \
+// RUN: -internal-isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify \
 // RUN: 

[PATCH] D157445: [CodeGen][UBSan] Add support for handling attributed functions in getUBSanFunctionTypeHash.

2023-08-15 Thread Usama Hameed via Phabricator via cfe-commits
usama54321 updated this revision to Diff 550475.
usama54321 retitled this revision from "[CodeGen][UBSan] Add support for 
handling attributed functions in getUBSanFunctionTypeHash." to 
"[CodeGen][UBSan] Add support for handling attributed functions in 
getUBSanFunctionTypeHash.".
usama54321 added a comment.

Updated PR according to feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157445

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/ubsan-function-attributed.c


Index: clang/test/CodeGen/ubsan-function-attributed.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-function-attributed.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -S -triple x86_64 -std=c17 -fsanitize=function %s -o - | 
FileCheck %s --check-prefixes=CHECK
+
+// CHECK: .long248076293
+void __attribute__((ms_abi)) f(void) {}
+
+// CHECK: .long905068220
+void g(void) {}
+
+// CHECK: .long1717976574
+void __attribute__((ms_abi)) f_no_prototype() {}
+
+// CHECK: .long1717976574
+void g_no_prototype() {}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -572,7 +572,7 @@
 CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const {
   // Remove any (C++17) exception specifications, to allow calling e.g. a
   // noexcept function through a non-noexcept pointer.
-  if (!isa(Ty))
+  if (!Ty->isFunctionNoProtoType())
 Ty = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
   std::string Mangled;
   llvm::raw_string_ostream Out(Mangled);


Index: clang/test/CodeGen/ubsan-function-attributed.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-function-attributed.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -S -triple x86_64 -std=c17 -fsanitize=function %s -o - | FileCheck %s --check-prefixes=CHECK
+
+// CHECK: .long	248076293
+void __attribute__((ms_abi)) f(void) {}
+
+// CHECK: .long	905068220
+void g(void) {}
+
+// CHECK: .long	1717976574
+void __attribute__((ms_abi)) f_no_prototype() {}
+
+// CHECK: .long	1717976574
+void g_no_prototype() {}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -572,7 +572,7 @@
 CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const {
   // Remove any (C++17) exception specifications, to allow calling e.g. a
   // noexcept function through a non-noexcept pointer.
-  if (!isa(Ty))
+  if (!Ty->isFunctionNoProtoType())
 Ty = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
   std::string Mangled;
   llvm::raw_string_ostream Out(Mangled);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95299: Fix truncated __OPENMP_NVPTX__ preprocessor condition

2023-08-15 Thread Mehdi AMINI via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc49142e4f5c8: Fix truncated __OPENMP_NVPTX__ preprocessor 
condition (authored by r-burns, committed by mehdi_amini).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95299

Files:
  clang/lib/Headers/__clang_cuda_math.h


Index: clang/lib/Headers/__clang_cuda_math.h
===
--- clang/lib/Headers/__clang_cuda_math.h
+++ clang/lib/Headers/__clang_cuda_math.h
@@ -36,7 +36,7 @@
 // because the OpenMP overlay requires constexpr functions here but prior to
 // c++14 void return functions could not be constexpr.
 #pragma push_macro("__DEVICE_VOID__")
-#ifdef __OPENMP_NVPTX__ && defined(__cplusplus) && __cplusplus < 201402L
+#if defined(__OPENMP_NVPTX__) && defined(__cplusplus) && __cplusplus < 201402L
 #define __DEVICE_VOID__ static __attribute__((always_inline, nothrow))
 #else
 #define __DEVICE_VOID__ __DEVICE__


Index: clang/lib/Headers/__clang_cuda_math.h
===
--- clang/lib/Headers/__clang_cuda_math.h
+++ clang/lib/Headers/__clang_cuda_math.h
@@ -36,7 +36,7 @@
 // because the OpenMP overlay requires constexpr functions here but prior to
 // c++14 void return functions could not be constexpr.
 #pragma push_macro("__DEVICE_VOID__")
-#ifdef __OPENMP_NVPTX__ && defined(__cplusplus) && __cplusplus < 201402L
+#if defined(__OPENMP_NVPTX__) && defined(__cplusplus) && __cplusplus < 201402L
 #define __DEVICE_VOID__ static __attribute__((always_inline, nothrow))
 #else
 #define __DEVICE_VOID__ __DEVICE__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158021: [clang][modules] Mark builtin header 'inttypes.h' for modules

2023-08-15 Thread Ian Anderson via Phabricator via cfe-commits
iana added a subscriber: vsapsai.
iana added a comment.
Herald added a subscriber: ormris.

Can you add @vsapsai to the reviewers please? He was looking at this one a year 
or two ago.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158021

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


[PATCH] D158021: [clang][modules] Mark builtin header 'inttypes.h' for modules

2023-08-15 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: iana, jansvoboda11.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Like the other enumerated builtin headers, inttypes.h can be declared by 
another system module.

rdar://113924039


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158021

Files:
  clang/lib/Lex/ModuleMap.cpp
  clang/test/Modules/Inputs/System/usr/include/module.map
  clang/test/Modules/cstd.m


Index: clang/test/Modules/cstd.m
===
--- clang/test/Modules/cstd.m
+++ clang/test/Modules/cstd.m
@@ -28,3 +28,11 @@
 #  error "bool was not defined!"
 #endif
 
+// Supplied by compiler, which forwards to the "/usr/include" version.
+@import cstd.inttypes;
+#ifndef __CLANG_INTTYPES_H
+#error "__CLANG_INTTYPES_H was not defined!"
+#endif
+#ifndef MY_PRIi32
+#error "MY_PRIi32 was not defined!"
+#endif
Index: clang/test/Modules/Inputs/System/usr/include/module.map
===
--- clang/test/Modules/Inputs/System/usr/include/module.map
+++ clang/test/Modules/Inputs/System/usr/include/module.map
@@ -4,6 +4,11 @@
 header "float.h"
   }
 
+  // In both directories (compiler support version wins, forwards)
+  module inttypes {
+header "inttypes.h"
+  }
+
   // Only in system headers directory
   module stdio {
 header "stdio.h"
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -379,6 +379,7 @@
 bool ModuleMap::isBuiltinHeader(StringRef FileName) {
   return llvm::StringSwitch(FileName)
.Case("float.h", true)
+   .Case("inttypes.h", true)
.Case("iso646.h", true)
.Case("limits.h", true)
.Case("stdalign.h", true)


Index: clang/test/Modules/cstd.m
===
--- clang/test/Modules/cstd.m
+++ clang/test/Modules/cstd.m
@@ -28,3 +28,11 @@
 #  error "bool was not defined!"
 #endif
 
+// Supplied by compiler, which forwards to the "/usr/include" version.
+@import cstd.inttypes;
+#ifndef __CLANG_INTTYPES_H
+#error "__CLANG_INTTYPES_H was not defined!"
+#endif
+#ifndef MY_PRIi32
+#error "MY_PRIi32 was not defined!"
+#endif
Index: clang/test/Modules/Inputs/System/usr/include/module.map
===
--- clang/test/Modules/Inputs/System/usr/include/module.map
+++ clang/test/Modules/Inputs/System/usr/include/module.map
@@ -4,6 +4,11 @@
 header "float.h"
   }
 
+  // In both directories (compiler support version wins, forwards)
+  module inttypes {
+header "inttypes.h"
+  }
+
   // Only in system headers directory
   module stdio {
 header "stdio.h"
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -379,6 +379,7 @@
 bool ModuleMap::isBuiltinHeader(StringRef FileName) {
   return llvm::StringSwitch(FileName)
.Case("float.h", true)
+   .Case("inttypes.h", true)
.Case("iso646.h", true)
.Case("limits.h", true)
.Case("stdalign.h", true)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated

2023-08-15 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

Thanks for the feedback.




Comment at: clang/test/SemaCXX/warn-constant-evaluated-constexpr.cpp:38
 constexpr int fn5() {
-  if constexpr (__builtin_is_constant_evaluated()) // expected-warning 
{{'__builtin_is_constant_evaluated' will always evaluate to 'true' in a 
manifestly constant-evaluated expression}}
+  if constexpr (__builtin_is_constant_evaluated()) // expected-warning 
{{'__builtin_is_constant_evaluated' will always evaluate to true in this 
context}}
 return 0;

cjdb wrote:
> This should also generate a fix-it hint, since we can automate the fix.
I think it's reasonable to show fix-it hint to remove `constexpr` here.
For that we need to store the source range of `constexpr` in evaluation context 
record if it's constexpr-if condition.



Comment at: clang/test/SemaCXX/warn-tautological-meta-constant.cpp:18
+  } else {
+if constexpr (std::is_constant_evaluated()) { // expected-warning {{always 
evaluate to true}}
+  return 0;

cjdb wrote:
> I'm not a fan of this diagnostic text: it doesn't offer insight into what's 
> gone wrong or provide actionable feedback on how to fix the code.
I agree that the current wording (`... will always evaluate to true in this 
context`) is not great, but I'm not sure how to improve it because the reason 
to see this diagnostic would mostly be a misunderstanding of the C++ const 
semantics.
At least, if the appearance of `is_constant_evaluated` is in the condition of 
constexpr-if, probably we can say they should remove `constexpr`.
CC @aaron.ballman 


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

https://reviews.llvm.org/D155064

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


[clang] cda3198 - [clang] Add missing field to TLSModelAttr json AST dump

2023-08-15 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-08-15T22:24:42+02:00
New Revision: cda319851fe7facf603c3930d5587e127d46b3b7

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

LOG: [clang] Add missing field to TLSModelAttr json AST dump

Recommit with test case updated.

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

Added: 


Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp
clang/test/AST/ast-dump-attr-json.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 03c903069ad877..0ce272df8df65b 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -214,6 +214,7 @@ class JSONNodeDumper
   void VisitUnavailableAttr(const UnavailableAttr *UA);
   void VisitSectionAttr(const SectionAttr *SA);
   void VisitVisibilityAttr(const VisibilityAttr *VA);
+  void VisitTLSModelAttr(const TLSModelAttr *TA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 134938a1ef19a0..139dfce41e914c 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -559,6 +559,10 @@ void JSONNodeDumper::VisitVisibilityAttr(const 
VisibilityAttr *VA) {
   VA->getVisibility()));
 }
 
+void JSONNodeDumper::VisitTLSModelAttr(const TLSModelAttr *TA) {
+  JOS.attribute("tls_model", TA->getModel());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())

diff  --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
index 059ac488cc31d5..051c2956abfdf7 100644
--- a/clang/test/AST/ast-dump-attr-json.cpp
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -19,6 +19,7 @@ __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
 __attribute__ ((visibility ("hidden"))) int visibility_var;
 
+__thread __attribute__ ((tls_model ("local-exec"))) int tls_model_var;
 
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
@@ -479,3 +480,51 @@ __attribute__ ((visibility ("hidden"))) int visibility_var;
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 748,
+// CHECK-NEXT:   "line": 22,
+// CHECK-NEXT:   "col": 57,
+// CHECK-NEXT:   "tokLen": 13
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 692,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 8
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 748,
+// CHECK-NEXT:"col": 57,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "tls_model_var",
+// CHECK-NEXT:  "mangledName": "tls_model_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "tls": "static",
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "TLSModelAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 717,
+// CHECK-NEXT:  "col": 26,
+// CHECK-NEXT:  "tokLen": 9
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 740,
+// CHECK-NEXT:  "col": 49,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"tls_model": "local-exec"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }



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


[PATCH] D158006: [Clang][WIP]Experimental implementation of data member packs in dependent context.

2023-08-15 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:3292
+  std::string NewFieldName =
+  PackedField->getName().str() + "@" + std::to_string(Arg);
+  PackedField->setDeclName(&Context.Idents.get(NewFieldName));

Does LLVM have some form of `absl::StrCat` that we can use instead of 
`operator+`?



Comment at: clang/lib/Sema/TreeTransform.h:4191-4218
+  // Transform unexpanded field name and create a new member 
expression.
+  DeclarationName ExpandedName = &SemaRef.Context.Idents.get(
+  UnExpanedNameStr + "@" + std::to_string(Arg));
+  // Construct name info with new name and keep other members the same.
+  DeclarationNameInfo ExpandedNameInfo = DeclarationNameInfo(
+  ExpandedName, MemberExpr->getMemberNameInfo().getLoc(),
+  MemberExpr->getMemberNameInfo().getInfo());

It may be worth putting this into its own named function to help with 
readability.



Comment at: clang/test/CodeGenCXX/data_member_packs.cpp:73
+  // CHECK: i32 @_Z3sumIJiiEEDaDpT_(i32 noundef %ts, i32 noundef %ts1)
+  sum_pack2(s6);
+  // Check instantiation of sum(int, long, float, double)

This needs to be passed to one of the sum functions and checked that it's 
generating the correct code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158006

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


[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-15 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 550443.
hazohelet added a comment.

Removed warning fixes that are now in D158016 


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

https://reviews.llvm.org/D152495

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/warn-unused-variables.cpp

Index: clang/test/SemaCXX/warn-unused-variables.cpp
===
--- clang/test/SemaCXX/warn-unused-variables.cpp
+++ clang/test/SemaCXX/warn-unused-variables.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++14-extensions -Wno-c++17-extensions -verify -std=c++11 %s
 template void f() {
   T t;
   t = 17;
@@ -294,3 +294,115 @@
 }
 
 } // namespace gh54489
+
+namespace inside_condition {
+  void ifs() {
+if (int hoge = 0) // expected-warning {{unused variable 'hoge'}}
+  return;
+if (const int const_hoge = 0) // expected-warning {{unused variable 'const_hoge'}}
+  return;
+else if (int fuga = 0)
+  (void)fuga;
+else if (int used = 1; int catched = used) // expected-warning {{unused variable 'catched'}}
+  return;
+else if (int refed = 1; int used = refed)
+  (void)used;
+else if (int unused1 = 2; int unused2 = 3) // expected-warning {{unused variable 'unused1'}} \
+   // expected-warning {{unused variable 'unused2'}}
+  return;
+else if (int unused = 4; int used = 5) // expected-warning {{unused variable 'unused'}}
+  (void)used;
+else if (int used = 6; int unused = 7) // expected-warning {{unused variable 'unused'}}
+  (void)used;
+else if (int used1 = 8; int used2 = 9)
+  (void)(used1 + used2);
+else if (auto [a, b] = (int[2]){ 1, 2 }; 1) // expected-warning {{unused variable '[a, b]'}}
+  return;
+else if (auto [a, b] = (int[2]){ 1, 2 }; a)
+  return;
+  }
+
+  void fors() {
+for (int i = 0;int unused = 0;); // expected-warning {{unused variable 'i'}} \
+ // expected-warning {{unused variable 'unused'}}
+for (int i = 0;int used = 0;) // expected-warning {{unused variable 'i'}}
+  (void)used;
+  while(int var = 1) // expected-warning {{unused variable 'var'}}
+return;
+  }
+
+  void whiles() {
+while(int unused = 1) // expected-warning {{unused variable 'unused'}}
+  return;
+while(int used = 1)
+  (void)used;
+  }
+
+
+  void switches() {
+switch(int unused = 1) { // expected-warning {{unused variable 'unused'}}
+  case 1: return;
+}
+switch(constexpr int used = 3; int unused = 4) { // expected-warning {{unused variable 'unused'}}
+  case used: return;
+}
+switch(int used = 3; int unused = 4) { // expected-warning {{unused variable 'unused'}}
+  case 3: (void)used;
+}
+switch(constexpr int used1 = 0; constexpr int used2 = 6) {
+  case (used1+used2): return;
+}
+switch(auto [a, b] = (int[2]){ 1, 2 }; 1) { // expected-warning {{unused variable '[a, b]'}}
+  case 1: return;
+}
+switch(auto [a, b] = (int[2]){ 1, 2 }; b) {
+  case 1: return;
+}
+switch(auto [a, b] = (int[2]){ 1, 2 }; 1) {
+  case 1: (void)a;
+}
+  }
+  template 
+  struct Vector {
+void doIt() {
+  for (auto& e : elements){} // expected-warning {{unused variable 'e'}}
+}
+T elements[10];
+  };
+  void ranged_for() {
+Vectorvector;
+vector.doIt(); // expected-note {{here}}
+  }
+
+
+  struct RAII {
+int &x;
+RAII(int &ref) : x(ref) {}
+~RAII() { x = 0;}
+operator int() const { return 1; }
+  };
+  void aggregate() {
+int x = 10;
+int y = 10;
+if (RAII var = x) {}
+for(RAII var = x; RAII var2 = y;) {}
+while (RAII var = x) {}
+switch (RAII var = x) {}
+  }
+
+  struct TrivialDtor{
+int &x;
+TrivialDtor(int &ref) : x(ref) { ref = 32; }
+operator int() const { return 1; }
+  };
+  void trivial_dtor() {
+int x = 10;
+int y = 10;
+if (TrivialDtor var = x) {} // expected-warning {{unused variable 'var'}}
+for(TrivialDtor var = x; TrivialDtor var2 = y;) {} // expected-warning {{unused variable 'var'}} \
+ // expected-warning {{unused variable 'var2'}}
+while (TrivialDtor var = x) {} // expected-warning {{unused variable 'var'}}
+switch (TrivialDtor var = x) {} // expected-warning {{unused variable 'var'}}
+  }
+
+} // namespace inside_condition
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- c

[PATCH] D157150: [Driver] Update BoolOption to handle Visibility. NFC

2023-08-15 Thread Justin Bogner via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0db9dfb19329: [Driver] Update BoolOption to handle 
Visibility. NFC (authored by bogner).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157150

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td

Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -79,6 +79,23 @@
 // target will lead to an err_drv_unsupported_opt_for_target error.
 def TargetSpecific : OptionFlag;
 
+// Indicates that this warning is ignored, but accepted with a warning for
+// GCC compatibility.
+class IgnoredGCCCompat : Flags<[HelpHidden]> {}
+
+class TargetSpecific : Flags<[TargetSpecific]> {}
+
+/
+// Visibility
+
+// We prefer the name "ClangOption" here rather than "Default" to make
+// it clear that these options will be visible in the clang driver (as
+// opposed to clang -cc1, the CL driver, or the flang driver).
+defvar ClangOption = DefaultVis;
+
+/
+// Docs
+
 // A short name to show in documentation. The name will be interpreted as rST.
 class DocName { string DocName = name; }
 
@@ -89,12 +106,6 @@
 // documentation.
 class DocFlatten { bit DocFlatten = 1; }
 
-// Indicates that this warning is ignored, but accepted with a warning for
-// GCC compatibility.
-class IgnoredGCCCompat : Flags<[HelpHidden]> {}
-
-class TargetSpecific : Flags<[TargetSpecific]> {}
-
 /
 // Groups
 
@@ -381,7 +392,8 @@
 
 // Definition of single command line flag. This is an implementation detail, use
 // SetTrueBy or SetFalseBy instead.
-class FlagDef option_flags,
+class FlagDef option_flags, list option_vis,
   string help, list implied_by_expressions = []> {
   // The polarity. Besides spelling, this also decides whether the TableGen
   // record will be prefixed with "no_".
@@ -390,9 +402,12 @@
   // The value assigned to key path when the flag is present on command line.
   bit Value = value;
 
-  // OptionFlags that control visibility of the flag in different tools.
+  // OptionFlags in different tools.
   list OptionFlags = option_flags;
 
+  // OptionVisibility flags for different tools.
+  list OptionVisibility = option_vis;
+
   // The help text associated with the flag.
   string Help = help;
 
@@ -401,8 +416,11 @@
 }
 
 // Additional information to be appended to both positive and negative flag.
-class BothFlags option_flags, string help = ""> {
+class BothFlags option_flags,
+list option_vis = [ClangOption],
+string help = ""> {
   list OptionFlags = option_flags;
+  list OptionVisibility = option_vis;
   string Help = help;
 }
 
@@ -411,23 +429,26 @@
   FlagDef Result
 = FlagDef;
 }
 
 // Definition of the command line flag with positive spelling, e.g. "-ffoo".
-class PosFlag flags = [], string help = "",
-  list implied_by_expressions = []>
-  : FlagDef {}
+class PosFlag flags = [], list vis = [],
+  string help = "", list implied_by_expressions = []>
+  : FlagDef {}
 
 // Definition of the command line flag with negative spelling, e.g. "-fno-foo".
-class NegFlag flags = [], string help = "",
-  list implied_by_expressions = []>
-  : FlagDef {}
+class NegFlag flags = [], list vis = [],
+  string help = "", list implied_by_expressions = []>
+  : FlagDef {}
 
 // Expanded FlagDef that's convenient for creation of TableGen records.
 class FlagDefExpanded
-  : FlagDef {
+  : FlagDef {
   // Name of the TableGen record.
   string RecordName = prefix # !if(flag.Polarity, "", "no_") # name;
 
@@ -445,7 +466,8 @@
 class MarshalledFlagRec
-  : Flag<["-"], flag.Spelling>, Flags, HelpText,
+  : Flag<["-"], flag.Spelling>, Flags,
+Visibility, HelpText,
 MarshallingInfoBooleanFlag,
 ImpliedByAnyOf {}
@@ -459,7 +481,7 @@
 multiclass BoolOption> {
+  BothFlags suffix = BothFlags<[]>> {
   defvar flag1 = FlagDefExpanded.Result, prefix,
  NAME, spelling_base>;
 
@@ -490,7 +512,7 @@
 /// CompilerInvocation.
 multiclass BoolFOption> {
+   BothFlags both = BothFlags<[]>> {
   defm NAME : BoolOption<"f", flag_base, kpm, default, flag1, flag2, both>,
   Group;
 }
@@ -501,7 +523,7 @@
 // CompilerInvocation.
 multiclass BoolGOption> {
+   BothFlags both = BothFlags<[]>> {
   defm NAME : BoolOption<"g", flag_base, kpm, default, flag1, flag2, both>,
   Group;
 }
@@ -509,7 +531,7 @@
 // Works like BoolOption except without marshalling
 multiclass BoolOptionWithoutMarshalling> {
+BothFlags suffix = BothFlags<[]>> {
   defvar flag1 = FlagDefExpanded.Result, prefix,

[PATCH] D158016: [NFC] Remove unused variables declared in conditions

2023-08-15 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet created this revision.
hazohelet added reviewers: nikic, aaron.ballman, MaskRay, tbaeder.
Herald added subscribers: hoy, wlei, steakhal, abrachet, ormris, StephenFan, 
martong, hiraditya.
Herald added a reviewer: NoQ.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
hazohelet requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wangpc.
Herald added projects: clang, LLVM.

D152495  makes clang warn on unused variables 
that are declared in conditions like `if (int var = init) {}`
This patch is an NFC fix to suppress the new warning in llvm,clang,lld builds 
to pass CI in the above patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158016

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Yaml.h
  clang/tools/clang-scan-deps/ClangScanDeps.cpp
  lld/MachO/Driver.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
  llvm/lib/IR/PrintPasses.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp

Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -812,7 +812,7 @@
   // Handles DWO sections that can either be in .o, .dwo or .dwp files.
   for (const auto &CompilationUnit : DebugContext->compile_units()) {
 DWARFUnit *const DwarfUnit = CompilationUnit.get();
-if (std::optional DWOId = DwarfUnit->getDWOId()) {
+if (DwarfUnit->getDWOId()) {
   DWARFUnit *DWOCU = DwarfUnit->getNonSkeletonUnitDIE(false).getDwarfUnit();
   if (!DWOCU->isDWOUnit()) {
 std::string DWOName = dwarf::toString(
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9178,7 +9178,7 @@
 VecOp = FMulRecipe;
   } else {
 if (RecurrenceDescriptor::isMinMaxRecurrenceKind(Kind)) {
-  if (auto *Cmp = dyn_cast(CurrentLink)) {
+  if (isa(CurrentLink)) {
 assert(isa(CurrentLinkI) &&
"need to have the compare of the select");
 continue;
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1337,7 +1337,7 @@
   SmallString<256> Path;
   Path_.toVector(Path);
 
-  if (std::error_code EC = makeCanonical(Path))
+  if (makeCanonical(Path))
 return {};
 
   return ExternalFS->isLocal(Path, Result);
Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -501,7 +501,7 @@
   static SmallVector FD{-1};
   SmallVector SR{S};
   static SmallVector FileName{""};
-  if (auto Err = prepareTempFiles(FD, SR, FileName)) {
+  if (prepareTempFiles(FD, SR, FileName)) {
 dbgs() << "Unable to create temporary file.";
 return;
   }
@@ -518,7 +518,7 @@
 return;
   }
 
-  if (auto Err = cleanUpTempFiles(FileName))
+  if (cleanUpTempFiles(FileName))
 dbgs() << "Unable to remove temporary file.";
 }
 
Index: llvm/lib/IR/PrintPasses.cpp
===
--- llvm/lib/IR/PrintPasses.cpp
+++ llvm/lib/IR/PrintPasses.cpp
@@ -212,7 +212,7 @@
   static SmallVector FD{-1, -1, -1};
   SmallVector SR{Before, After};
   static SmallVector FileName{"", "", ""};
-  if (auto Err = prepareTempFiles(FD, SR, FileName))
+  if (prepareTempFiles(FD, SR, FileName))
 return "Unable to create temporary file.";
 
   static ErrorOr DiffExe = sys::findProgramByName(DiffBinary);
@@ -238,7 +238,7 @@
   else
 return "Unable to read result.";
 
-  if (auto Err = cleanUpTempFiles(FileName))
+  if (cleanUpTempFiles(FileName))
 return "Unable to remove temporary file.";
 
   return Diff;
Index: llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
===
--- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
+++ llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
@@ -462,7 +462,7 @@
   size_t NumBefore = Gsym.getNumFunctionInfos();
  

[PATCH] D157994: [OpenMP] Migrate dispatch related utility functions from Clang codegen to OMPIRBuilder

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

LG, but do not remove the Attribute from our set, add it to the tests. The 
functions are nounwind.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:532
MemoryAttr(MemoryEffects::argMemOnly() | 
MemoryEffects::inaccessibleMemOnly(ModRefInfo::Ref)))
-: AttributeSet(EnumAttr(NoUnwind)))
 __OMP_ATTRS_SET(

TIFitis wrote:
> Clang test //llvm/clang/test/OpenMP/ordered_codegen.cpp// complains about the 
> presence of `NoUnwind` attribute for the `__kmpc_dispatch_*` functions.
> 
> This change doesn't seem to break any other test, although I am not sure if 
> we should be creating a new `Attr` group for the `__kmpc_dispatch` functions 
> and remove the `NoUnwind` `Attr` only there.
Add nounwind to the tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157994

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


[PATCH] D157379: [CodeGen] Restrict addEmittedDeferredDecl to incremental extensions

2023-08-15 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

Thank you, this seems reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157379

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


[PATCH] D156537: [CodeGen] Keep track of eagerly emitted globals

2023-08-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

If we're avoiding the expense here when we're not emitting incremental 
extensions, this seems fine to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156537

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


[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-15 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Please split the warning fixes off into a separate patch.


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

https://reviews.llvm.org/D152495

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


[PATCH] D157479: [Clang][DebugInfo] Emit narrower base types for structured binding declarations that bind to struct bitfields

2023-08-15 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

New test LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157479

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


[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-08-15 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 550433.
hazohelet added a comment.
Herald added subscribers: llvm-commits, wangpc, hoy, wlei, steakhal, abrachet, 
ormris, martong, MaskRay, hiraditya.
Herald added a reviewer: NoQ.
Herald added projects: LLVM, lld-macho.
Herald added a reviewer: lld-macho.

Fixed newly-issued warnings when trying 
`check-clang,llvm,lld,compiler-rt,cxx,cxxabi` with `-Werror=unused-variable` 
locally using local build of clang


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

https://reviews.llvm.org/D152495

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Yaml.h
  clang/test/SemaCXX/warn-unused-variables.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp
  lld/MachO/Driver.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
  llvm/lib/IR/PrintPasses.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp

Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -812,7 +812,7 @@
   // Handles DWO sections that can either be in .o, .dwo or .dwp files.
   for (const auto &CompilationUnit : DebugContext->compile_units()) {
 DWARFUnit *const DwarfUnit = CompilationUnit.get();
-if (std::optional DWOId = DwarfUnit->getDWOId()) {
+if (DwarfUnit->getDWOId()) {
   DWARFUnit *DWOCU = DwarfUnit->getNonSkeletonUnitDIE(false).getDwarfUnit();
   if (!DWOCU->isDWOUnit()) {
 std::string DWOName = dwarf::toString(
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9178,7 +9178,7 @@
 VecOp = FMulRecipe;
   } else {
 if (RecurrenceDescriptor::isMinMaxRecurrenceKind(Kind)) {
-  if (auto *Cmp = dyn_cast(CurrentLink)) {
+  if (isa(CurrentLink)) {
 assert(isa(CurrentLinkI) &&
"need to have the compare of the select");
 continue;
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1337,7 +1337,7 @@
   SmallString<256> Path;
   Path_.toVector(Path);
 
-  if (std::error_code EC = makeCanonical(Path))
+  if (makeCanonical(Path))
 return {};
 
   return ExternalFS->isLocal(Path, Result);
Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -501,7 +501,7 @@
   static SmallVector FD{-1};
   SmallVector SR{S};
   static SmallVector FileName{""};
-  if (auto Err = prepareTempFiles(FD, SR, FileName)) {
+  if (prepareTempFiles(FD, SR, FileName)) {
 dbgs() << "Unable to create temporary file.";
 return;
   }
@@ -518,7 +518,7 @@
 return;
   }
 
-  if (auto Err = cleanUpTempFiles(FileName))
+  if (cleanUpTempFiles(FileName))
 dbgs() << "Unable to remove temporary file.";
 }
 
Index: llvm/lib/IR/PrintPasses.cpp
===
--- llvm/lib/IR/PrintPasses.cpp
+++ llvm/lib/IR/PrintPasses.cpp
@@ -212,7 +212,7 @@
   static SmallVector FD{-1, -1, -1};
   SmallVector SR{Before, After};
   static SmallVector FileName{"", "", ""};
-  if (auto Err = prepareTempFiles(FD, SR, FileName))
+  if (prepareTempFiles(FD, SR, FileName))
 return "Unable to create temporary file.";
 
   static ErrorOr DiffExe = sys::findProgramByName(DiffBinary);
@@ -238,7 +238,7 @@
   else
 return "Unable to read result.";
 
-  if (auto Err = cleanUpTempFiles(FileName))
+  if (cleanUpTempFiles(FileName))
 return "Unable to remove temporary file.";
 
   return Diff;
Index: llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
===
--- llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
+++ llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
@@ -462,7 +462,7 @@
   size_t NumBefore = Gsym.getNumFunctionInfos();
   auto getDie = [&](DWARFUnit 

[PATCH] D156537: [CodeGen] Keep track of eagerly emitted globals

2023-08-15 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D156537#4587874 , @aaron.ballman 
wrote:

> In D156537#4587832 , @v.g.vassilev 
> wrote:
>
>> @Hahnfeld, let's move forward and rely on a post-commit review here if 
>> necessary.
>
> Because one of the codegen code owners has been active on the thread with 
> concerns, I think it's better to wait a bit longer for an explicit sign-off 
> that those concerns are addressed (this code impacts more than clang-repl).

D157379  seems to resolve the concern but 
indeed we can wait a little longer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156537

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


[PATCH] D156897: [CodeGen] Clean up access to EmittedDeferredDecls, NFCI.

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

This looks reasonable to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156897

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


[PATCH] D157750: Properly handle -fsplit-machine-functions for fatbinary compilation

2023-08-15 Thread Han Shen via Phabricator via cfe-commits
shenhan marked 3 inline comments as done.
shenhan added inline comments.



Comment at: llvm/lib/CodeGen/TargetPassConfig.cpp:1278
 }
-addPass(createMachineFunctionSplitterPass());
+if (TM->getTargetTriple().isX86())
+  addPass(createMachineFunctionSplitterPass());

shenhan wrote:
> snehasish wrote:
> > Can you coordinate with @dhoekwater ? He has some patches in flight for 
> > AArch64. 
> > 
> > I think D157157 is the one which modifies the same logic.
> Thanks. Yes, I'll coordinate with @dhoekwater before resolving this.
@dhoekwater will rebase D157157 on top of this.



Comment at: llvm/test/CodeGen/X86/mfs-triple.ll:8
+
+define void @foo4(i1 zeroext %0, i1 zeroext %1) nounwind {
+  br i1 %0, label %3, label %7

snehasish wrote:
> Any reason why we can't use the bitcode already in 
> test/CodeGen/machine-function-splitter.ll? (Going to be moved to 
> test/Generic/machine-function-splitter.ll in D157563)
> 
> IMO we can just reuse the basic test and add these run and check lines.
Moved the tests into machine-function-splitter.ll. Either this CL or D157563 
can be submitted first, and the other will rebase on top of that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157750

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


[PATCH] D157750: Properly handle -fsplit-machine-functions for fatbinary compilation

2023-08-15 Thread Han Shen via Phabricator via cfe-commits
shenhan updated this revision to Diff 550423.
shenhan marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157750

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsplit-machine-functions-with-cuda-nvptx.c
  clang/test/Driver/fsplit-machine-functions.c
  clang/test/Driver/fsplit-machine-functions2.c
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/lib/CodeGen/MachineFunctionSplitter.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/test/CodeGen/X86/machine-function-splitter.ll

Index: llvm/test/CodeGen/X86/machine-function-splitter.ll
===
--- llvm/test/CodeGen/X86/machine-function-splitter.ll
+++ llvm/test/CodeGen/X86/machine-function-splitter.ll
@@ -5,6 +5,15 @@
 ; RUN: sed 's/InstrProf/SampleProfile/g' %s > %t.ll
 ; RUN: llc < %t.ll -mtriple=x86_64-unknown-linux-gnu -split-machine-functions | FileCheck %s --check-prefix=FSAFDO-MFS
 ; RUN: llc < %t.ll -mtriple=x86_64-unknown-linux-gnu -split-machine-functions | FileCheck %s --check-prefix=FSAFDO-MFS2
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -debug-pass=Structure -fs-profile-file=%S/Inputs/fsloader-mfs.afdo -enable-fs-discriminator=true -improved-fs-discriminator=true -split-machine-functions 2>&1 | FileCheck %s --check-prefix=MFS_ON
+; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu -debug-pass=Structure -fs-profile-file=%S/Inputs/fsloader-mfs.afdo -enable-fs-discriminator=true -improved-fs-discriminator=true -split-machine-functions 2>&1 | FileCheck %s --check-prefix=MFS_OFF
+
+;; Check that MFS is on for X86 targets.
+; MFS_ON: Machine Function Splitter Transformation
+; MFS_ON_NO: warning: -fsplit-machine-functions is not valid for
+;; Check that MFS is not on for non-X86 targets.
+; MFS_OFF: warning: -fsplit-machine-functions is not valid for
+; MFS_OFF_NO: Machine Function Splitter Transformation
 
 define void @foo1(i1 zeroext %0) nounwind !prof !14 !section_prefix !15 {
 ;; Check that cold block is moved to .text.split.
Index: llvm/lib/IR/DiagnosticInfo.cpp
===
--- llvm/lib/IR/DiagnosticInfo.cpp
+++ llvm/lib/IR/DiagnosticInfo.cpp
@@ -449,3 +449,7 @@
   if (!getNote().empty())
 DP << ": " << getNote();
 }
+
+void DiagnosticInfoMachineFunctionSplit::print(DiagnosticPrinter &DP) const {
+  DP << "-fsplit-machine-functions is not valid for " << TargetTriple;
+}
Index: llvm/lib/CodeGen/MachineFunctionSplitter.cpp
===
--- llvm/lib/CodeGen/MachineFunctionSplitter.cpp
+++ llvm/lib/CodeGen/MachineFunctionSplitter.cpp
@@ -35,9 +35,11 @@
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Function.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/TargetParser/Triple.h"
 #include 
 
 using namespace llvm;
@@ -82,6 +84,13 @@
   void getAnalysisUsage(AnalysisUsage &AU) const override;
 
   bool runOnMachineFunction(MachineFunction &F) override;
+
+  bool doInitialization(Module &) override;
+
+  static bool isSupportedTriple(const Triple &T) { return T.isX86(); }
+
+private:
+  bool UnsupportedTriple = false;
 };
 } // end anonymous namespace
 
@@ -127,7 +136,20 @@
   return (*Count < ColdCountThreshold);
 }
 
+bool MachineFunctionSplitter::doInitialization(Module &M) {
+  StringRef T = M.getTargetTriple();
+  if (!isSupportedTriple(Triple(T))) {
+UnsupportedTriple = true;
+M.getContext().diagnose(
+DiagnosticInfoMachineFunctionSplit(T, DS_Warning));
+return false;
+  }
+  return MachineFunctionPass::doInitialization(M);
+}
+
 bool MachineFunctionSplitter::runOnMachineFunction(MachineFunction &MF) {
+  if (UnsupportedTriple)
+return false;
   // We target functions with profile data. Static information in the form
   // of exception handling code may be split to cold if user passes the
   // mfs-split-ehcode flag.
Index: llvm/include/llvm/IR/DiagnosticInfo.h
===
--- llvm/include/llvm/IR/DiagnosticInfo.h
+++ llvm/include/llvm/IR/DiagnosticInfo.h
@@ -86,6 +86,7 @@
   DK_SrcMgr,
   DK_DontCall,
   DK_MisExpect,
+  DK_MachineFunctionSplit,
   DK_FirstPluginKind // Must be last value to work with
  // getNextAvailablePluginDiagnosticKind
 };
@@ -1117,6 +1118,20 @@
   }
 };
 
+class DiagnosticInfoMachineFunctionSplit : public DiagnosticInfo {
+  StringRef TargetTriple;
+
+public:
+  DiagnosticInfoMachineFunctionSplit(StringRef TargetTriple,
+ DiagnosticSeverity DS)
+  : DiagnosticInfo(DK_MachineFunctionSplit, DS),
+TargetTriple(TargetTriple) {}
+  void print(Diagnost

[PATCH] D74094: Reapply: [IRGen] Emit lifetime intrinsics around temporary aggregate argument allocas

2023-08-15 Thread Lei Huang via Phabricator via cfe-commits
lei added a comment.

@nickdesaulniers I have verified this patch on top of 
`40ee8abee77a2e8fb0089d4c7f5723b71f27d416` passes our multistage bot 
http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage

Thank-you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74094

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


[PATCH] D151567: [LLVM][Support] Report EISDIR when opening a directory on AIX

2023-08-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

Thanks for the patch, but there are two issues that should be fixed:

(1) stat => fstat
(2) change the subject to mean that this is not AIX specific (`[LLVM][Support] 
Report EISDIR when opening a directory on AIX`). Other OSes including Linux are 
changed as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151567

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


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Yonggang Luo via Phabricator via cfe-commits
lygstate updated this revision to Diff 550413.
lygstate added a comment.

creating proper function definitions instead of macro define


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

https://reviews.llvm.org/D157297

Files:
  clang/lib/Headers/bmiintrin.h

Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -19,8 +19,7 @@
to use it as a potentially faster version of BSF. */
 #define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 
-#define _tzcnt_u16(a) (__tzcnt_u16((a)))
-
+/* AMD-specified, double-leading-underscore version of TZCNT */
 /// Counts the number of trailing zero bits in the operand.
 ///
 /// \headerfile 
@@ -31,12 +30,32 @@
 ///An unsigned 16-bit integer whose trailing zeros are to be counted.
 /// \returns An unsigned 16-bit integer containing the number of trailing zero
 ///bits in the operand.
+/// \see _tzcnt_u16
 static __inline__ unsigned short __RELAXED_FN_ATTRS
 __tzcnt_u16(unsigned short __X)
 {
   return __builtin_ia32_tzcnt_u16(__X);
 }
 
+/* Intel-specified, single-leading-underscore version of TZCNT */
+/// Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  TZCNT  instruction.
+///
+/// \param __X
+///An unsigned 16-bit integer whose trailing zeros are to be counted.
+/// \returns An unsigned 16-bit integer containing the number of trailing zero
+///bits in the operand.
+/// \see __tzcnt_u16
+static __inline__ unsigned short __RELAXED_FN_ATTRS
+_tzcnt_u16(unsigned short __X)
+{
+  return __builtin_ia32_tzcnt_u16(__X);
+}
+
+/* AMD-specified, double-leading-underscore version of TZCNT */
 /// Counts the number of trailing zero bits in the operand.
 ///
 /// \headerfile 
@@ -47,13 +66,31 @@
 ///An unsigned 32-bit integer whose trailing zeros are to be counted.
 /// \returns An unsigned 32-bit integer containing the number of trailing zero
 ///bits in the operand.
-/// \see _mm_tzcnt_32
+/// \see _tzcnt_u32
 static __inline__ unsigned int __RELAXED_FN_ATTRS
 __tzcnt_u32(unsigned int __X)
 {
   return __builtin_ia32_tzcnt_u32(__X);
 }
 
+/* Intel-specified, single-leading-underscore version of TZCNT */
+/// Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  TZCNT  instruction.
+///
+/// \param __X
+///An unsigned 32-bit integer whose trailing zeros are to be counted.
+/// \returns An unsigned 32-bit integer containing the number of trailing zero
+///bits in the operand.
+/// \see __tzcnt_u32
+static __inline__ unsigned int __RELAXED_FN_ATTRS
+_tzcnt_u32(unsigned int __X)
+{
+  return __builtin_ia32_tzcnt_u32(__X);
+}
+
 /// Counts the number of trailing zero bits in the operand.
 ///
 /// \headerfile 
@@ -71,10 +108,9 @@
   return (int)__builtin_ia32_tzcnt_u32(__X);
 }
 
-#define _tzcnt_u32(a) (__tzcnt_u32((a)))
-
 #ifdef __x86_64__
 
+/* AMD-specified, double-leading-underscore version of TZCNT */
 /// Counts the number of trailing zero bits in the operand.
 ///
 /// \headerfile 
@@ -85,13 +121,31 @@
 ///An unsigned 64-bit integer whose trailing zeros are to be counted.
 /// \returns An unsigned 64-bit integer containing the number of trailing zero
 ///bits in the operand.
-/// \see _mm_tzcnt_64
+/// \see _tzcnt_u64
 static __inline__ unsigned long long __RELAXED_FN_ATTRS
 __tzcnt_u64(unsigned long long __X)
 {
   return __builtin_ia32_tzcnt_u64(__X);
 }
 
+/* Intel-specified, single-leading-underscore version of TZCNT */
+/// Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  TZCNT  instruction.
+///
+/// \param __X
+///An unsigned 64-bit integer whose trailing zeros are to be counted.
+/// \returns An unsigned 64-bit integer containing the number of trailing zero
+///bits in the operand.
+/// \see __tzcnt_u64
+static __inline__ unsigned long long __RELAXED_FN_ATTRS
+_tzcnt_u64(unsigned long long __X)
+{
+  return __builtin_ia32_tzcnt_u64(__X);
+}
+
 /// Counts the number of trailing zero bits in the operand.
 ///
 /// \headerfile 
@@ -109,8 +163,6 @@
   return (long long)__builtin_ia32_tzcnt_u64(__X);
 }
 
-#define _tzcnt_u64(a) (__tzcnt_u64((a)))
-
 #endif /* __x86_64__ */
 
 #undef __RELAXED_FN_ATTRS
@@ -121,15 +173,7 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))
 
-#define _andn_u32(a, b)   (__andn_u32((a), (b)))
-
-/* _bextr_u32 != __bextr_u32 */
-#define _blsi_u32(a)  (__blsi_u32((a)))
-
-#define _blsmsk_u32(a)(__blsmsk_u32((a)))
-
-#define _blsr_u32(a)  (__blsr_u32((a)))
-
+/* AMD-specified, double-leading-underscore version of ANDN */
 /// Performs a bitwise AND of the second operand with the one's
 //

[PATCH] D154869: [Flang] [FlangRT] Implement FlangRT library as solution to Flang's runtime LLVM integration

2023-08-15 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro added inline comments.



Comment at: flang/lib/Decimal/CMakeLists.txt:52
 
-add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN
-  binary-to-decimal.cpp
-  decimal-to-binary.cpp
-)
+add_compile_options(-fPIC)
+

efriedma wrote:
> This `add_compile_options(-fPIC)` shouldn't be necessary?
Pretty sure you're right, let me build/test without it to make sure and I'll 
update if everything is alright


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154869

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


[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-08-15 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments.



Comment at: clang/test/Lexer/case-insensitive-include-win.c:5-9
+// Note: We must use the real path here, because the logic to detect case
+// mismatch relies on resolving the real path and checking that casing differs.
+// If we use %t and we are on a substitute drive S: mapping to C:\subst,
+// then we will compare "S:\test.dir\FOO.h" to "C:\subst\test.dir\foo.h"
+// and avoid emitting the diagnostic because the structure is different.

MrTrillian wrote:
> tahonermann wrote:
> > MrTrillian wrote:
> > > tahonermann wrote:
> > > > MrTrillian wrote:
> > > > > tahonermann wrote:
> > > > > > Hmm, is it really desirable or necessary that the case mismatch 
> > > > > > logic resolve substituted drives? I wouldn't think so. This seems 
> > > > > > like another case where our common canonicalization would be 
> > > > > > desired.
> > > > > I think it is necessary as I don't see how else we can retrieve the 
> > > > > original casing of the file path. Merely making the path absolute 
> > > > > would not do that. Searching for solutions on the internet finds 
> > > > > ideas that are worse like converting to a short path then back to a 
> > > > > long path or rebuilding the path one component at a time with a 
> > > > > series directory listing requests.
> > > > The warning this test checks for is diagnosed in 
> > > > `Preprocessor::HandleHeaderIncludeOrImport()`; search for 
> > > > `pp_nonportable_path` and/or `pp_nonportable_system_path`. I believe 
> > > > this warning will be issued if any component of the path does not match 
> > > > the case of the include directive. Since the file name differs in case, 
> > > > unless there is a bug in handling of the file name, this test isn't 
> > > > sensitive to case mismatches in `%t`.
> > > > 
> > > > From a user point of view, resolving a substitute drive doesn't seem 
> > > > desirableto me with respect to determining whether a non-portable path 
> > > > is being used; I don't think the behavior should be dependent on 
> > > > whether a substitute drive is being used or what its target is.
> > > @tahonermann I think the code is working by design and it would be an 
> > > unrelated change to modify its logic. See `trySimplifyPath` in 
> > > `PPDirectives.cpp`:
> > > 
> > > ```
> > >   // Below is a best-effort to handle ".." in paths. It is admittedly
> > >   // not 100% correct in the presence of symlinks.
> > > 
> > > // If these path components differ by more than just case, then we
> > > // may be looking at symlinked paths. Bail on this diagnostic to 
> > > avoid
> > > // noisy false positives.
> > > ```
> > > 
> > > The test was previously implicitly requiring getting the realpath, and it 
> > > worked because `lit.py`'s logic of doing that. Now that requirement is 
> > > explicit in the test.
> > I'm still not following here. Are you saying that `trySimplifyPath()` will 
> > replace substitute drives? If so, that doesn't sound desirable and I would 
> > expect it to be problematic for your use case. I think we should follow 
> > this up ... somewhere (now that this review is closed).
> @tahonermann . `trySimplifyPath()` does not replace substitute drives. It's a 
> best-effort attempt to see if the included path mismatches the real file path 
> only by case. It explicitly bails out without diagnostics if it finds that 
> the included path has a different shape from the real file path, which will 
> happen if the included path is on a substitute drive. It has to compare with 
> the real file path because this is the only reasonable way to get the 
> original path casing.
> 
> It was already the case that this diagnostic bailed out in the presence of 
> symbolic links, so there are no behavioral differences. I needed to update 
> the test because previously `lit.py` would enforce that `%t` was a real path, 
> and now it doesn't, which means that we would hit the "bail out" code path 
> and not produce the diagnostic.
I think `trySimplifyPath()` is not particularly relevant as it just performs a 
simple canonicalization (removal of `.` and `..` path components without regard 
for symlink traversal) and case insensitive comparison with the remaining 
components with a "real" path that is presumed to already be devoid of such 
components. It is therefore sensitive to structure, but only for the (non-`.` 
and non-`..`) components present in the (non-real) `Components` vector; the 
"real" path may have more leading components (the `Components` vector may 
represent a relative path). The presence of a substitute drive in the "real" 
path won't contribute to a structural difference unless the `Components` vector 
is absolute but with a drive other than the substitute drive or if it is 
relative but starting at a higher directory level than the substitute drive; 
neither of which should be the case for this test when `%t` is consistently 
used.

The only relevant user path pro

[PATCH] D158008: [AArch64] Add patterns for FMADD, FMSUB

2023-08-15 Thread OverMighty via Phabricator via cfe-commits
overmighty created this revision.
overmighty added reviewers: dmgreen, john.brawn, SjoerdMeijer.
Herald added subscribers: arphaman, hiraditya, kristof.beyls.
Herald added a project: All.
overmighty requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

FMADD, FMSUB instructions perform better or the same compared to indexed
FMLA, FMLS.

For example, the Arm Cortex-A55 Software Optimization Guide lists "FP
multiply accumulate" FMADD, FMSUB instructions with a throughput of 2
IPC, whereas it lists "ASIMD FP multiply accumulate, by element" FMLA,
FMLS with a throughput of 1 IPC.

The Arm Cortex-A77 Software Optimization Guide, however, does not
separately list "by element" variants of the "ASIMD FP multiply
accumulate" instructions, which are listed with the same throughput of 2
IPC as "FP multiply accumulate" instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158008

Files:
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/test/CodeGen/AArch64/complex-deinterleaving-f16-mul.ll
  llvm/test/CodeGen/AArch64/fp16_intrinsic_lane.ll
  llvm/test/CodeGen/AArch64/neon-scalar-by-elem-fma.ll

Index: llvm/test/CodeGen/AArch64/neon-scalar-by-elem-fma.ll
===
--- llvm/test/CodeGen/AArch64/neon-scalar-by-elem-fma.ll
+++ llvm/test/CodeGen/AArch64/neon-scalar-by-elem-fma.ll
@@ -7,56 +7,90 @@
 declare float @llvm.experimental.constrained.fma.f32(float, float, float, metadata, metadata)
 declare double @llvm.experimental.constrained.fma.f64(double, double, double, metadata, metadata)
 
-define float @test_fmla_ss4S(float %a, float %b, <4 x float> %v) {
-  ; CHECK-LABEL: test_fmla_ss4S
+define float @test_fmla_ss4S_0(float %a, float %b, <4 x float> %v) {
+  ; CHECK-LABEL: test_fmla_ss4S_0
+  ; CHECK: fmadd s0, s1, s2, s0
+  %tmp1 = extractelement <4 x float> %v, i32 0
+  %tmp2 = call float @llvm.fma.f32(float %b, float %tmp1, float %a)
+  ret float %tmp2
+}
+
+define float @test_fmla_ss4S_3(float %a, float %b, <4 x float> %v) {
+  ; CHECK-LABEL: test_fmla_ss4S_3
   ; CHECK: fmla {{s[0-9]+}}, {{s[0-9]+}}, {{v[0-9]+}}.s[3]
   %tmp1 = extractelement <4 x float> %v, i32 3
   %tmp2 = call float @llvm.fma.f32(float %b, float %tmp1, float %a)
   ret float %tmp2
 }
 
-define float @test_fmla_ss4S_swap(float %a, float %b, <4 x float> %v) {
-  ; CHECK-LABEL: test_fmla_ss4S_swap
+define float @test_fmla_ss4S_3_swap(float %a, float %b, <4 x float> %v) {
+  ; CHECK-LABEL: test_fmla_ss4S_3_swap
   ; CHECK: fmla {{s[0-9]+}}, {{s[0-9]+}}, {{v[0-9]+}}.s[3]
   %tmp1 = extractelement <4 x float> %v, i32 3
   %tmp2 = call float @llvm.fma.f32(float %tmp1, float %a, float %a)
   ret float %tmp2
 }
 
-define float @test_fmla_ss2S(float %a, float %b, <2 x float> %v) {
-  ; CHECK-LABEL: test_fmla_ss2S
+define float @test_fmla_ss2S_0(float %a, float %b, <2 x float> %v) {
+  ; CHECK-LABEL: test_fmla_ss2S_0
+  ; CHECK: fmadd s0, s1, s2, s0
+  %tmp1 = extractelement <2 x float> %v, i32 0
+  %tmp2 = call float @llvm.fma.f32(float %b, float %tmp1, float %a)
+  ret float %tmp2
+}
+
+define float @test_fmla_ss2S_1(float %a, float %b, <2 x float> %v) {
+  ; CHECK-LABEL: test_fmla_ss2S_1
   ; CHECK: fmla {{s[0-9]+}}, {{s[0-9]+}}, {{v[0-9]+}}.s[1]
   %tmp1 = extractelement <2 x float> %v, i32 1
   %tmp2 = call float @llvm.fma.f32(float %b, float %tmp1, float %a)
   ret float %tmp2
 }
 
-define double @test_fmla_ddD(double %a, double %b, <1 x double> %v) {
-  ; CHECK-LABEL: test_fmla_ddD
-  ; CHECK: {{fmla d[0-9]+, d[0-9]+, v[0-9]+.d\[0]|fmadd d[0-9]+, d[0-9]+, d[0-9]+, d[0-9]+}}
+define double @test_fmla_ddD_0(double %a, double %b, <1 x double> %v) {
+  ; CHECK-LABEL: test_fmla_ddD_0
+  ; CHECK: fmadd d0, d1, d2, d0
   %tmp1 = extractelement <1 x double> %v, i32 0
   %tmp2 = call double @llvm.fma.f64(double %b, double %tmp1, double %a)
   ret double %tmp2
 }
 
-define double @test_fmla_dd2D(double %a, double %b, <2 x double> %v) {
-  ; CHECK-LABEL: test_fmla_dd2D
+define double @test_fmla_dd2D_0(double %a, double %b, <2 x double> %v) {
+  ; CHECK-LABEL: test_fmla_dd2D_0
+  ; CHECK: fmadd d0, d1, d2, d0
+  %tmp1 = extractelement <2 x double> %v, i32 0
+  %tmp2 = call double @llvm.fma.f64(double %b, double %tmp1, double %a)
+  ret double %tmp2
+}
+
+define double @test_fmla_dd2D_1(double %a, double %b, <2 x double> %v) {
+  ; CHECK-LABEL: test_fmla_dd2D_1
   ; CHECK: fmla {{d[0-9]+}}, {{d[0-9]+}}, {{v[0-9]+}}.d[1]
   %tmp1 = extractelement <2 x double> %v, i32 1
   %tmp2 = call double @llvm.fma.f64(double %b, double %tmp1, double %a)
   ret double %tmp2
 }
 
-define double @test_fmla_dd2D_swap(double %a, double %b, <2 x double> %v) {
-  ; CHECK-LABEL: test_fmla_dd2D_swap
+define double @test_fmla_dd2D_1_swap(double %a, double %b, <2 x double> %v) {
+  ; CHECK-LABEL: test_fmla_dd2D_1_swap
   ; CHECK: fmla {{d[0-9]+}}, {{d[0-9]+}},

[PATCH] D154869: [Flang] [FlangRT] Implement FlangRT library as solution to Flang's runtime LLVM integration

2023-08-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The test changes look good to me.




Comment at: flang/lib/Decimal/CMakeLists.txt:52
 
-add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN
-  binary-to-decimal.cpp
-  decimal-to-binary.cpp
-)
+add_compile_options(-fPIC)
+

This `add_compile_options(-fPIC)` shouldn't be necessary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154869

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


  1   2   3   >