[PATCH] D71607: [clang-tidy] Add unsigned subtraction warning, with suggestion to convert to unsigned literals.

2021-10-18 Thread Amin Yahyaabadi via Phabricator via cfe-commits
aminya added a comment.

I just hit this bug in my code where the subtraction of two size_t values 
resulted in a very large value. Fortunately, the address sanitizer immediately 
alerted me about the issue. It would be great to have such a warning in 
clang-tidy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71607

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


[PATCH] D111863: [libunwind] Add an interface for dynamic .eh_frame registration

2021-10-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a subscriber: dim.
MaskRay added a comment.

In D111863#3072023 , @housel wrote:

> It's also worth noting that FreeBSD's version of libgcc exception handling is 
> actually based on the libunwind code, with a local patch 
> 
>  that implements compatibility with libgcc `__register_frame` by changing it 
> to parse an entire `.eh_frame` section (in a slightly more ad hoc fashion 
> than this code). Having this new entry point in-tree would simplify the 
> FreeBSD local changes.

@dim


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111863

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


[PATCH] D111863: [libunwind] Add an interface for dynamic .eh_frame registration

2021-10-18 Thread Peter S. Housel via Phabricator via cfe-commits
housel added a comment.

It's also worth noting that FreeBSD's version of libgcc exception handling is 
actually based on the libunwind code, with a local patch 

 that implements compatibility with libgcc `__register_frame` by changing it to 
parse an entire `.eh_frame` section (in a slightly more ad hoc fashion than 
this code). Having this new entry point in-tree would simplify the FreeBSD 
local changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111863

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


[PATCH] D111692: [RISCV] Remove Zvamo C intrinsics and builtins.

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 380587.
craig.topper added a comment.

Reduce scope since RISCVISAInfo landed. We need more changes to MC tests
if we we remove Zvamo from RISCVISAInfo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111692

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamomax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamomin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoswap.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamomax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamomin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoswap.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoxor.c
  clang/utils/TableGen/RISCVVEmitter.cpp

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


[PATCH] D112028: [RISCV] Remove the HasSideEffects property from riscv_vector.td

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39a1fcb9cf59: [RISCV] Remove the HasSideEffects property 
from riscv_vector.td (authored by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D112028?vs=380496=380583#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112028

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -153,7 +153,6 @@
   std::string Name; // Builtin name
   std::string MangledName;
   std::string IRName;
-  bool HasSideEffects;
   bool IsMask;
   bool HasVL;
   bool HasPolicy;
@@ -170,9 +169,9 @@
 
 public:
   RVVIntrinsic(StringRef Name, StringRef Suffix, StringRef MangledName,
-   StringRef MangledSuffix, StringRef IRName, bool HasSideEffects,
-   bool IsMask, bool HasMaskedOffOperand, bool HasVL,
-   bool HasPolicy, bool HasNoMaskedOverloaded, bool HasAutoDef,
+   StringRef MangledSuffix, StringRef IRName, bool IsMask,
+   bool HasMaskedOffOperand, bool HasVL, bool HasPolicy,
+   bool HasNoMaskedOverloaded, bool HasAutoDef,
StringRef ManualCodegen, const RVVTypes ,
const std::vector ,
StringRef RequiredExtension, unsigned NF);
@@ -180,7 +179,6 @@
 
   StringRef getName() const { return Name; }
   StringRef getMangledName() const { return MangledName; }
-  bool hasSideEffects() const { return HasSideEffects; }
   bool hasVL() const { return HasVL; }
   bool hasPolicy() const { return HasPolicy; }
   bool hasNoMaskedOverloaded() const { return HasNoMaskedOverloaded; }
@@ -757,14 +755,13 @@
 //===--===//
 RVVIntrinsic::RVVIntrinsic(StringRef NewName, StringRef Suffix,
StringRef NewMangledName, StringRef MangledSuffix,
-   StringRef IRName, bool HasSideEffects, bool IsMask,
+   StringRef IRName, bool IsMask,
bool HasMaskedOffOperand, bool HasVL, bool HasPolicy,
bool HasNoMaskedOverloaded, bool HasAutoDef,
StringRef ManualCodegen, const RVVTypes ,
const std::vector ,
StringRef RequiredExtension, unsigned NF)
-: IRName(IRName), HasSideEffects(HasSideEffects), IsMask(IsMask),
-  HasVL(HasVL), HasPolicy(HasPolicy),
+: IRName(IRName), IsMask(IsMask), HasVL(HasVL), HasPolicy(HasPolicy),
   HasNoMaskedOverloaded(HasNoMaskedOverloaded), HasAutoDef(HasAutoDef),
   ManualCodegen(ManualCodegen.str()), NF(NF) {
 
@@ -1018,11 +1015,7 @@
   OS << "#endif\n";
   for (auto  : Defs) {
 OS << "RISCVV_BUILTIN(__builtin_rvv_" << Def->getName() << ",\""
-   << Def->getBuiltinTypeStr() << "\", ";
-if (!Def->hasSideEffects())
-  OS << "\"n\")\n";
-else
-  OS << "\"\")\n";
+   << Def->getBuiltinTypeStr() << "\", \"n\")\n";
   }
   OS << "#undef RISCVV_BUILTIN\n";
 }
@@ -1093,7 +1086,6 @@
 bool HasVL = R->getValueAsBit("HasVL");
 bool HasPolicy = R->getValueAsBit("HasPolicy");
 bool HasNoMaskedOverloaded = R->getValueAsBit("HasNoMaskedOverloaded");
-bool HasSideEffects = R->getValueAsBit("HasSideEffects");
 std::vector Log2LMULList = R->getValueAsListOfInts("Log2LMUL");
 StringRef ManualCodegen = R->getValueAsString("ManualCodegen");
 StringRef ManualCodegenMask = R->getValueAsString("ManualCodegenMask");
@@ -1165,17 +1157,17 @@
 // Create a non-mask intrinsic
 Out.push_back(std::make_unique(
 Name, SuffixStr, MangledName, MangledSuffixStr, IRName,
-HasSideEffects, /*IsMask=*/false, /*HasMaskedOffOperand=*/false,
-HasVL, HasPolicy, HasNoMaskedOverloaded, HasAutoDef, ManualCodegen,
-Types.getValue(), IntrinsicTypes, RequiredExtension, NF));
+/*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL, HasPolicy,
+HasNoMaskedOverloaded, HasAutoDef, ManualCodegen, Types.getValue(),
+IntrinsicTypes, RequiredExtension, NF));
 if (HasMask) {
   // Create a mask intrinsic
   Optional MaskTypes =
   computeTypes(I, Log2LMUL, NF, ProtoMaskSeq);
   Out.push_back(std::make_unique(
   Name, SuffixStr, MangledName, MangledSuffixStr, IRNameMask,
-  HasSideEffects, /*IsMask=*/true, HasMaskedOffOperand, HasVL,
-  HasPolicy, HasNoMaskedOverloaded, HasAutoDef, ManualCodegenMask,
+  /*IsMask=*/true, HasMaskedOffOperand, HasVL, HasPolicy,
+  HasNoMaskedOverloaded, HasAutoDef, 

[clang] 39a1fcb - [RISCV] Remove the HasSideEffects property from riscv_vector.td

2021-10-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-10-18T21:35:13-07:00
New Revision: 39a1fcb9cf5930eb3931ed0f9b8ef2f50dae4aa5

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

LOG: [RISCV] Remove the HasSideEffects property from riscv_vector.td

It was being used to control the nothrow attribute on the builtins. The
nothrow attribute is for C++ exceptions. Even if the vector builtins
have side effects in IR, that's different than the nothrow attribute.

Reviewed By: HsiangKai

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

Added: 


Modified: 
clang/include/clang/Basic/riscv_vector.td
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index e4b7dfd56b6a..607f277ebb4e 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -191,9 +191,6 @@ class RVVBuiltin Log2LMUL = [0, 1, 2, 3, -1, -2, -3];
 
@@ -1475,7 +1472,6 @@ multiclass RVVPseudoVNCVTBuiltin ,
StringRef RequiredExtension, unsigned NF);
@@ -180,7 +179,6 @@ class RVVIntrinsic {
 
   StringRef getName() const { return Name; }
   StringRef getMangledName() const { return MangledName; }
-  bool hasSideEffects() const { return HasSideEffects; }
   bool hasVL() const { return HasVL; }
   bool hasPolicy() const { return HasPolicy; }
   bool hasNoMaskedOverloaded() const { return HasNoMaskedOverloaded; }
@@ -757,14 +755,13 @@ void RVVType::applyModifier(StringRef Transformer) {
 
//===--===//
 RVVIntrinsic::RVVIntrinsic(StringRef NewName, StringRef Suffix,
StringRef NewMangledName, StringRef MangledSuffix,
-   StringRef IRName, bool HasSideEffects, bool IsMask,
+   StringRef IRName, bool IsMask,
bool HasMaskedOffOperand, bool HasVL, bool 
HasPolicy,
bool HasNoMaskedOverloaded, bool HasAutoDef,
StringRef ManualCodegen, const RVVTypes ,
const std::vector ,
StringRef RequiredExtension, unsigned NF)
-: IRName(IRName), HasSideEffects(HasSideEffects), IsMask(IsMask),
-  HasVL(HasVL), HasPolicy(HasPolicy),
+: IRName(IRName), IsMask(IsMask), HasVL(HasVL), HasPolicy(HasPolicy),
   HasNoMaskedOverloaded(HasNoMaskedOverloaded), HasAutoDef(HasAutoDef),
   ManualCodegen(ManualCodegen.str()), NF(NF) {
 
@@ -1018,11 +1015,7 @@ void RVVEmitter::createBuiltins(raw_ostream ) {
   OS << "#endif\n";
   for (auto  : Defs) {
 OS << "RISCVV_BUILTIN(__builtin_rvv_" << Def->getName() << ",\""
-   << Def->getBuiltinTypeStr() << "\", ";
-if (!Def->hasSideEffects())
-  OS << "\"n\")\n";
-else
-  OS << "\"\")\n";
+   << Def->getBuiltinTypeStr() << "\", \"n\")\n";
   }
   OS << "#undef RISCVV_BUILTIN\n";
 }
@@ -1093,7 +1086,6 @@ void RVVEmitter::createRVVIntrinsics(
 bool HasVL = R->getValueAsBit("HasVL");
 bool HasPolicy = R->getValueAsBit("HasPolicy");
 bool HasNoMaskedOverloaded = R->getValueAsBit("HasNoMaskedOverloaded");
-bool HasSideEffects = R->getValueAsBit("HasSideEffects");
 std::vector Log2LMULList = R->getValueAsListOfInts("Log2LMUL");
 StringRef ManualCodegen = R->getValueAsString("ManualCodegen");
 StringRef ManualCodegenMask = R->getValueAsString("ManualCodegenMask");
@@ -1165,17 +1157,17 @@ void RVVEmitter::createRVVIntrinsics(
 // Create a non-mask intrinsic
 Out.push_back(std::make_unique(
 Name, SuffixStr, MangledName, MangledSuffixStr, IRName,
-HasSideEffects, /*IsMask=*/false, /*HasMaskedOffOperand=*/false,
-HasVL, HasPolicy, HasNoMaskedOverloaded, HasAutoDef, ManualCodegen,
-Types.getValue(), IntrinsicTypes, RequiredExtension, NF));
+/*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL, HasPolicy,
+HasNoMaskedOverloaded, HasAutoDef, ManualCodegen, Types.getValue(),
+IntrinsicTypes, RequiredExtension, NF));
 if (HasMask) {
   // Create a mask intrinsic
   Optional MaskTypes =
   computeTypes(I, Log2LMUL, NF, ProtoMaskSeq);
   Out.push_back(std::make_unique(
   Name, SuffixStr, MangledName, MangledSuffixStr, IRNameMask,
-  HasSideEffects, /*IsMask=*/true, HasMaskedOffOperand, HasVL,
-  HasPolicy, HasNoMaskedOverloaded, HasAutoDef, ManualCodegenMask,
+  /*IsMask=*/true, HasMaskedOffOperand, HasVL, HasPolicy,
+  HasNoMaskedOverloaded, HasAutoDef, ManualCodegenMask,
   MaskTypes.getValue(), IntrinsicTypes, 

[PATCH] D111923: [RISCV] Split RISCV vector builtins into their own file and namespace.

2021-10-18 Thread Craig Topper 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 rG34173330bb3f: [RISCV] Split RISCV vector builtins into their 
own file and namespace. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111923

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/BuiltinsRISCVVector.def
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/module.modulemap
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -1046,7 +1046,7 @@
   PrevDef->emitCodeGenSwitchBody(OS);
 }
 PrevDef = Def.get();
-OS << "case RISCV::BI__builtin_rvv_" << Def->getName() << ":\n";
+OS << "case RISCVVector::BI__builtin_rvv_" << Def->getName() << ":\n";
   }
   Defs.back()->emitCodeGenSwitchBody(OS);
   OS << "\n";
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5340,8 +5340,8 @@
 }
 
 static bool RISCVAliasValid(unsigned BuiltinID, StringRef AliasName) {
-  return BuiltinID >= Builtin::FirstTSBuiltin &&
- BuiltinID < RISCV::LastTSBuiltin;
+  return BuiltinID >= RISCV::FirstRVVBuiltin &&
+ BuiltinID <= RISCV::LastRVVBuiltin;
 }
 
 static void handleBuiltinAliasAttr(Sema , Decl *D,
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3661,137 +3661,137 @@
 return true;
 
   switch (BuiltinID) {
-  case RISCV::BI__builtin_rvv_vsetvli:
+  case RISCVVector::BI__builtin_rvv_vsetvli:
 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 3) ||
CheckRISCVLMUL(TheCall, 2);
-  case RISCV::BI__builtin_rvv_vsetvlimax:
+  case RISCVVector::BI__builtin_rvv_vsetvlimax:
 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3) ||
CheckRISCVLMUL(TheCall, 1);
-  case RISCV::BI__builtin_rvv_vget_v_i8m2_i8m1:
-  case RISCV::BI__builtin_rvv_vget_v_i16m2_i16m1:
-  case RISCV::BI__builtin_rvv_vget_v_i32m2_i32m1:
-  case RISCV::BI__builtin_rvv_vget_v_i64m2_i64m1:
-  case RISCV::BI__builtin_rvv_vget_v_f32m2_f32m1:
-  case RISCV::BI__builtin_rvv_vget_v_f64m2_f64m1:
-  case RISCV::BI__builtin_rvv_vget_v_u8m2_u8m1:
-  case RISCV::BI__builtin_rvv_vget_v_u16m2_u16m1:
-  case RISCV::BI__builtin_rvv_vget_v_u32m2_u32m1:
-  case RISCV::BI__builtin_rvv_vget_v_u64m2_u64m1:
-  case RISCV::BI__builtin_rvv_vget_v_i8m4_i8m2:
-  case RISCV::BI__builtin_rvv_vget_v_i16m4_i16m2:
-  case RISCV::BI__builtin_rvv_vget_v_i32m4_i32m2:
-  case RISCV::BI__builtin_rvv_vget_v_i64m4_i64m2:
-  case RISCV::BI__builtin_rvv_vget_v_f32m4_f32m2:
-  case RISCV::BI__builtin_rvv_vget_v_f64m4_f64m2:
-  case RISCV::BI__builtin_rvv_vget_v_u8m4_u8m2:
-  case RISCV::BI__builtin_rvv_vget_v_u16m4_u16m2:
-  case RISCV::BI__builtin_rvv_vget_v_u32m4_u32m2:
-  case RISCV::BI__builtin_rvv_vget_v_u64m4_u64m2:
-  case RISCV::BI__builtin_rvv_vget_v_i8m8_i8m4:
-  case RISCV::BI__builtin_rvv_vget_v_i16m8_i16m4:
-  case RISCV::BI__builtin_rvv_vget_v_i32m8_i32m4:
-  case RISCV::BI__builtin_rvv_vget_v_i64m8_i64m4:
-  case RISCV::BI__builtin_rvv_vget_v_f32m8_f32m4:
-  case RISCV::BI__builtin_rvv_vget_v_f64m8_f64m4:
-  case RISCV::BI__builtin_rvv_vget_v_u8m8_u8m4:
-  case RISCV::BI__builtin_rvv_vget_v_u16m8_u16m4:
-  case RISCV::BI__builtin_rvv_vget_v_u32m8_u32m4:
-  case RISCV::BI__builtin_rvv_vget_v_u64m8_u64m4:
+  case RISCVVector::BI__builtin_rvv_vget_v_i8m2_i8m1:
+  case RISCVVector::BI__builtin_rvv_vget_v_i16m2_i16m1:
+  case RISCVVector::BI__builtin_rvv_vget_v_i32m2_i32m1:
+  case RISCVVector::BI__builtin_rvv_vget_v_i64m2_i64m1:
+  case RISCVVector::BI__builtin_rvv_vget_v_f32m2_f32m1:
+  case RISCVVector::BI__builtin_rvv_vget_v_f64m2_f64m1:
+  case RISCVVector::BI__builtin_rvv_vget_v_u8m2_u8m1:
+  case RISCVVector::BI__builtin_rvv_vget_v_u16m2_u16m1:
+  case RISCVVector::BI__builtin_rvv_vget_v_u32m2_u32m1:
+  case RISCVVector::BI__builtin_rvv_vget_v_u64m2_u64m1:
+  case RISCVVector::BI__builtin_rvv_vget_v_i8m4_i8m2:
+  case RISCVVector::BI__builtin_rvv_vget_v_i16m4_i16m2:
+  case RISCVVector::BI__builtin_rvv_vget_v_i32m4_i32m2:
+  case RISCVVector::BI__builtin_rvv_vget_v_i64m4_i64m2:
+  case RISCVVector::BI__builtin_rvv_vget_v_f32m4_f32m2:
+  case RISCVVector::BI__builtin_rvv_vget_v_f64m4_f64m2:
+  case RISCVVector::BI__builtin_rvv_vget_v_u8m4_u8m2:
+  case RISCVVector::BI__builtin_rvv_vget_v_u16m4_u16m2:
+  case RISCVVector::BI__builtin_rvv_vget_v_u32m4_u32m2:
+  

[clang] 3417333 - [RISCV] Split RISCV vector builtins into their own file and namespace.

2021-10-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-10-18T21:26:18-07:00
New Revision: 34173330bb3f372df0a0d7fd6b639a9812cf77bb

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

LOG: [RISCV] Split RISCV vector builtins into their own file and namespace.

Similar to SVE, this separates the RVV builtlins into their own
region of builtin IDs. Only those IDs are allowed to be used by
the builtin_alias attribute now.

Reviewed By: HsiangKai

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

Added: 
clang/include/clang/Basic/BuiltinsRISCVVector.def

Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/include/clang/Basic/TargetBuiltins.h
clang/include/clang/module.modulemap
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index b2b4950f92bd6..06560415e6861 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -15,8 +15,6 @@
 #   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
-#include "clang/Basic/riscv_vector_builtins.inc"
-
 // Zbb extension
 TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb")
 TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", 
"experimental-zbb,64bit")

diff  --git a/clang/include/clang/Basic/BuiltinsRISCVVector.def 
b/clang/include/clang/Basic/BuiltinsRISCVVector.def
new file mode 100644
index 0..008cb939a30bc
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsRISCVVector.def
@@ -0,0 +1,21 @@
+//==- BuiltinsRISCVVector.def - RISC-V Vector Builtin Database ---*- C++ 
-*-==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines the RISC-V-specific builtin function database.  Users of
+// this file must define the BUILTIN macro to make use of this information.
+//
+//===--===//
+
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
+#include "clang/Basic/riscv_vector_builtins.inc"
+
+#undef BUILTIN
+#undef TARGET_BUILTIN

diff  --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index ed53b10f61ef4..d4ea8e98b2e3f 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -124,10 +124,21 @@ namespace clang {
   enum { LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, LastTSBuiltin };
   }
 
+  namespace RISCVVector {
+  enum {
+LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/BuiltinsRISCVVector.def"
+FirstTSBuiltin,
+  };
+  }
+
   /// RISCV builtins
   namespace RISCV {
   enum {
 LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+FirstRVVBuiltin = clang::Builtin::FirstTSBuiltin,
+LastRVVBuiltin = RISCVVector::FirstTSBuiltin - 1,
 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
 #include "clang/Basic/BuiltinsRISCV.def"
 LastTSBuiltin

diff  --git a/clang/include/clang/module.modulemap 
b/clang/include/clang/module.modulemap
index e99b8d4f5c63c..e850a1cd4b9ad 100644
--- a/clang/include/clang/module.modulemap
+++ b/clang/include/clang/module.modulemap
@@ -45,6 +45,7 @@ module Clang_Basic {
   textual header "Basic/BuiltinsNVPTX.def"
   textual header "Basic/BuiltinsPPC.def"
   textual header "Basic/BuiltinsRISCV.def"
+  textual header "Basic/BuiltinsRISCVVector.def"
   textual header "Basic/BuiltinsSVE.def"
   textual header "Basic/BuiltinsSystemZ.def"
   textual header "Basic/BuiltinsWebAssembly.def"

diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 83b2fb95b3d1c..93562dde2f544 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -184,6 +184,11 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
,
 }
 
 const Builtin::Info RISCVTargetInfo::BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS)   
\
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   
\
+{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
+#include "clang/Basic/BuiltinsRISCVVector.def"
 #define BUILTIN(ID, TYPE, ATTRS) 

[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 380581.
hliao added a comment.

Fix formatting again following clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AssumptionCache.h
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/Analysis/AssumptionCache.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/builtin-assumed-addrspace.ll
  llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Analysis/AliasAnalysisTest.cpp
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
  llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
  llvm/unittests/Analysis/DDGTest.cpp
  llvm/unittests/Analysis/IVDescriptorsTest.cpp
  llvm/unittests/Analysis/LoopInfoTest.cpp
  llvm/unittests/Analysis/LoopNestTest.cpp
  llvm/unittests/Analysis/MemorySSATest.cpp
  llvm/unittests/Analysis/ScalarEvolutionTest.cpp
  llvm/unittests/Analysis/ValueTrackingTest.cpp
  llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp
  llvm/unittests/Transforms/Utils/CodeExtractorTest.cpp
  llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
  llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp
  llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
  llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
  llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
  llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
  llvm/unittests/Transforms/Vectorize/VPlanTestBase.h

Index: llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
===
--- llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
+++ llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
@@ -57,7 +57,7 @@
   void doAnalysis(Function ) {
 DT.reset(new DominatorTree(F));
 LI.reset(new LoopInfo(*DT));
-AC.reset(new AssumptionCache(F));
+AC.reset(new AssumptionCache(F, /*TTI=*/nullptr));
 SE.reset(new ScalarEvolution(F, TLI, *AC, *DT, *LI));
   }
 
Index: llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
===
--- llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
+++ llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
@@ -38,7 +38,7 @@
 
   VPInterleavedAccessInfo getInterleavedAccessInfo(Function , Loop *L,
VPlan ) {
-AC.reset(new AssumptionCache(F));
+AC.reset(new AssumptionCache(F, /*TTI=*/nullptr));
 SE.reset(new ScalarEvolution(F, TLI, *AC, *DT, *LI));
 BasicAA.reset(new BasicAAResult(DL, F, TLI, *AC, &*DT));
 AARes.reset(new AAResults(TLI));
Index: llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
===
--- llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
+++ llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
@@ -61,7 +61,7 @@
   auto *F = M->getFunction("test");
   DominatorTree DT(*F);
   LoopInfo LI(DT);
-  AssumptionCache AC(*F);
+  AssumptionCache AC(*F, /*TTI=*/nullptr);
   TargetLibraryInfoImpl TLII;
   TargetLibraryInfo TLI(TLII);
   ScalarEvolution SE(*F, TLI, AC, DT, LI);
Index: llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
===
--- llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
+++ llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
@@ -45,7 +45,7 @@
   ScalarEvolutionExpanderTest() : M("", Context), TLII(), TLI(TLII) {}
 
   ScalarEvolution buildSE(Function ) {
-AC.reset(new AssumptionCache(F));
+AC.reset(new AssumptionCache(F, /*TTI=*/nullptr));
 DT.reset(new DominatorTree(F));
 LI.reset(new LoopInfo(*DT));
 return ScalarEvolution(F, TLI, *AC, *DT, *LI);
Index: llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
===
--- llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
+++ llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
@@ -34,7 +34,7 @@
   DominatorTree DT(*F);
   TargetLibraryInfoImpl TLII;
   TargetLibraryInfo TLI(TLII);
-  AssumptionCache AC(*F);
+  AssumptionCache AC(*F, /*TTI=*/nullptr);
   LoopInfo LI(DT);
   ScalarEvolution 

[PATCH] D112053: [cuda] Add address space predicate funuctions.

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

With this patch, the following code could be compiled into the same PTX as 
NVCC. Check https://godbolt.org/z/q6EYE1q1o for the difference between NVCC and 
the current Clang output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112053

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


[PATCH] D112053: [cuda] Add address space predicate funuctions.

2021-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added a reviewer: tra.
Herald added subscribers: yaxunl, jholewinski.
hliao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Add the missing NVVM predicate builtins on address space checking
- Redefine them as pure functions so that they could be used in 
__builtin_assume.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112053

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -271,7 +271,38 @@
 #undef __CUDABE__
 #endif
 #include "sm_20_atomic_functions.hpp"
+// Predicate functions used in `__builtin_assume` need to have no side effect.
+// However, sm_20_intrinsics.hpp doesn't define them with neither pure nor
+// const attribute. Rename definitions from sm_20_intrinsics.hpp and re-define
+// them as pure ones.
+#pragma push_macro("__isGlobal")
+#pragma push_macro("__isShared")
+#pragma push_macro("__isConstant")
+#pragma push_macro("__isLocal")
+#define __isGlobal __ignored_cuda___isGlobal
+#define __isShared __ignored_cuda___isShared
+#define __isConstant __ignored_cuda___isConstant
+#define __isLocal __ignored_cuda___isLocal
 #include "sm_20_intrinsics.hpp"
+#pragma pop_macro("__isGlobal")
+#pragma pop_macro("__isShared")
+#pragma pop_macro("__isConstant")
+#pragma pop_macro("__isLocal")
+#pragma push_macro("__DEVICE__")
+#define __DEVICE__ static __device__ __forceinline__ __attribute__((const))
+__DEVICE__ unsigned int __isGlobal(const void *p) {
+  return __nvvm_isspacep_global(p);
+}
+__DEVICE__ unsigned int __isShared(const void *p) {
+  return __nvvm_isspacep_shared(p);
+}
+__DEVICE__ unsigned int __isConstant(const void *p) {
+  return __nvvm_isspacep_const(p);
+}
+__DEVICE__ unsigned int __isLocal(const void *p) {
+  return __nvvm_isspacep_local(p);
+}
+#pragma pop_macro("__DEVICE__")
 #include "sm_32_atomic_functions.hpp"
 
 // Don't include sm_30_intrinsics.h and sm_32_intrinsics.h.  These define the
Index: clang/include/clang/Basic/BuiltinsNVPTX.def
===
--- clang/include/clang/Basic/BuiltinsNVPTX.def
+++ clang/include/clang/Basic/BuiltinsNVPTX.def
@@ -687,6 +687,12 @@
 BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "")
 BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "")
 
+// Address space predicates.
+BUILTIN(__nvvm_isspacep_const, "bvC*", "nc")
+BUILTIN(__nvvm_isspacep_global, "bvC*", "nc")
+BUILTIN(__nvvm_isspacep_local, "bvC*", "nc")
+BUILTIN(__nvvm_isspacep_shared, "bvC*", "nc")
+
 // Builtins to support WMMA instructions on sm_70
 TARGET_BUILTIN(__hmma_m16n16k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX60))
 TARGET_BUILTIN(__hmma_m16n16k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX60))


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -271,7 +271,38 @@
 #undef __CUDABE__
 #endif
 #include "sm_20_atomic_functions.hpp"
+// Predicate functions used in `__builtin_assume` need to have no side effect.
+// However, sm_20_intrinsics.hpp doesn't define them with neither pure nor
+// const attribute. Rename definitions from sm_20_intrinsics.hpp and re-define
+// them as pure ones.
+#pragma push_macro("__isGlobal")
+#pragma push_macro("__isShared")
+#pragma push_macro("__isConstant")
+#pragma push_macro("__isLocal")
+#define __isGlobal __ignored_cuda___isGlobal
+#define __isShared __ignored_cuda___isShared
+#define __isConstant __ignored_cuda___isConstant
+#define __isLocal __ignored_cuda___isLocal
 #include "sm_20_intrinsics.hpp"
+#pragma pop_macro("__isGlobal")
+#pragma pop_macro("__isShared")
+#pragma pop_macro("__isConstant")
+#pragma pop_macro("__isLocal")
+#pragma push_macro("__DEVICE__")
+#define __DEVICE__ static __device__ __forceinline__ __attribute__((const))
+__DEVICE__ unsigned int __isGlobal(const void *p) {
+  return __nvvm_isspacep_global(p);
+}
+__DEVICE__ unsigned int __isShared(const void *p) {
+  return __nvvm_isspacep_shared(p);
+}
+__DEVICE__ unsigned int __isConstant(const void *p) {
+  return __nvvm_isspacep_const(p);
+}
+__DEVICE__ unsigned int __isLocal(const void *p) {
+  return __nvvm_isspacep_local(p);
+}
+#pragma pop_macro("__DEVICE__")
 #include "sm_32_atomic_functions.hpp"
 
 // Don't include sm_30_intrinsics.h and sm_32_intrinsics.h.  These define the
Index: clang/include/clang/Basic/BuiltinsNVPTX.def
===
--- clang/include/clang/Basic/BuiltinsNVPTX.def
+++ clang/include/clang/Basic/BuiltinsNVPTX.def
@@ -687,6 +687,12 @@
 BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "")
 BUILTIN(__nvvm_ldg_d2, 

[PATCH] D91815: Fix small typo in Block ABI docs

2021-10-18 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa94bc9d81bfc: Fix small typo in Block ABI docs (authored by 
dmaclach, committed by xgupta).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91815

Files:
  clang/docs/Block-ABI-Apple.rst


Index: clang/docs/Block-ABI-Apple.rst
===
--- clang/docs/Block-ABI-Apple.rst
+++ clang/docs/Block-ABI-Apple.rst
@@ -765,7 +765,7 @@
printf("%d\n", _block->foo.value());
 }
 
-void __block_literal_10(struct __block_literal_10 *dst, struct 
__block_literal_10 *src) {
+void __block_copy_10(struct __block_literal_10 *dst, struct 
__block_literal_10 *src) {
  FOO_ctor(>foo, >foo);
 }
 


Index: clang/docs/Block-ABI-Apple.rst
===
--- clang/docs/Block-ABI-Apple.rst
+++ clang/docs/Block-ABI-Apple.rst
@@ -765,7 +765,7 @@
printf("%d\n", _block->foo.value());
 }
 
-void __block_literal_10(struct __block_literal_10 *dst, struct __block_literal_10 *src) {
+void __block_copy_10(struct __block_literal_10 *dst, struct __block_literal_10 *src) {
  FOO_ctor(>foo, >foo);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a94bc9d - Fix small typo in Block ABI docs

2021-10-18 Thread Shivam Gupta via cfe-commits

Author: Dave MacLachlan
Date: 2021-10-19T09:33:35+05:30
New Revision: a94bc9d81bfce2c697494431b4524fcee90a26cf

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

LOG: Fix small typo in Block ABI docs

I think the C++ code example had the wrong name for the block copy function.

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/docs/Block-ABI-Apple.rst

Removed: 




diff  --git a/clang/docs/Block-ABI-Apple.rst b/clang/docs/Block-ABI-Apple.rst
index 4f98b3ba6538..9983f26a6240 100644
--- a/clang/docs/Block-ABI-Apple.rst
+++ b/clang/docs/Block-ABI-Apple.rst
@@ -765,7 +765,7 @@ The compiler would synthesize:
printf("%d\n", _block->foo.value());
 }
 
-void __block_literal_10(struct __block_literal_10 *dst, struct 
__block_literal_10 *src) {
+void __block_copy_10(struct __block_literal_10 *dst, struct 
__block_literal_10 *src) {
  FOO_ctor(>foo, >foo);
 }
 



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


[PATCH] D111529: Specify Clang vector builtins.

2021-10-18 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:579
+ NaNs, fmax() return a NaN.
+ ET __builtin_reduce_add(VT a)   \+
   integer and floating point types
+ ET __builtin_reduce_and(VT a)   & 
   integer types

The example above use `__builtin_reduce_fadd`, but not listed here? or should 
we just use `__builtin_reduce_add` for floating point and fix the example?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529

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


[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 380574.
hliao added a comment.

Fix formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AssumptionCache.h
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/Analysis/AssumptionCache.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/builtin-assumed-addrspace.ll
  llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Analysis/AliasAnalysisTest.cpp
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
  llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
  llvm/unittests/Analysis/DDGTest.cpp
  llvm/unittests/Analysis/IVDescriptorsTest.cpp
  llvm/unittests/Analysis/LoopInfoTest.cpp
  llvm/unittests/Analysis/LoopNestTest.cpp
  llvm/unittests/Analysis/MemorySSATest.cpp
  llvm/unittests/Analysis/ScalarEvolutionTest.cpp
  llvm/unittests/Analysis/ValueTrackingTest.cpp
  llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp
  llvm/unittests/Transforms/Utils/CodeExtractorTest.cpp
  llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
  llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp
  llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
  llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
  llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
  llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
  llvm/unittests/Transforms/Vectorize/VPlanTestBase.h

Index: llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
===
--- llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
+++ llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
@@ -57,7 +57,7 @@
   void doAnalysis(Function ) {
 DT.reset(new DominatorTree(F));
 LI.reset(new LoopInfo(*DT));
-AC.reset(new AssumptionCache(F));
+AC.reset(new AssumptionCache(F, /*TTI=*/nullptr));
 SE.reset(new ScalarEvolution(F, TLI, *AC, *DT, *LI));
   }
 
Index: llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
===
--- llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
+++ llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
@@ -38,7 +38,7 @@
 
   VPInterleavedAccessInfo getInterleavedAccessInfo(Function , Loop *L,
VPlan ) {
-AC.reset(new AssumptionCache(F));
+AC.reset(new AssumptionCache(F, /*TTI=*/nullptr));
 SE.reset(new ScalarEvolution(F, TLI, *AC, *DT, *LI));
 BasicAA.reset(new BasicAAResult(DL, F, TLI, *AC, &*DT));
 AARes.reset(new AAResults(TLI));
Index: llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
===
--- llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
+++ llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
@@ -61,7 +61,7 @@
   auto *F = M->getFunction("test");
   DominatorTree DT(*F);
   LoopInfo LI(DT);
-  AssumptionCache AC(*F);
+  AssumptionCache AC(*F, /*TTI=*/nullptr);
   TargetLibraryInfoImpl TLII;
   TargetLibraryInfo TLI(TLII);
   ScalarEvolution SE(*F, TLI, AC, DT, LI);
Index: llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
===
--- llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
+++ llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
@@ -45,7 +45,7 @@
   ScalarEvolutionExpanderTest() : M("", Context), TLII(), TLI(TLII) {}
 
   ScalarEvolution buildSE(Function ) {
-AC.reset(new AssumptionCache(F));
+AC.reset(new AssumptionCache(F, /*TTI=*/nullptr));
 DT.reset(new DominatorTree(F));
 LI.reset(new LoopInfo(*DT));
 return ScalarEvolution(F, TLI, *AC, *DT, *LI);
Index: llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
===
--- llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
+++ llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
@@ -34,7 +34,7 @@
   DominatorTree DT(*F);
   TargetLibraryInfoImpl TLII;
   TargetLibraryInfo TLI(TLII);
-  AssumptionCache AC(*F);
+  AssumptionCache AC(*F, /*TTI=*/nullptr);
   LoopInfo LI(DT);
   ScalarEvolution SE(*F, TLI, AC, DT, LI);
   

[PATCH] D112050: [clang] NFC: return void in an alternative expression after call to void function.

2021-10-18 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou created this revision.
zhouyizhou added a reviewer: clang.
zhouyizhou requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It is better to return void in an alternative expression after call to void 
function. Also, I processed emitDestroy's function body using clang-format.

I don't have write access to LLVM repository,  if the patch got approved, can 
someone commit for me ?

Thanks 
Zhouyi

Signed-off-by: Zhouyi Zhou 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112050

Files:
  clang/lib/CodeGen/CGDecl.cpp


Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2181,14 +2181,15 @@
   Destroyer *destroyer,
   bool useEHCleanupForArray) {
   const ArrayType *arrayType = getContext().getAsArrayType(type);
-  if (!arrayType)
-return destroyer(*this, addr, type);
+  if (!arrayType) {
+destroyer(*this, addr, type);
+return;
+  }
 
   llvm::Value *length = emitArrayLength(arrayType, type, addr);
 
-  CharUnits elementAlign =
-addr.getAlignment()
-.alignmentOfArrayElement(getContext().getTypeSizeInChars(type));
+  CharUnits elementAlign = addr.getAlignment().alignmentOfArrayElement(
+  getContext().getTypeSizeInChars(type));
 
   // Normally we have to check whether the array is zero-length.
   bool checkZeroLength = true;
@@ -2196,15 +2197,16 @@
   // But if the array length is constant, we can suppress that.
   if (llvm::ConstantInt *constLength = dyn_cast(length)) {
 // ...and if it's constant zero, we can just skip the entire thing.
-if (constLength->isZero()) return;
+if (constLength->isZero())
+  return;
 checkZeroLength = false;
   }
 
   llvm::Value *begin = addr.getPointer();
   llvm::Value *end =
   Builder.CreateInBoundsGEP(addr.getElementType(), begin, length);
-  emitArrayDestroy(begin, end, type, elementAlign, destroyer,
-   checkZeroLength, useEHCleanupForArray);
+  emitArrayDestroy(begin, end, type, elementAlign, destroyer, checkZeroLength,
+   useEHCleanupForArray);
 }
 
 /// emitArrayDestroy - Destroys all the elements of the given array,


Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2181,14 +2181,15 @@
   Destroyer *destroyer,
   bool useEHCleanupForArray) {
   const ArrayType *arrayType = getContext().getAsArrayType(type);
-  if (!arrayType)
-return destroyer(*this, addr, type);
+  if (!arrayType) {
+destroyer(*this, addr, type);
+return;
+  }
 
   llvm::Value *length = emitArrayLength(arrayType, type, addr);
 
-  CharUnits elementAlign =
-addr.getAlignment()
-.alignmentOfArrayElement(getContext().getTypeSizeInChars(type));
+  CharUnits elementAlign = addr.getAlignment().alignmentOfArrayElement(
+  getContext().getTypeSizeInChars(type));
 
   // Normally we have to check whether the array is zero-length.
   bool checkZeroLength = true;
@@ -2196,15 +2197,16 @@
   // But if the array length is constant, we can suppress that.
   if (llvm::ConstantInt *constLength = dyn_cast(length)) {
 // ...and if it's constant zero, we can just skip the entire thing.
-if (constLength->isZero()) return;
+if (constLength->isZero())
+  return;
 checkZeroLength = false;
   }
 
   llvm::Value *begin = addr.getPointer();
   llvm::Value *end =
   Builder.CreateInBoundsGEP(addr.getElementType(), begin, length);
-  emitArrayDestroy(begin, end, type, elementAlign, destroyer,
-   checkZeroLength, useEHCleanupForArray);
+  emitArrayDestroy(begin, end, type, elementAlign, destroyer, checkZeroLength,
+   useEHCleanupForArray);
 }
 
 /// emitArrayDestroy - Destroys all the elements of the given array,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112049: [ObjC] avoid crashing when emitting synthesized getter/setter and ptrdiff_t is smaller than long

2021-10-18 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson created this revision.
mhjacobson added reviewers: rjmccall, ddunbar.
Herald added subscribers: Jim, dylanmckay.
mhjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

On targets where `ptrdiff_t` is smaller than `long`, clang crashes (backtrace 
below) when emitting synthesized getters/setters that call 
`objc_[gs]etProperty`.  Explicitly emit a zext/trunc of the ivar offset value 
(which is defined to `long`) to `ptrdiff_t`, which `objc_[gs]etProperty` takes.

Add a test using the AVR target, where `ptrdiff_t` is smaller than `long`.  
Test failed previously and passes now.

Backtrace:

  Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function 
Create, file /Users/matt/src/llvm/llvm/lib/IR/Instructions.cpp, line 3042.
  
  ...
  
  7  libsystem_c.dylib0x7fff6ec09ac6 err + 0
  8  clang-14 0x00010acf104c 
llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, 
llvm::Twine const&, llvm::Instruction*) + 124
  9  clang-14 0x00010beb140a 
llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, 
llvm::Type*, llvm::Twine const&) + 234
  10 clang-14 0x00010bebdec2 
llvm::IRBuilderBase::CreateZExt(llvm::Value*, llvm::Type*, llvm::Twine const&) 
+ 50
  11 clang-14 0x00010cab50aa 
clang::CodeGen::CodeGenFunction::EmitCall(clang::CodeGen::CGFunctionInfo 
const&, clang::CodeGen::CGCallee const&, clang::CodeGen::ReturnValueSlot, 
clang::CodeGen::CallArgList const&, llvm::CallBase**, bool, 
clang::SourceLocation) + 8442
  12 clang-14 0x00010ceadeb8 
clang::CodeGen::CodeGenFunction::EmitCall(clang::CodeGen::CGFunctionInfo 
const&, clang::CodeGen::CGCallee const&, clang::CodeGen::ReturnValueSlot, 
clang::CodeGen::CallArgList const&, llvm::CallBase**, bool) + 216
  13 clang-14 0x00010cc76fe3 
clang::CodeGen::CodeGenFunction::generateObjCGetterBody(clang::ObjCImplementationDecl
 const*, clang::ObjCPropertyImplDecl const*, clang::ObjCMethodDecl const*, 
llvm::Constant*) + 2595
  14 clang-14 0x00010cc75387 
clang::CodeGen::CodeGenFunction::GenerateObjCGetter(clang::ObjCImplementationDecl*,
 clang::ObjCPropertyImplDecl const*) + 343
  15 clang-14 0x00010cf1c4c0 
clang::CodeGen::CodeGenModule::EmitObjCPropertyImplementations(clang::ObjCImplementationDecl
 const*) + 336
  16 clang-14 0x00010cf17799 
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 2009
  17 clang-14 0x00010d114bf2 (anonymous 
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 146
  18 clang-14 0x00010cec0014 
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 228
  19 clang-14 0x000110436425 clang::ParseAST(clang::Sema&, 
bool, bool) + 533


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112049

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/avr/objc-property.m


Index: clang/test/CodeGen/avr/objc-property.m
===
--- /dev/null
+++ clang/test/CodeGen/avr/objc-property.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm -fobjc-runtime=macosx %s -o /dev/null
+
+__attribute__((objc_root_class))
+@interface Foo
+
+@property(strong) Foo *f;
+
+@end
+
+@implementation Foo
+
+@synthesize f = _f;
+
+@end
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -3906,6 +3906,8 @@
 
   llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
   const ObjCIvarDecl *Ivar);
+  llvm::Value *EmitIvarOffsetAsPointerDiff(const ObjCInterfaceDecl *Interface,
+   const ObjCIvarDecl *Ivar);
   LValue EmitLValueForField(LValue Base, const FieldDecl* Field);
   LValue EmitLValueForLambdaField(const FieldDecl *Field);
 
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -1192,7 +1192,7 @@
   Builder.CreateLoad(GetAddrOfLocalVar(getterMethod->getCmdDecl()), "cmd");
 llvm::Value *self = Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy);
 llvm::Value *ivarOffset =
-  EmitIvarOffset(classImpl->getClassInterface(), ivar);
+EmitIvarOffsetAsPointerDiff(classImpl->getClassInterface(), ivar);
 
 CallArgList args;
 args.add(RValue::get(self), getContext().getObjCIdType());
@@ -1479,7 +1479,7 @@
 llvm::Value *self =
   Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy);
 llvm::Value *ivarOffset =
-  

[PATCH] D111692: [RISCV] Remove Zvamo C intrinsics and builtins.

2021-10-18 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai accepted this revision.
HsiangKai added a comment.
This revision is now accepted and ready to land.

Zvamo is not a part of standard V extension in the current stage. I am fine to 
remove it in the implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111692

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


[PATCH] D111923: [RISCV] Split RISCV vector builtins into their own file and namespace.

2021-10-18 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai accepted this revision.
HsiangKai 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/D111923/new/

https://reviews.llvm.org/D111923

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


[PATCH] D111371: [Support][ThinLTO] Move ThinLTO caching to LLVM Support library.

2021-10-18 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe678c5117710: [Support][ThinLTO] Move ThinLTO caching to 
LLVM Support library (authored by noajshu, committed by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111371

Files:
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/LTO.cpp
  lld/ELF/LTO.cpp
  lld/MachO/LTO.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/Caching.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/Support/Caching.h
  llvm/lib/LTO/CMakeLists.txt
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Caching.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn
  llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
@@ -54,6 +54,7 @@
 "COM.cpp",
 "CRC.cpp",
 "CachePruning.cpp",
+"Caching.cpp",
 "Chrono.cpp",
 "CodeGenCoverage.cpp",
 "CommandLine.cpp",
Index: llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn
@@ -22,7 +22,6 @@
 "//llvm/lib/Transforms/Utils",
   ]
   sources = [
-"Caching.cpp",
 "LTO.cpp",
 "LTOBackend.cpp",
 "LTOCodeGenerator.cpp",
Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -19,10 +19,10 @@
 #include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -362,14 +362,13 @@
   if (HasErrors)
 return 1;
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 std::string Path = OutputFilename + "." + utostr(Task);
 
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S));
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
@@ -378,7 +377,8 @@
 
   NativeObjectCache Cache;
   if (!CacheDir.empty())
-Cache = check(localCache(CacheDir, AddBuffer), "failed to create cache");
+Cache = check(localCache("ThinLTO", "Thin", CacheDir, AddBuffer),
+  "failed to create cache");
 
   check(Lto.run(AddStream, Cache), "LTO::run failed");
   return 0;
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1097,8 +1097,7 @@
 error("writing merged module failed.");
 }
 
-auto AddStream =
-[&](size_t Task) -> std::unique_ptr {
+auto AddStream = [&](size_t Task) -> std::unique_ptr {
   std::string PartFilename = OutputFilename;
   if (Parallelism != 1)
 PartFilename += "." + utostr(Task);
@@ -1108,7 +1107,7 @@
   std::make_unique(PartFilename, EC, sys::fs::OF_None);
   if (EC)
 error("error opening the file '" + PartFilename + "': " + EC.message());
-  return std::make_unique(std::move(S));
+  return std::make_unique(std::move(S));
 };
 
 if (!CodeGen.compileOptimized(AddStream, Parallelism))
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -19,11 +19,11 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/Error.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
 #include "llvm/Support/CachePruning.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
@@ -1081,12 +1081,11 @@
   size_t MaxTasks = Lto->getMaxTasks();
   std::vector, bool>> Files(MaxTasks);
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> 

[clang] e678c51 - [Support][ThinLTO] Move ThinLTO caching to LLVM Support library

2021-10-18 Thread Petr Hosek via cfe-commits

Author: Noah Shutty
Date: 2021-10-18T18:57:25-07:00
New Revision: e678c51177102845c93529d457b020f969125373

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

LOG: [Support][ThinLTO] Move ThinLTO caching to LLVM Support library

We would like to move ThinLTO’s battle-tested file caching mechanism to
the LLVM Support library so that we can use it elsewhere in LLVM.

Patch By: noajshu

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

Added: 
llvm/include/llvm/Support/Caching.h
llvm/lib/Support/Caching.cpp

Modified: 
clang/docs/tools/clang-formatted-files.txt
clang/lib/CodeGen/BackendUtil.cpp
lld/COFF/LTO.cpp
lld/ELF/LTO.cpp
lld/MachO/LTO.cpp
lld/wasm/LTO.cpp
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
llvm/lib/LTO/CMakeLists.txt
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/lib/Support/CMakeLists.txt
llvm/tools/gold/gold-plugin.cpp
llvm/tools/llvm-lto/llvm-lto.cpp
llvm/tools/llvm-lto2/llvm-lto2.cpp
llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn

Removed: 
llvm/include/llvm/LTO/Caching.h
llvm/lib/LTO/Caching.cpp



diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 1b09cc64dae5d..45451c9090b50 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -4745,7 +4745,6 @@ llvm/include/llvm/IR/ReplaceConstant.h
 llvm/include/llvm/IR/StructuralHash.h
 llvm/include/llvm/IR/TrackingMDRef.h
 llvm/include/llvm/IR/UseListOrder.h
-llvm/include/llvm/LTO/Caching.h
 llvm/include/llvm/LTO/SummaryBasedOptimizations.h
 llvm/include/llvm/MC/MCAsmInfoCOFF.h
 llvm/include/llvm/MC/MCAsmInfoDarwin.h
@@ -4852,6 +4851,7 @@ llvm/include/llvm/Support/BinaryStreamRef.h
 llvm/include/llvm/Support/BinaryStreamWriter.h
 llvm/include/llvm/Support/BuryPointer.h
 llvm/include/llvm/Support/CachePruning.h
+llvm/include/llvm/Support/Caching.h
 llvm/include/llvm/Support/CFGDiff.h
 llvm/include/llvm/Support/CFGUpdate.h
 llvm/include/llvm/Support/CodeGenCoverage.h

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 986c9e8104e9d..ff76ef1d9dd88 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1561,7 +1561,7 @@ static void runThinLTOBackend(
 return;
 
   auto AddStream = [&](size_t Task) {
-return std::make_unique(std::move(OS));
+return std::make_unique(std::move(OS));
   };
   lto::Config Conf;
   if (CGOpts.SaveTempsFilePrefix != "") {

diff  --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp
index ce9c4fd0d51b2..505360663f4f9 100644
--- a/lld/COFF/LTO.cpp
+++ b/lld/COFF/LTO.cpp
@@ -20,10 +20,10 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/Config.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/SymbolicFile.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
@@ -164,16 +164,17 @@ std::vector 
BitcodeCompiler::compile(COFFLinkerContext ) {
   // The /lldltocache option specifies the path to a directory in which to 
cache
   // native object files for ThinLTO incremental builds. If a path was
   // specified, configure LTO to use it as the cache directory.
-  lto::NativeObjectCache cache;
+  NativeObjectCache cache;
   if (!config->ltoCache.empty())
-cache = check(lto::localCache(
-config->ltoCache, [&](size_t task, std::unique_ptr mb) {
-  files[task] = std::move(mb);
-}));
+cache =
+check(localCache("ThinLTO", "Thin", config->ltoCache,
+ [&](size_t task, std::unique_ptr mb) {
+   files[task] = std::move(mb);
+ }));
 
   checkError(ltoObj->run(
   [&](size_t task) {
-return std::make_unique(
+return std::make_unique(
 std::make_unique(buf[task]));
   },
   cache));

diff  --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index fb354f81d49d6..5f206fc97b3ca 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -23,10 +23,10 @@
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/Config.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/SymbolicFile.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
@@ -304,18 +304,18 @@ std::vector BitcodeCompiler::compile() {
   // The --thinlto-cache-dir option specifies the path to 

[PATCH] D112028: [RISCV] Remove the HasSideEffects property from riscv_vector.td

2021-10-18 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai accepted this revision.
HsiangKai 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/D112028/new/

https://reviews.llvm.org/D112028

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


[PATCH] D111273: [clang-format-diff] Fix missing formatting for zero length git diff lines

2021-10-18 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

Heads up -- I think I just hit an error due to this while formatting a local 
commit:

  % ./clang/tools/clang-format/git-clang-format HEAD~1  
 
  Assertion failed: (Line && Col && "Line and column should start from 1!"), 
function translateLineCol, file 
./llvm-project/clang/lib/Basic/SourceManager.cpp, line 1699.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace.
  Stack dump:   
 
  0.  Program arguments: clang-format -lines=15:15 -lines=24:24 
-lines=46:47 -lines=73:74 -lines=82:82 -lines=117:117 -lines=128:128 
-lines=168:168 -lines=177:177 -lines=0:0 
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
  Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH 
or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):  
 
  0  clang-format 0x000101390dad 
llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 61
  1  clang-format 0x00010139135b 
PrintStackTraceSignalHandler(void*) + 27
  2  clang-format 0x00010138f00b llvm::sys::RunSignalHandlers() 
+ 123
  3  clang-format 0x000101393fb8 SignalHandler(int) + 232   
 
  4  libsystem_platform.dylib 0x7fff20639d7d _sigtramp + 29 
 
  5  libsystem_platform.dylib 00 _sigtramp + 
18446603339972764320
  6  libsystem_c.dylib0x7fff20549411 abort + 120

 
  7  libsystem_c.dylib0x7fff205487e8 err + 0
  8  clang-format 0x00010146e898 
clang::SourceManager::translateLineCol(clang::FileID, unsigned int, unsigned 
int) const + 136
  9  clang-format 0x0001011eb586 
clang::format::fillRanges(llvm::MemoryBuffer*, 
std::__1::vector >&) + 966
 
  10 clang-format 0x0001011dd718 
clang::format::format(llvm::StringRef) + 1064   
  11 clang-format 0x0001011dcc1b main + 955 

 
  12 libdyld.dylib0x7fff2060ff3d start + 1  
 
  13 libdyld.dylib0x000c start + 18446603339972935888   

 
  error: `clang-format -lines=15:15 -lines=24:24 -lines=46:47 -lines=73:74 
-lines=82:82 -lines=117:117 -lines=128:128 -lines=168:168 -lines=177:177 
-lines=0:0 llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp` failed

Reverting this patch fixed the error.

I am able to reliably reproduce this crash on Darwin by running:

  % git checkout fd26ca4e7515e7dd32ae02e777bd21693afc68ff
  % git am jitlink-table-manager-updates.patch
  % ./clang/tools/clang-format/git-clang-format HEAD~1

F19699034: jitlink-table-manager-updates.patch 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111273

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


[PATCH] D111434: [PowerPC] PPC backend optimization on conditional trap intrustions

2021-10-18 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added a comment.

gentle ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

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


[PATCH] D74531: [WebAssembly] Emit clangast in custom section aligned by 4 bytes

2021-10-18 Thread Yuta Saito via Phabricator via cfe-commits
kateinoigakukun updated this revision to Diff 380554.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74531

Files:
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/test/PCH/pch-wasm.c
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/test/MC/WebAssembly/custom-section-alignment.ll

Index: llvm/test/MC/WebAssembly/custom-section-alignment.ll
===
--- /dev/null
+++ llvm/test/MC/WebAssembly/custom-section-alignment.ll
@@ -0,0 +1,10 @@
+; RUN: llc -filetype=obj %s -o - | od -t x1 -v | FileCheck %s
+
+target triple = "wasm32-unknown-unknown"
+
+!0 = !{ !"before", !"\de\ad\be\ef" }
+!1 = !{ !"__clangast", !"\fe\ed\fa\ce" }
+!wasm.custom_sections = !{ !0, !1 }
+
+; Ensure that __clangast content is aligned by 4 bytes
+; CHECK: {{(([0-9a-f]{2} ){4})*}}fe ed fa ce
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -292,6 +292,8 @@
 W->OS << Str;
   }
 
+  void writeStringWithAlignment(const StringRef Str, unsigned Alignment);
+
   void writeI32(int32_t val) {
 char Buffer[4];
 support::endian::write32le(Buffer, val);
@@ -362,6 +364,28 @@
   Section.Index = SectionCount++;
 }
 
+// Write a string with extra paddings for trailing alignment
+// TODO: support alignment at asm and llvm level?
+void WasmObjectWriter::writeStringWithAlignment(const StringRef Str,
+unsigned Alignment) {
+
+  // Calculate the encoded size of str length and add pads based on it and
+  // alignment.
+  raw_null_ostream NullOS;
+  uint64_t StrSizeLength = encodeULEB128(Str.size(), NullOS);
+  uint64_t Offset = W->OS.tell() + StrSizeLength + Str.size();
+  uint64_t Paddings = offsetToAlignment(Offset, Align(Alignment));
+  Offset += Paddings;
+
+  // LEB128 greater than 5 bytes is invalid
+  assert((StrSizeLength + Paddings) <= 5 && "too long string to align");
+
+  encodeSLEB128(Str.size(), W->OS, StrSizeLength + Paddings);
+  W->OS << Str;
+
+  assert(W->OS.tell() == Offset && "invalid padding");
+}
+
 void WasmObjectWriter::startCustomSection(SectionBookkeeping ,
   StringRef Name) {
   LLVM_DEBUG(dbgs() << "startCustomSection " << Name << "\n");
@@ -371,7 +395,12 @@
   Section.PayloadOffset = W->OS.tell();
 
   // Custom sections in wasm also have a string identifier.
-  writeString(Name);
+  if (Name != "__clangast") {
+writeString(Name);
+  } else {
+// The on-disk hashtable in clangast needs to be aligned by 4 bytes.
+writeStringWithAlignment(Name, 4);
+  }
 
   // The position where the custom section starts.
   Section.ContentsOffset = W->OS.tell();
Index: clang/test/PCH/pch-wasm.c
===
--- /dev/null
+++ clang/test/PCH/pch-wasm.c
@@ -0,0 +1,7 @@
+// REQUIRES: webassembly-registered-target
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown-wasm -emit-pch -fmodule-format=obj %S/pchpch1.h -o - | llvm-objdump --section-headers - | FileCheck %s
+
+// Ensure that clangast section should be emitted in a section for wasm object file
+
+// CHECK: file format wasm
+// CHECK: __clangast   {{[0-9a-f]+}} {{[0-9a-f]+}}
Index: clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
===
--- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -270,25 +270,42 @@
 assert(Buffer->IsComplete && "serialization did not complete");
 auto  = Buffer->Data;
 auto Size = SerializedAST.size();
-auto Int8Ty = llvm::Type::getInt8Ty(*VMContext);
-auto *Ty = llvm::ArrayType::get(Int8Ty, Size);
-auto *Data = llvm::ConstantDataArray::getString(
-*VMContext, StringRef(SerializedAST.data(), Size),
-/*AddNull=*/false);
-auto *ASTSym = new llvm::GlobalVariable(
-*M, Ty, /*constant*/ true, llvm::GlobalVariable::InternalLinkage, Data,
-"__clang_ast");
-// The on-disk hashtable needs to be aligned.
-ASTSym->setAlignment(llvm::Align(8));
-
-// Mach-O also needs a segment name.
-if (Triple.isOSBinFormatMachO())
-  ASTSym->setSection("__CLANG,__clangast");
-// COFF has an eight character length limit.
-else if (Triple.isOSBinFormatCOFF())
-  ASTSym->setSection("clangast");
-else
-  ASTSym->setSection("__clangast");
+
+if (Triple.isOSBinFormatWasm()) {
+  // Emit __clangast in custom section instead of named data segment
+  // to find it while iterating sections.
+  // This could be avoided if all data segements (the wasm sense) were
+  // represented as their own sections (in the llvm sense).
+  // TODO: https://github.com/WebAssembly/tool-conventions/issues/138
+  

[PATCH] D74531: [WebAssembly] Emit clangast in custom section aligned by 4 bytes

2021-10-18 Thread Yuta Saito via Phabricator via cfe-commits
kateinoigakukun updated this revision to Diff 380551.
kateinoigakukun added a comment.

Thank you for taking a look again. OK, I extracted `writeStringWithAlignment` 
and updated comment lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74531

Files:
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/test/PCH/pch-wasm.c
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/test/MC/WebAssembly/custom-section-alignment.ll

Index: llvm/test/MC/WebAssembly/custom-section-alignment.ll
===
--- /dev/null
+++ llvm/test/MC/WebAssembly/custom-section-alignment.ll
@@ -0,0 +1,10 @@
+; RUN: llc -filetype=obj %s -o - | od -t x1 -v | FileCheck %s
+
+target triple = "wasm32-unknown-unknown"
+
+!0 = !{ !"before", !"\de\ad\be\ef" }
+!1 = !{ !"__clangast", !"\fe\ed\fa\ce" }
+!wasm.custom_sections = !{ !0, !1 }
+
+; Ensure that __clangast content is aligned by 4 bytes
+; CHECK: {{(([0-9a-f]{2} ){4})*}}fe ed fa ce
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -292,6 +292,8 @@
 W->OS << Str;
   }
 
+  void writeStringWithAlignment(const StringRef Str, unsigned Alignment);
+
   void writeI32(int32_t val) {
 char Buffer[4];
 support::endian::write32le(Buffer, val);
@@ -362,6 +364,28 @@
   Section.Index = SectionCount++;
 }
 
+// Write a string with extra paddings for trailing alignment
+// TODO: support alignment at asm and llvm level?
+void WasmObjectWriter::writeStringWithAlignment(const StringRef Str,
+unsigned Alignment) {
+
+  // Calculate the encoded size of str length and add pads based on it and
+  // alignment.
+  raw_null_ostream NullOS;
+  uint64_t StrSizeLength = encodeULEB128(Str.size(), NullOS);
+  uint64_t Offset = W->OS.tell() + StrSizeLength + Str.size();
+  uint64_t Paddings = offsetToAlignment(Offset, Align(Alignment));
+  Offset += Paddings;
+
+  // LEB128 greater than 5 bytes is invalid
+  assert((StrSizeLength + Paddings) <= 5 && "too long section name to align");
+
+  encodeSLEB128(Str.size(), W->OS, StrSizeLength + Paddings);
+  W->OS << Str;
+
+  assert(W->OS.tell() == Offset && "invalid padding");
+}
+
 void WasmObjectWriter::startCustomSection(SectionBookkeeping ,
   StringRef Name) {
   LLVM_DEBUG(dbgs() << "startCustomSection " << Name << "\n");
@@ -371,7 +395,12 @@
   Section.PayloadOffset = W->OS.tell();
 
   // Custom sections in wasm also have a string identifier.
-  writeString(Name);
+  if (Name != "__clangast") {
+writeString(Name);
+  } else {
+// The on-disk hashtable in clangast needs to be aligned by 4 bytes.
+writeStringWithAlignment(Name, 4);
+  }
 
   // The position where the custom section starts.
   Section.ContentsOffset = W->OS.tell();
Index: clang/test/PCH/pch-wasm.c
===
--- /dev/null
+++ clang/test/PCH/pch-wasm.c
@@ -0,0 +1,7 @@
+// REQUIRES: webassembly-registered-target
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown-wasm -emit-pch -fmodule-format=obj %S/pchpch1.h -o - | llvm-objdump --section-headers - | FileCheck %s
+
+// Ensure that clangast section should be emitted in a section for wasm object file
+
+// CHECK: file format wasm
+// CHECK: __clangast   {{[0-9a-f]+}} {{[0-9a-f]+}}
Index: clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
===
--- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -270,25 +270,42 @@
 assert(Buffer->IsComplete && "serialization did not complete");
 auto  = Buffer->Data;
 auto Size = SerializedAST.size();
-auto Int8Ty = llvm::Type::getInt8Ty(*VMContext);
-auto *Ty = llvm::ArrayType::get(Int8Ty, Size);
-auto *Data = llvm::ConstantDataArray::getString(
-*VMContext, StringRef(SerializedAST.data(), Size),
-/*AddNull=*/false);
-auto *ASTSym = new llvm::GlobalVariable(
-*M, Ty, /*constant*/ true, llvm::GlobalVariable::InternalLinkage, Data,
-"__clang_ast");
-// The on-disk hashtable needs to be aligned.
-ASTSym->setAlignment(llvm::Align(8));
-
-// Mach-O also needs a segment name.
-if (Triple.isOSBinFormatMachO())
-  ASTSym->setSection("__CLANG,__clangast");
-// COFF has an eight character length limit.
-else if (Triple.isOSBinFormatCOFF())
-  ASTSym->setSection("clangast");
-else
-  ASTSym->setSection("__clangast");
+
+if (Triple.isOSBinFormatWasm()) {
+  // Emit __clangast in custom section instead of named data segment
+  // to find it while iterating sections.
+  // This could be avoided if all data segements (the wasm sense) were
+  

[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: tra, yaxunl, arsenm, rampitec.
Herald added subscribers: jeroen.dobbelaere, ormris, foad, wenlei, bmahjour, 
kerbowa, asbirlea, rogfer01, steven_wu, george.burgess.iv, zzheng, hiraditya, 
nhaehnle, jvesely, jholewinski.
hliao requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, vkmr, wdng.
Herald added projects: clang, LLVM.

- CUDA cannot associate memory space with pointer types. Even though Clang 
could add extra attributes to specify the address space explicitly on a pointer 
type, it breaks the portability between Clang and NVCC.
- This change proposes to assume the address space from a pointer from the 
assumption built upon target-specific address space predicates, such as 
`__isGlobal` from CUDA. E.g.,

  foo(float *p) { __builtin_assume(__isGlobal(p)); // From there, we could 
assume p is a global pointer instead of a // generic one. }

  This makes the code portable without introducing the implementation-specific 
features.

  Note that NVCC starts to support __builtin_assume from version 11.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112041

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AssumptionCache.h
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/Analysis/AssumptionCache.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/builtin-assumed-addrspace.ll
  llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Analysis/AliasAnalysisTest.cpp
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
  llvm/unittests/Analysis/BasicAliasAnalysisTest.cpp
  llvm/unittests/Analysis/DDGTest.cpp
  llvm/unittests/Analysis/IVDescriptorsTest.cpp
  llvm/unittests/Analysis/LoopInfoTest.cpp
  llvm/unittests/Analysis/LoopNestTest.cpp
  llvm/unittests/Analysis/MemorySSATest.cpp
  llvm/unittests/Analysis/ScalarEvolutionTest.cpp
  llvm/unittests/Analysis/ValueTrackingTest.cpp
  llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp
  llvm/unittests/Transforms/Utils/CodeExtractorTest.cpp
  llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
  llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp
  llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp
  llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
  llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
  llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
  llvm/unittests/Transforms/Vectorize/VPlanTestBase.h

Index: llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
===
--- llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
+++ llvm/unittests/Transforms/Vectorize/VPlanTestBase.h
@@ -57,7 +57,7 @@
   void doAnalysis(Function ) {
 DT.reset(new DominatorTree(F));
 LI.reset(new LoopInfo(*DT));
-AC.reset(new AssumptionCache(F));
+AC.reset(new AssumptionCache(F, /*TTI=*/nullptr));
 SE.reset(new ScalarEvolution(F, TLI, *AC, *DT, *LI));
   }
 
Index: llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
===
--- llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
+++ llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp
@@ -38,7 +38,7 @@
 
   VPInterleavedAccessInfo getInterleavedAccessInfo(Function , Loop *L,
VPlan ) {
-AC.reset(new AssumptionCache(F));
+AC.reset(new AssumptionCache(F, /*TTI=*/nullptr));
 SE.reset(new ScalarEvolution(F, TLI, *AC, *DT, *LI));
 BasicAA.reset(new BasicAAResult(DL, F, TLI, *AC, &*DT));
 AARes.reset(new AAResults(TLI));
Index: llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
===
--- llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
+++ llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp
@@ -61,7 +61,7 @@
   auto *F = M->getFunction("test");
   DominatorTree DT(*F);
   LoopInfo LI(DT);
-  AssumptionCache AC(*F);
+  AssumptionCache AC(*F, /*TTI=*/nullptr);
   TargetLibraryInfoImpl TLII;
   TargetLibraryInfo TLI(TLII);
   ScalarEvolution SE(*F, TLI, AC, DT, LI);
Index: llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp
===
--- 

[PATCH] D111863: [libunwind] Add an interface for dynamic .eh_frame registration

2021-10-18 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

In D111863#3071353 , @joerg wrote:

> I would strongly prefer if ORCv2 doesn't depend on this. It essentially 
> forces libunwind to parse the whole section just to find the delimiters of 
> the FDEs. That's a lot of unnecessary work as JIT use normally allows 
> registering functions individually.

I don't follow this. Does libunwind provide some way to register FDEs without 
parsing the FDE content? If so we can definitely use that, but we should still 
process the whole section: ORC links objects (not functions), and we should 
register every FDE for an object when it's linked in.

It's also worth noting that ORC and MCJIT have always called `__register_frame` 
on every frame, which seems like it should be at least as much work as this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111863

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


[clang] cb5a101 - [test] Remove tests pinned to the legacy PM

2021-10-18 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-10-18T16:40:46-07:00
New Revision: cb5a10199b32b5e1104ed36a490be73fa3bdf5ca

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

LOG: [test] Remove tests pinned to the legacy PM

Now that the legacy PM is deprecated for the optimization pipeline, we
can start deleting legacy PM tests.

For tests that test both PMs, merge the RUN lines.
Delete tests specific to the legacy PM.

Added: 


Modified: 
clang/test/CodeGen/X86/avx512fp16-complex.c
clang/test/CodeGen/X86/builtin-movdir.c
clang/test/CodeGen/X86/x86_64-instrument-functions.c
clang/test/CodeGen/aggregate-assign-call.c
clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
clang/test/CodeGen/available-externally-suppress.c
clang/test/CodeGen/callback_annotated.c
clang/test/CodeGen/complex-math.c
clang/test/CodeGen/cspgo-instrumentation.c
clang/test/CodeGen/cspgo-instrumentation_lto.c
clang/test/CodeGen/lifetime.c
clang/test/CodeGen/pgo-instrumentation.c
clang/test/CodeGen/pgo-sample.c
clang/test/CodeGen/split-debug-single-file.c
clang/test/CodeGen/split-lto-unit.c
clang/test/CodeGen/thinlto-debug-pm.c
clang/test/CodeGen/use-sample-profile-attr.c
clang/test/CodeGenCXX/conditional-temporaries.cpp
clang/test/CodeGenCXX/member-function-pointer-calls.cpp
clang/test/CodeGenCXX/merge-functions.cpp
clang/test/CodeGenCXX/nrvo.cpp
clang/test/CodeGenCXX/ubsan-coroutines.cpp
clang/test/CodeGenOpenCL/convergent.cl
clang/test/Driver/asan.c
clang/test/Driver/dfsan.c
clang/test/Driver/memtag.c
clang/test/Driver/memtag_lto.c
clang/test/Driver/msan.c
clang/test/Driver/sancov.c
clang/test/Driver/tsan.c
clang/test/Frontend/optimization-remark-line-directive.c
clang/test/Profile/gcc-flag-compatibility-aix.c
clang/test/Profile/gcc-flag-compatibility.c

Removed: 
clang/test/Misc/pr32207.c



diff  --git a/clang/test/CodeGen/X86/avx512fp16-complex.c 
b/clang/test/CodeGen/X86/avx512fp16-complex.c
index 8e66cf8ab9e8..8a6b50eb0056 100644
--- a/clang/test/CodeGen/X86/avx512fp16-complex.c
+++ b/clang/test/CodeGen/X86/avx512fp16-complex.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -O0 -fno-experimental-new-pass-manager -emit-llvm 
-triple x86_64-unknown-unknown -target-feature +avx512fp16 -o - | FileCheck %s 
--check-prefix=X86
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown 
-target-feature +avx512fp16 -o - | FileCheck %s --check-prefix=X86
 
 _Float16 _Complex add_half_rr(_Float16 a, _Float16 b) {
   // X86-LABEL: @add_half_rr(

diff  --git a/clang/test/CodeGen/X86/builtin-movdir.c 
b/clang/test/CodeGen/X86/builtin-movdir.c
index f1f104db87b4..d2bc7485ee32 100644
--- a/clang/test/CodeGen/X86/builtin-movdir.c
+++ b/clang/test/CodeGen/X86/builtin-movdir.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fno-experimental-new-pass-manager -triple x86_64-unknown-unknown 
-target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,X86_64
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fno-experimental-new-pass-manager -triple i386-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fexperimental-new-pass-manager -triple x86_64-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,X86_64
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fexperimental-new-pass-manager -triple i386-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple 
x86_64-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s 
-emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,X86_64
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown 
-target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK
 
 #include 
 #include 

diff  --git a/clang/test/CodeGen/X86/x86_64-instrument-functions.c 
b/clang/test/CodeGen/X86/x86_64-instrument-functions.c
index 14e2199b0aed..0d414b4eb0cc 100644
--- a/clang/test/CodeGen/X86/x86_64-instrument-functions.c
+++ b/clang/test/CodeGen/X86/x86_64-instrument-functions.c
@@ -1,8 +1,4 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions -O0 -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions -O2 -emit-llvm 

[PATCH] D112022: [WebAssembly] Add prototype relaxed swizzle instructions

2021-10-18 Thread Ng Zhi An via Phabricator via cfe-commits
ngzhian updated this revision to Diff 380542.
ngzhian added a comment.

Add title for relaxed swizzle instruction


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112022

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td


Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1362,6 +1362,11 @@
 defm "" : SIMDLANESELECT;
 defm "" : SIMDLANESELECT;
 
+
+//===--===//
+// Relaxed swizzle
+//===--===//
+
 def wasm_relaxed_swizzle : SDNode<"WebAssemblyISD::RELAXED_SWIZZLE", 
wasm_swizzle_t>;
 
 defm RELAXED_SWIZZLE :


Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1362,6 +1362,11 @@
 defm "" : SIMDLANESELECT;
 defm "" : SIMDLANESELECT;
 
+
+//===--===//
+// Relaxed swizzle
+//===--===//
+
 def wasm_relaxed_swizzle : SDNode<"WebAssemblyISD::RELAXED_SWIZZLE", wasm_swizzle_t>;
 
 defm RELAXED_SWIZZLE :
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 684b626 - [RISCV][TableGen] Remove HasMaskedOffOperand as a member of RVVIntrinsic. NFC

2021-10-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-10-18T15:56:37-07:00
New Revision: 684b6265b31cabf422b01cd8937a3641c6df914f

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

LOG: [RISCV][TableGen] Remove HasMaskedOffOperand as a member of RVVIntrinsic. 
NFC

This value is only used by the RVVIntrinsic constructor. We don't
need it to be a member.

Added: 


Modified: 
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index d9c9ac86f34c..462406db6a75 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -155,7 +155,6 @@ class RVVIntrinsic {
   std::string IRName;
   bool HasSideEffects;
   bool IsMask;
-  bool HasMaskedOffOperand;
   bool HasVL;
   bool HasPolicy;
   bool HasNoMaskedOverloaded;
@@ -182,7 +181,6 @@ class RVVIntrinsic {
   StringRef getName() const { return Name; }
   StringRef getMangledName() const { return MangledName; }
   bool hasSideEffects() const { return HasSideEffects; }
-  bool hasMaskedOffOperand() const { return HasMaskedOffOperand; }
   bool hasVL() const { return HasVL; }
   bool hasPolicy() const { return HasPolicy; }
   bool hasNoMaskedOverloaded() const { return HasNoMaskedOverloaded; }
@@ -766,9 +764,9 @@ RVVIntrinsic::RVVIntrinsic(StringRef NewName, StringRef 
Suffix,
const std::vector ,
StringRef RequiredExtension, unsigned NF)
 : IRName(IRName), HasSideEffects(HasSideEffects), IsMask(IsMask),
-  HasMaskedOffOperand(HasMaskedOffOperand), HasVL(HasVL),
-  HasPolicy(HasPolicy), HasNoMaskedOverloaded(HasNoMaskedOverloaded),
-  HasAutoDef(HasAutoDef), ManualCodegen(ManualCodegen.str()), NF(NF) {
+  HasVL(HasVL), HasPolicy(HasPolicy),
+  HasNoMaskedOverloaded(HasNoMaskedOverloaded), HasAutoDef(HasAutoDef),
+  ManualCodegen(ManualCodegen.str()), NF(NF) {
 
   // Init Name and MangledName
   Name = NewName.str();



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


[PATCH] D111471: [NVPTX] Add a late SROA pass which allows optimizing away more allocas.

2021-10-18 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 380538.
tra added a comment.

The test uses llc only now. Opt is not affected by this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111471

Files:
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
  llvm/test/CodeGen/NVPTX/b52037.ll

Index: llvm/test/CodeGen/NVPTX/b52037.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/b52037.ll
@@ -0,0 +1,250 @@
+; Reproducer for a bad performance regression triggered by switch to the new PM.
+; `barney` ended up with the local variables not being optimized away and that
+; had rather dramatic effect on some GPU code. See
+; https://bugs.llvm.org/show_bug.cgi?id=52037 for the gory details.
+;
+; RUN: llc -mtriple=nvptx64-nvidia-cuda -mcpu=sm_70 -O3 -o - %s | FileCheck %s
+
+; CHECK-LABEL: .visible .entry barney(
+; CHECK-NOT:  .local{{.*}}__local_depot
+; CHECK: ret;
+
+source_filename = "reduced.1.ll"
+target triple = "nvptx64-nvidia-cuda"
+
+%char3 = type { i8, i8, i8 }
+%float4 = type { float, float, float, float }
+%float3 = type { float, float, float }
+%int3 = type { i32, i32, i32 }
+%struct.spam.2 = type { %struct.foo.3, i16*, float, float, i32, float }
+%struct.foo.3 = type <{ %float4*, %float4*, %float4*, i32*, i32*, i32, i32, float }>
+%struct.zot = type { %struct.bar, [8 x i8], %struct.foo, [12 x i8] }
+%struct.bar = type { i32 (...)** }
+%struct.foo = type <{ i16*, %float4, %int3, i32, %float3, [4 x i8], i64, i32, i8, [3 x i8], i32 }>
+
+@global = external local_unnamed_addr addrspace(4) externally_initialized global [27 x %char3], align 1
+@global.1 = linkonce_odr unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* inttoptr (i64 16 to i8*), i8* null, i8* null] }, align 8
+
+; Function Attrs: argmemonly mustprogress nofree nounwind willreturn
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0
+
+declare %float4 @snork(float) local_unnamed_addr
+
+declare %float3 @bar.2(float, float) local_unnamed_addr
+
+declare %float3 @zot() local_unnamed_addr
+
+declare %int3 @hoge(i32, i32, i32) local_unnamed_addr
+
+declare i64 @foo() local_unnamed_addr
+
+define void @barney(%struct.spam.2* nocapture readonly %arg) local_unnamed_addr {
+bb:
+  tail call void asm sideeffect "// KEEP", ""() #1
+  %tmp = alloca %struct.zot, align 16
+  %tmp4 = getelementptr inbounds %struct.spam.2, %struct.spam.2* %arg, i64 0, i32 1
+  %tmp5 = load i16*, i16** %tmp4, align 8
+  %tmp6 = bitcast %struct.zot* %tmp to i8*
+  %tmp9 = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2, i32 1
+  %0 = bitcast %float4* %tmp9 to i16**
+  store i16* %tmp5, i16** %0, align 8
+  %tmp10 = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 0, i32 0
+  store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @global.1, i64 0, inrange i32 0, i64 3) to i32 (...)**), i32 (...)*** %tmp10, align 16
+  %tmp34 = getelementptr %struct.spam.2, %struct.spam.2* %arg, i64 0, i32 0, i32 0
+  %tmp.i1 = tail call i64 @foo()
+  %tmp44.i16 = getelementptr inbounds i16, i16* %tmp5, i64 undef
+  %tmp45.i17 = load i16, i16* %tmp44.i16, align 2
+  %tmp47.i18 = icmp eq i16 %tmp45.i17, -1
+  br i1 %tmp47.i18, label %bb14, label %bb49.i.lr.ph
+
+bb49.i.lr.ph: ; preds = %bb
+  %tmp16 = bitcast %struct.zot* %tmp to i8**
+  %tmp7.i6 = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2
+  %extract = lshr i16 %tmp45.i17, 11
+  %extract.t = trunc i16 %extract to i8
+  %1 = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2
+  %tmp58.i = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2, i32 1, i32 2
+  %tmp59.i = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2, i32 4, i32 2
+  %tmp62.i = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2, i32 2, i32 2
+  %2 = getelementptr inbounds %struct.foo, %struct.foo* %1, i64 1
+  %3 = bitcast %struct.foo* %2 to i8*
+  %tmp64.i = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2, i32 10
+  %tmp19.i.i = load float, float* %tmp58.i, align 16
+  %tmp23.i.i = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2, i32 2
+  %4 = bitcast %int3* %tmp23.i.i to float*
+  %tmp24.i.i = load float, float* %4, align 8
+  %5 = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2, i32 5, i64 0
+  %6 = bitcast i8* %5 to float*
+  %.repack3.i = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2, i32 6
+  %7 = bitcast i64* %.repack3.i to float*
+  %tmp41.i.i = load i32, i32* %tmp62.i, align 16
+  %tmp48.i.i = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, i32 2, i32 3
+  %tmp49.i.i = load i32, i32* %tmp48.i.i, align 4
+  %tmp54.i.i = getelementptr inbounds %struct.zot, %struct.zot* %tmp, i64 0, 

[clang] 0567f03 - [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-10-18 Thread Anshil Gandhi via cfe-commits

Author: Anshil Gandhi
Date: 2021-10-18T16:53:15-06:00
New Revision: 0567f0333176e476e15b7f32b463f58f7475ff22

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

LOG: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

By default clang emits complete contructors as alias of base constructors if 
they are the same.
The backend is supposed to emit symbols for the alias, otherwise it causes 
undefined symbols.
@yaxunl observed that this issue is related to the llvm options 
`-amdgpu-early-inline-all=true`
and `-amdgpu-function-calls=false`. This issue is resolved by only inlining 
global values
with internal linkage. The `getCalleeFunction()` in AMDGPUResourceUsageAnalysis 
also had
to be extended to support aliases to functions. inline-calls.ll was corrected 
appropriately.

Reviewed By: yaxunl, #amdgpu

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

Added: 
clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
llvm/test/CodeGen/AMDGPU/inline-calls.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 83afbc3952d84..316c6026adf5c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5089,9 +5089,9 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we

diff  --git a/clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu 
b/clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
new file mode 100644
index 0..ec7b7c3b7ff4c
--- /dev/null
+++ b/clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
@@ -0,0 +1,17 @@
+// REQUIRES: amdgpu-registered-target, clang-driver
+
+// RUN: %clang -target x86_64-unknown-linux-gnu --offload-arch=gfx906 
--cuda-device-only -nogpulib -nogpuinc -x hip -emit-llvm -S -o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm 
-amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), 
void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+}

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
index 7ff24d1e9c62b..2e24e9f929d2a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
@@ -15,6 +15,7 @@
 #include "AMDGPU.h"
 #include "AMDGPUTargetMachine.h"
 #include "Utils/AMDGPUBaseInfo.h"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/CommandLine.h"
@@ -90,9 +91,13 @@ static bool alwaysInlineImpl(Module , bool GlobalOpt) {
 
   SmallPtrSet FuncsToAlwaysInline;
   SmallPtrSet FuncsToNoInline;
+  Triple TT(M.getTargetTriple());
 
   for (GlobalAlias  : M.aliases()) {
 if (Function* F = dyn_cast(A.getAliasee())) {
+  if (TT.getArch() == Triple::amdgcn &&
+  A.getLinkage() != GlobalValue::InternalLinkage)
+continue;
   A.replaceAllUsesWith(F);
   AliasesToRemove.push_back();
 }

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
index e841e939ef34b..3c5cb6e190850 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
@@ -29,6 +29,8 @@
 #include "SIMachineFunctionInfo.h"
 #include "llvm/Analysis/CallGraph.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
+#include "llvm/IR/GlobalAlias.h"
+#include "llvm/IR/GlobalValue.h"
 #include "llvm/Target/TargetMachine.h"
 
 using namespace llvm;
@@ -61,7 +63,8 @@ static const Function *getCalleeFunction(const MachineOperand 
) {
 assert(Op.getImm() == 0);
 return nullptr;
   }
-
+  if (auto *GA = dyn_cast(Op.getGlobal()))
+return cast(GA->getOperand(0));
   return cast(Op.getGlobal());
 }
 

diff  --git a/llvm/test/CodeGen/AMDGPU/inline-calls.ll 
b/llvm/test/CodeGen/AMDGPU/inline-calls.ll
index 

[clang] b477b92 - [RISCV] Fix typo in comment. NFC

2021-10-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-10-18T15:45:35-07:00
New Revision: b477b927749707982414d06674c7d2af276e046c

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

LOG: [RISCV] Fix typo in comment. NFC

Added: 


Modified: 
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 0d8b2009baab5..d9c9ac86f34ce 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -80,7 +80,7 @@ class RVVType {
   // passing to the BUILTIN() macro in Builtins.def.
   const std::string () const { return BuiltinStr; }
 
-  // Return the clang buitlin type for RVV vector type which are used in the
+  // Return the clang builtin type for RVV vector type which are used in the
   // riscv_vector.h header file.
   const std::string () const { return ClangBuiltinStr; }
 



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


[PATCH] D111371: [Support][ThinLTO] Move ThinLTO caching to LLVM Support library.

2021-10-18 Thread Noah Shutty via Phabricator via cfe-commits
noajshu updated this revision to Diff 380527.
noajshu added a comment.

Migrate references to Caching.cpp from 
llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn to [...]/Support/BUILD.gn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111371

Files:
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/LTO.cpp
  lld/ELF/LTO.cpp
  lld/MachO/LTO.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/Caching.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/Support/Caching.h
  llvm/lib/LTO/CMakeLists.txt
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Caching.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn
  llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
@@ -54,6 +54,7 @@
 "COM.cpp",
 "CRC.cpp",
 "CachePruning.cpp",
+"Caching.cpp",
 "Chrono.cpp",
 "CodeGenCoverage.cpp",
 "CommandLine.cpp",
Index: llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/LTO/BUILD.gn
@@ -22,7 +22,6 @@
 "//llvm/lib/Transforms/Utils",
   ]
   sources = [
-"Caching.cpp",
 "LTO.cpp",
 "LTOBackend.cpp",
 "LTOCodeGenerator.cpp",
Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -19,10 +19,10 @@
 #include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -362,14 +362,13 @@
   if (HasErrors)
 return 1;
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 std::string Path = OutputFilename + "." + utostr(Task);
 
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S));
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
@@ -378,7 +377,8 @@
 
   NativeObjectCache Cache;
   if (!CacheDir.empty())
-Cache = check(localCache(CacheDir, AddBuffer), "failed to create cache");
+Cache = check(localCache("ThinLTO", "Thin", CacheDir, AddBuffer),
+  "failed to create cache");
 
   check(Lto.run(AddStream, Cache), "LTO::run failed");
   return 0;
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1097,8 +1097,7 @@
 error("writing merged module failed.");
 }
 
-auto AddStream =
-[&](size_t Task) -> std::unique_ptr {
+auto AddStream = [&](size_t Task) -> std::unique_ptr {
   std::string PartFilename = OutputFilename;
   if (Parallelism != 1)
 PartFilename += "." + utostr(Task);
@@ -1108,7 +1107,7 @@
   std::make_unique(PartFilename, EC, sys::fs::OF_None);
   if (EC)
 error("error opening the file '" + PartFilename + "': " + EC.message());
-  return std::make_unique(std::move(S));
+  return std::make_unique(std::move(S));
 };
 
 if (!CodeGen.compileOptimized(AddStream, Parallelism))
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -19,11 +19,11 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/Error.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
 #include "llvm/Support/CachePruning.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
@@ -1081,12 +1081,11 @@
   size_t MaxTasks = Lto->getMaxTasks();
   std::vector, bool>> Files(MaxTasks);
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 

[PATCH] D111471: [NVPTX] Add a late SROA pass which allows optimizing away more allocas.

2021-10-18 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111471

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


[PATCH] D111471: [NVPTX] Add a late SROA pass which allows optimizing away more allocas.

2021-10-18 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 380524.
tra added a comment.

Moved the test to LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111471

Files:
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
  llvm/test/CodeGen/NVPTX/b52037.ll

Index: llvm/test/CodeGen/NVPTX/b52037.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/b52037.ll
@@ -0,0 +1,252 @@
+; Reproducer for a bad performance regression triggered by switch to the new PM.
+; `barney` ended up with the local variables not being optimized away and that
+; had rather dramatic effect on some GPU code. See
+; https://bugs.llvm.org/show_bug.cgi?id=52037 for the gory details.
+;
+; RUN: opt -mtriple=nvptx64-nvidia-cuda -passes='default' -S %s -o - \
+; RUN:  | llc -mtriple=nvptx64-nvidia-cuda -mcpu=sm_70 -O3  -o - \
+; RUN:  | FileCheck %s
+
+; CHECK-LABEL: .visible .entry barney(
+; CHECK-NOT:  .local{{.*}}__local_depot
+; CHECK: ret;
+
+source_filename = "reduced.1.ll"
+
+%char3 = type { i8, i8, i8 }
+%float4 = type { float, float, float, float }
+%float3 = type { float, float, float }
+%int3 = type { i32, i32, i32 }
+%struct.w = type { i32 (...)**, [8 x i8], i32, [12 x i8] }
+%struct.blam = type <{ i32*, i16*, %float4, %int3, i32, %float3, [4 x i8], i64, i32, i8, [3 x i8], i32, [12 x i8] }>
+%struct.spam.2 = type { %struct.foo.3, i16*, float, float, i32, float }
+%struct.foo.3 = type <{ %float4*, %float4*, %float4*, i32*, i32*, i32, i32, float }>
+%struct.zot = type { %struct.bar, [8 x i8], %struct.foo, [12 x i8] }
+%struct.bar = type { i32 (...)** }
+%struct.foo = type <{ i16*, %float4, %int3, i32, %float3, [4 x i8], i64, i32, i8, [3 x i8], i32 }>
+
+@global = external addrspace(4) externally_initialized global [27 x %char3], align 1
+@global.1 = linkonce_odr unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* inttoptr (i64 16 to i8*), i8* null, i8* null] }, align 8
+
+; Function Attrs: argmemonly nofree nounwind willreturn
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0
+
+declare %float4 @snork(float)
+
+declare %float3 @bar.2(float, float)
+
+declare %float3 @zot()
+
+declare %int3 @hoge(i32, i32, i32)
+
+define internal i1 @pluto(%struct.w* %arg) {
+bb:
+  %tmp = call i64 @foo()
+  %tmp1 = bitcast %struct.w* %arg to i8**
+  %tmp2 = load i8*, i8** %tmp1, align 8, !tbaa !1
+  %tmp3 = getelementptr i8, i8* %tmp2, i64 -24
+  %tmp4 = bitcast i8* %tmp3 to i64*
+  %tmp5 = load i64, i64* %tmp4, align 8
+  %tmp6 = bitcast %struct.w* %arg to i8*
+  %tmp7 = getelementptr inbounds i8, i8* %tmp6, i64 %tmp5
+  %tmp8 = bitcast i8* %tmp7 to %struct.blam*
+  %tmp9 = getelementptr inbounds %struct.blam, %struct.blam* %tmp8, i32 undef, i32 7
+  %tmp10 = load i64, i64* %tmp9, align 16
+  %tmp11 = add i64 %tmp10, %tmp
+  store i64 %tmp11, i64* %tmp9, align 16, !tbaa !4
+  %tmp12 = bitcast %struct.w* %arg to i8**
+  %tmp13 = load i8*, i8** %tmp12, align 8, !tbaa !1
+  %tmp14 = getelementptr i8, i8* %tmp13, i64 -24
+  %tmp15 = bitcast i8* %tmp14 to i64*
+  %tmp16 = load i64, i64* %tmp15, align 8
+  %tmp17 = bitcast %struct.w* %arg to i8*
+  %tmp18 = getelementptr inbounds i8, i8* %tmp17, i64 %tmp16
+  %tmp19 = bitcast i8* %tmp18 to %struct.blam*
+  %tmp20 = getelementptr inbounds %struct.blam, %struct.blam* %tmp19, i32 undef, i32 1
+  %tmp21 = load i16*, i16** %tmp20, align 8
+  %tmp22 = bitcast %struct.w* %arg to i8**
+  %tmp23 = load i8*, i8** %tmp22, align 8
+  %tmp24 = getelementptr i8, i8* %tmp23, i64 -24
+  %tmp25 = bitcast i8* %tmp24 to i64*
+  %tmp26 = load i64, i64* %tmp25, align 8
+  %tmp27 = bitcast %struct.w* %arg to i8*
+  %tmp28 = getelementptr inbounds i8, i8* %tmp27, i64 %tmp26
+  %tmp29 = bitcast i8* %tmp28 to %struct.blam*
+  %tmp30 = getelementptr inbounds %struct.blam, %struct.blam* %tmp29, i32 undef, i32 7
+  %tmp31 = load i64, i64* %tmp30, align 16
+  %tmp32 = bitcast %struct.w* %arg to i8**
+  %tmp33 = load i8*, i8** %tmp32, align 8
+  %tmp34 = getelementptr i8, i8* %tmp33, i64 -24
+  %tmp35 = bitcast i8* %tmp34 to i64*
+  %tmp36 = load i64, i64* %tmp35, align 8
+  %tmp37 = bitcast %struct.w* %arg to i8*
+  %tmp38 = getelementptr inbounds i8, i8* %tmp37, i64 %tmp36
+  %tmp39 = bitcast i8* %tmp38 to %struct.blam*
+  %tmp40 = getelementptr inbounds %struct.blam, %struct.blam* %tmp39, i32 undef, i32 4
+  %tmp41 = load i32, i32* %tmp40, align 4
+  %tmp42 = zext i32 %tmp41 to i64
+  %tmp43 = add i64 %tmp31, %tmp42
+  %tmp44 = getelementptr inbounds i16, i16* %tmp21, i64 %tmp43
+  %tmp45 = load i16, i16* %tmp44, align 2
+  %tmp46 = zext i16 %tmp45 to i32
+  %tmp47 = icmp eq i32 %tmp46, 65535
+  br i1 %tmp47, label %bb67, label %bb49
+
+bb49: ; preds = %bb
+  %tmp50 = bitcast %struct.w* %arg to i8**
+  %tmp51 = load i8*, i8** %tmp50, align 8
+  

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 380518.
ASDenysPetrov added a comment.

Rebased on top of D106681 .


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

https://reviews.llvm.org/D111542

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/initialization.c


Index: clang/test/Analysis/initialization.c
===
--- clang/test/Analysis/initialization.c
+++ clang/test/Analysis/initialization.c
@@ -97,3 +97,42 @@
   // FIXME: Should warn {{garbage or undefined}}.
   int res = glob_arr2[x][y]; // no-warning
 }
+
+const int glob_arr3[];  // IncompleteArrayType
+const int glob_arr3[4] = {1, 2, 3}; // ConstantArrayType
+void glob_arr_index4() {
+  clang_analyzer_eval(glob_arr3[0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr3[1] == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr3[2] == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr3[3] == 0); // expected-warning{{TRUE}}
+}
+
+void glob_invalid_index5() {
+  int x = 42;
+  int res = glob_arr3[x]; // expected-warning{{garbage or undefined}}
+}
+
+void glob_invalid_index6() {
+  int x = -42;
+  int res = glob_arr3[x]; // expected-warning{{garbage or undefined}}
+}
+
+const int glob_arr4[];  // IncompleteArrayType
+const int glob_arr4[4] = {1, 2, 3}; // ConstantArrayType
+const int glob_arr4[];  // ConstantArrayType (according to AST)
+void glob_arr_index5() {
+  clang_analyzer_eval(glob_arr4[0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[1] == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[2] == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[3] == 0); // expected-warning{{TRUE}}
+}
+
+void glob_invalid_index7() {
+  int x = 42;
+  int res = glob_arr4[x]; // expected-warning{{garbage or undefined}}
+}
+
+void glob_invalid_index8() {
+  int x = -42;
+  int res = glob_arr4[x]; // expected-warning{{garbage or undefined}}
+}
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1640,7 +1640,21 @@
   (!B.isMainAnalysis() || !VD->hasGlobalStorage()))
 return None;
 
-  // Array's declaration should have ConstantArrayType type.
+  // Array's declaration should have `ConstantArrayType` type, because only 
this
+  // type contains an array extent. It may happen that array type can be of
+  // `IncompleteArrayType` type. To get the declaration of `ConstantArrayType`
+  // type, we should find the declaration in the redeclarations chain that has
+  // the initialization expression.
+  // NOTE: `VD` is always non-null if `Init` is non-null, so we can check for
+  // null only one of them.
+  const Expr *Init = VD->getAnyInitializer(VD);
+
+  // Array's declaration should have an initializer.
+  if (!Init)
+return None;
+
+  // Array's declaration should have ConstantArrayType type, because only this
+  // type contains an array extent.
   const ConstantArrayType *CAT = Ctx.getAsConstantArrayType(VD->getType());
   if (!CAT)
 return None;
@@ -1683,11 +1697,6 @@
 return UndefinedVal();
   // From here `Offset` is in the bounds.
 
-  // Array's declaration should have an initializer.
-  const Expr *Init = VD->getAnyInitializer();
-  if (!Init)
-return None;
-
   // Handle InitListExpr.
   if (const auto *ILE = dyn_cast(Init))
 return getSValFromInitListExpr(ILE, Offset, R->getElementType());


Index: clang/test/Analysis/initialization.c
===
--- clang/test/Analysis/initialization.c
+++ clang/test/Analysis/initialization.c
@@ -97,3 +97,42 @@
   // FIXME: Should warn {{garbage or undefined}}.
   int res = glob_arr2[x][y]; // no-warning
 }
+
+const int glob_arr3[];  // IncompleteArrayType
+const int glob_arr3[4] = {1, 2, 3}; // ConstantArrayType
+void glob_arr_index4() {
+  clang_analyzer_eval(glob_arr3[0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr3[1] == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr3[2] == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr3[3] == 0); // expected-warning{{TRUE}}
+}
+
+void glob_invalid_index5() {
+  int x = 42;
+  int res = glob_arr3[x]; // expected-warning{{garbage or undefined}}
+}
+
+void glob_invalid_index6() {
+  int x = -42;
+  int res = glob_arr3[x]; // expected-warning{{garbage or undefined}}
+}
+
+const int glob_arr4[];  // IncompleteArrayType
+const int glob_arr4[4] = {1, 2, 3}; // ConstantArrayType
+const int glob_arr4[];  // ConstantArrayType (according to AST)
+void glob_arr_index5() {
+  clang_analyzer_eval(glob_arr4[0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[1] == 2); // 

[PATCH] D111184: [clang] Allow printing 64 bit ints in diagnostics

2021-10-18 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D84#3071422 , @dblaikie wrote:

> Is there no diagnostic that could reasonably produce such a large value that 
> would be easy to test (without needing a giant binary, etc)? (seem surprising 
> to see this change without any test coverage)
>
> Like a 64 bit non-type template parameter or the like, perhaps?

Previously no, but https://reviews.llvm.org/D111250 modifies some tests to 
print 2^32, which was the motivating case behind this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84

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


[PATCH] D111184: [clang] Allow printing 64 bit ints in diagnostics

2021-10-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Is there no diagnostic that could reasonably produce such a large value that 
would be easy to test (without needing a giant binary, etc)? (seem surprising 
to see this change without any test coverage)

Like a 64 bit non-type template parameter or the like, perhaps?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84

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


[PATCH] D112032: [RISCV] Use a lambda to avoid having the Support library depend on Option library.

2021-10-18 Thread Craig Topper 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 rG1053e0b27ce1: [RISCV] Use a lambda to avoid having the 
Support library depend on Option… (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112032

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -11,7 +11,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Option/ArgList.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
@@ -252,8 +251,9 @@
   return LHS < RHS;
 }
 
-void RISCVISAInfo::toFeatures(const llvm::opt::ArgList ,
-  std::vector ) const {
+void RISCVISAInfo::toFeatures(
+std::vector ,
+std::function StrAlloc) const {
   for (auto  : Exts) {
 StringRef ExtName = Ext.first;
 
@@ -268,9 +268,9 @@
   Features.push_back("+experimental-zvlsseg");
   Features.push_back("+experimental-zvamo");
 } else if (isExperimentalExtension(ExtName)) {
-  Features.push_back(Args.MakeArgString("+experimental-" + ExtName));
+  Features.push_back(StrAlloc("+experimental-" + ExtName));
 } else {
-  Features.push_back(Args.MakeArgString("+" + ExtName));
+  Features.push_back(StrAlloc("+" + ExtName));
 }
   }
 }
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -19,9 +19,6 @@
 #include 
 
 namespace llvm {
-namespace opt {
-class ArgList;
-}
 struct RISCVExtensionInfo {
   std::string ExtName;
   unsigned MajorVersion;
@@ -57,8 +54,8 @@
   parseFeatures(unsigned XLen, const std::vector );
 
   /// Convert RISCV ISA info to a feature vector.
-  void toFeatures(const llvm::opt::ArgList ,
-  std::vector ) const;
+  void toFeatures(std::vector ,
+  std::function StrAlloc) const;
 
   const OrderedExtensionMap () const { return Exts; };
 
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -41,7 +41,8 @@
 return false;
   }
 
-  (*ISAInfo)->toFeatures(Args, Features);
+  (*ISAInfo)->toFeatures(
+  Features, [](const Twine ) { return Args.MakeArgString(Str); });
   return true;
 }
 


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -11,7 +11,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Option/ArgList.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
@@ -252,8 +251,9 @@
   return LHS < RHS;
 }
 
-void RISCVISAInfo::toFeatures(const llvm::opt::ArgList ,
-  std::vector ) const {
+void RISCVISAInfo::toFeatures(
+std::vector ,
+std::function StrAlloc) const {
   for (auto  : Exts) {
 StringRef ExtName = Ext.first;
 
@@ -268,9 +268,9 @@
   Features.push_back("+experimental-zvlsseg");
   Features.push_back("+experimental-zvamo");
 } else if (isExperimentalExtension(ExtName)) {
-  Features.push_back(Args.MakeArgString("+experimental-" + ExtName));
+  Features.push_back(StrAlloc("+experimental-" + ExtName));
 } else {
-  Features.push_back(Args.MakeArgString("+" + ExtName));
+  Features.push_back(StrAlloc("+" + ExtName));
 }
   }
 }
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -19,9 +19,6 @@
 #include 
 
 namespace llvm {
-namespace opt {
-class ArgList;
-}
 struct RISCVExtensionInfo {
   std::string ExtName;
   unsigned MajorVersion;
@@ -57,8 +54,8 @@
   parseFeatures(unsigned XLen, const std::vector );
 
   /// Convert RISCV ISA info to a feature vector.
-  void toFeatures(const llvm::opt::ArgList ,
-  std::vector ) const;
+  void toFeatures(std::vector ,
+  std::function StrAlloc) const;
 
   const OrderedExtensionMap () const { return Exts; };
 
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ 

[PATCH] D112030: [docs] Remove Makefile.sphinx files

2021-10-18 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

I am using them but I can move to sphinx calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112030

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


[clang] 1053e0b - [RISCV] Use a lambda to avoid having the Support library depend on Option library.

2021-10-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-10-18T13:39:37-07:00
New Revision: 1053e0b27ce135ce2da63af01aa986b9425386ee

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

LOG: [RISCV] Use a lambda to avoid having the Support library depend on Option 
library.

RISCVISAInfo::toFeatures needs to allocate strings using
ArgList::MakeArgString, but toFeatures lives in Support and
MakeArgString lives in Option.

toFeature only has one caller, so the simple fix is to have that
caller pass a lamdba that wraps MakeArgString to break the
dependency.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
llvm/include/llvm/Support/RISCVISAInfo.h
llvm/lib/Support/RISCVISAInfo.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 6cb6d0b2d1fcc..323f588c8269c 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -41,7 +41,8 @@ static bool getArchFeatures(const Driver , StringRef Arch,
 return false;
   }
 
-  (*ISAInfo)->toFeatures(Args, Features);
+  (*ISAInfo)->toFeatures(
+  Features, [](const Twine ) { return Args.MakeArgString(Str); });
   return true;
 }
 

diff  --git a/llvm/include/llvm/Support/RISCVISAInfo.h 
b/llvm/include/llvm/Support/RISCVISAInfo.h
index fe8599e1e04be..7110de601123f 100644
--- a/llvm/include/llvm/Support/RISCVISAInfo.h
+++ b/llvm/include/llvm/Support/RISCVISAInfo.h
@@ -19,9 +19,6 @@
 #include 
 
 namespace llvm {
-namespace opt {
-class ArgList;
-}
 struct RISCVExtensionInfo {
   std::string ExtName;
   unsigned MajorVersion;
@@ -57,8 +54,8 @@ class RISCVISAInfo {
   parseFeatures(unsigned XLen, const std::vector );
 
   /// Convert RISCV ISA info to a feature vector.
-  void toFeatures(const llvm::opt::ArgList ,
-  std::vector ) const;
+  void toFeatures(std::vector ,
+  std::function StrAlloc) const;
 
   const OrderedExtensionMap () const { return Exts; };
 

diff  --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 795d77defc984..8bbfc757f0755 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -11,7 +11,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Option/ArgList.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
@@ -252,8 +251,9 @@ bool RISCVISAInfo::compareExtension(const std::string ,
   return LHS < RHS;
 }
 
-void RISCVISAInfo::toFeatures(const llvm::opt::ArgList ,
-  std::vector ) const {
+void RISCVISAInfo::toFeatures(
+std::vector ,
+std::function StrAlloc) const {
   for (auto  : Exts) {
 StringRef ExtName = Ext.first;
 
@@ -268,9 +268,9 @@ void RISCVISAInfo::toFeatures(const llvm::opt::ArgList 
,
   Features.push_back("+experimental-zvlsseg");
   Features.push_back("+experimental-zvamo");
 } else if (isExperimentalExtension(ExtName)) {
-  Features.push_back(Args.MakeArgString("+experimental-" + ExtName));
+  Features.push_back(StrAlloc("+experimental-" + ExtName));
 } else {
-  Features.push_back(Args.MakeArgString("+" + ExtName));
+  Features.push_back(StrAlloc("+" + ExtName));
 }
   }
 }



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


[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D105168#3071330 , @jrtc27 wrote:

> In D105168#3071321 , @craig.topper 
> wrote:
>
>> In D105168#3071249 , @jrtc27 wrote:
>>
>>> Two options come to mind if we really need to be outputting a StringRef 
>>> list:
>>>
>>> 1. (the simpler option) Pass in a Twine -> `const char *` lambda that the 
>>> caller hooks up to Args.MakeArgString
>>
>> Good idea. I'll post a patch for that shortly.
>>
>>> 2. (probably the nicer option) Invent our own MakeArgString that allocates 
>>> from storage owned by RISCVISAInfo itself; lots of ways you can do that
>>
>> I don't think the RISCVISAInfo objects lives long enough for that. It only 
>> lives for the duration of the function that calls toFeatures, but the 
>> Features vector is returned from that function.
>
> Hm, I see. We could also just have a global cache of heap-allocated copies of 
> these strings, I guess; after all it's not all that different from the tables 
> of strings we already have, just lazily built up at run time (can even store 
> them in a lazily-initialised field of each RISCVExtensionInfo). Or we just 
> stick to the slightly-ugly lambda approach, unless anyone else has bright 
> ideas for a cleaner interface and implementation.

Lambda approach here https://reviews.llvm.org/D112032


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[PATCH] D112032: [RISCV] Use a lambda to avoid having the Support library depend on Option library.

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: jrtc27, kito-cheng, HsiangKai, khchen, arcbbb.
Herald added subscribers: achieveartificialintelligence, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, 
asb, hiraditya.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added projects: clang, LLVM.

RISCVISAInfo::toFeatures needs to allocate strings using
ArgList::MakeArgString, but toFeatures lives in Support and
MakeArgString lives in Option.

toFeature only has one caller, so the simple fix is to have that
caller pass a lamdba that wraps MakeArgString to break the
dependency.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112032

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -11,7 +11,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Option/ArgList.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
@@ -252,8 +251,9 @@
   return LHS < RHS;
 }
 
-void RISCVISAInfo::toFeatures(const llvm::opt::ArgList ,
-  std::vector ) const {
+void RISCVISAInfo::toFeatures(
+std::vector ,
+std::function StrAlloc) const {
   for (auto  : Exts) {
 StringRef ExtName = Ext.first;
 
@@ -268,9 +268,9 @@
   Features.push_back("+experimental-zvlsseg");
   Features.push_back("+experimental-zvamo");
 } else if (isExperimentalExtension(ExtName)) {
-  Features.push_back(Args.MakeArgString("+experimental-" + ExtName));
+  Features.push_back(StrAlloc("+experimental-" + ExtName));
 } else {
-  Features.push_back(Args.MakeArgString("+" + ExtName));
+  Features.push_back(StrAlloc("+" + ExtName));
 }
   }
 }
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -19,9 +19,6 @@
 #include 
 
 namespace llvm {
-namespace opt {
-class ArgList;
-}
 struct RISCVExtensionInfo {
   std::string ExtName;
   unsigned MajorVersion;
@@ -57,8 +54,8 @@
   parseFeatures(unsigned XLen, const std::vector );
 
   /// Convert RISCV ISA info to a feature vector.
-  void toFeatures(const llvm::opt::ArgList ,
-  std::vector ) const;
+  void toFeatures(std::vector ,
+  std::function StrAlloc) const;
 
   const OrderedExtensionMap () const { return Exts; };
 
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -41,7 +41,8 @@
 return false;
   }
 
-  (*ISAInfo)->toFeatures(Args, Features);
+  (*ISAInfo)->toFeatures(
+  Features, [](const Twine ) { return Args.MakeArgString(Str); });
   return true;
 }
 


Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -11,7 +11,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Option/ArgList.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
@@ -252,8 +251,9 @@
   return LHS < RHS;
 }
 
-void RISCVISAInfo::toFeatures(const llvm::opt::ArgList ,
-  std::vector ) const {
+void RISCVISAInfo::toFeatures(
+std::vector ,
+std::function StrAlloc) const {
   for (auto  : Exts) {
 StringRef ExtName = Ext.first;
 
@@ -268,9 +268,9 @@
   Features.push_back("+experimental-zvlsseg");
   Features.push_back("+experimental-zvamo");
 } else if (isExperimentalExtension(ExtName)) {
-  Features.push_back(Args.MakeArgString("+experimental-" + ExtName));
+  Features.push_back(StrAlloc("+experimental-" + ExtName));
 } else {
-  Features.push_back(Args.MakeArgString("+" + ExtName));
+  Features.push_back(StrAlloc("+" + ExtName));
 }
   }
 }
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -19,9 +19,6 @@
 #include 
 
 namespace llvm {
-namespace opt {
-class ArgList;
-}
 struct RISCVExtensionInfo {
   std::string ExtName;
   unsigned MajorVersion;
@@ -57,8 +54,8 @@
   

[PATCH] D111863: [libunwind] Add an interface for dynamic .eh_frame registration

2021-10-18 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D111863#3071328 , @housel wrote:

> In D111863#3069279 , @lhames wrote:
>
>> I think the ORC runtime provides a much more natural way to test this. Did 
>> you manage to come up with some ORC-runtime based tests in the end?
>
> My current plan is to automate what I've been doing manually, namely running 
> a test of C++ exception handling using `llvm-jitlink`, both with the default 
> configuration (using libgcc-provided unwinding), and with libunwind 
> `LD_PRELOAD`ed to force it as the unwinding provider.

@lhames  The other possibility is to lift JIT runtime to top level in 
llvm-project so it can link libunwind into its runtime so you don't need to:

- Create a public API in libunwind to support JIT
- Worry about deploying a compatible libunwind together with JIT (or worry 
about back-deploy)
- You can write all the tests in ORCJIT context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111863

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


[PATCH] D111009: Update inline builtin handling to honor gnu inline attribute

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

Also reported here: 
https://lore.kernel.org/llvm/1817774243.12566.1634255267713@localhost/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111009

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


[PATCH] D111863: [libunwind] Add an interface for dynamic .eh_frame registration

2021-10-18 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

I would strongly prefer if ORCv2 doesn't depend on this. It essentially forces 
libunwind to parse the whole section just to find the delimiters of the FDEs. 
That's a lot of unnecessary work as JIT use normally allows registering 
functions individually.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111863

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


[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-18 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D105168#3071321 , @craig.topper 
wrote:

> In D105168#3071249 , @jrtc27 wrote:
>
>> Two options come to mind if we really need to be outputting a StringRef list:
>>
>> 1. (the simpler option) Pass in a Twine -> `const char *` lambda that the 
>> caller hooks up to Args.MakeArgString
>
> Good idea. I'll post a patch for that shortly.
>
>> 2. (probably the nicer option) Invent our own MakeArgString that allocates 
>> from storage owned by RISCVISAInfo itself; lots of ways you can do that
>
> I don't think the RISCVISAInfo objects lives long enough for that. It only 
> lives for the duration of the function that calls toFeatures, but the 
> Features vector is returned from that function.

Hm, I see. We could also just have a global cache of heap-allocated copies of 
these strings, I guess; after all it's not all that different from the tables 
of strings we already have, just lazily built up at run time. Or we just stick 
to the slightly-ugly lambda approach, unless anyone else has bright ideas for a 
cleaner interface and implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[PATCH] D111863: [libunwind] Add an interface for dynamic .eh_frame registration

2021-10-18 Thread Peter S. Housel via Phabricator via cfe-commits
housel added a comment.

In D111863#3069279 , @lhames wrote:

> I think the ORC runtime provides a much more natural way to test this. Did 
> you manage to come up with some ORC-runtime based tests in the end?

My current plan is to automate what I've been doing manually, namely running a 
test of C++ exception handling using `llvm-jitlink`, both with the default 
configuration (using libgcc-provided unwinding), and with libunwind 
`LD_PRELOAD`ed to force it as the unwinding provider.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111863

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


[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D105168#3071249 , @jrtc27 wrote:

> Two options come to mind if we really need to be outputting a StringRef list:
>
> 1. (the simpler option) Pass in a Twine -> `const char *` lambda that the 
> caller hooks up to Args.MakeArgString

Good idea. I'll post a patch for that shortly.

> 2. (probably the nicer option) Invent our own MakeArgString that allocates 
> from storage owned by RISCVISAInfo itself; lots of ways you can do that

I don't think the RISCVISAInfo objects lives long enough for that. It only 
lives for the duration of the function that calls toFeatures, but the Features 
vector is returned from that function.

> Adding a new library just so we can use MakeArgString seems overkill, even if 
> there are other things that perhaps belong in something a bit less shared 
> than Support.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


Re: [clang] 2edb89c - Lex arguments for __has_cpp_attribute and friends as expanded tokens

2021-10-18 Thread Richard Smith via cfe-commits
On Mon, 18 Oct 2021 at 12:56, Aaron Ballman  wrote:

> On Mon, Oct 18, 2021 at 3:52 PM Richard Smith 
> wrote:
> >
> >  On Mon, 18 Oct 2021 at 12:48, Aaron Ballman 
> wrote:
> >>
> >> On Mon, Oct 18, 2021 at 3:33 PM Richard Smith 
> wrote:
> >> >
> >> > On Sun, 17 Oct 2021 at 04:58, Aaron Ballman via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >> >>
> >> >>
> >> >> Author: Aaron Ballman
> >> >> Date: 2021-10-17T07:54:48-04:00
> >> >> New Revision: 2edb89c746848c52964537268bf03e7906bf2542
> >> >>
> >> >> URL:
> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542
> >> >> DIFF:
> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542.diff
> >> >>
> >> >> LOG: Lex arguments for __has_cpp_attribute and friends as expanded
> tokens
> >> >>
> >> >> The C and C++ standards require the argument to __has_cpp_attribute
> and
> >> >> __has_c_attribute to be expanded ([cpp.cond]p5). It would make
> little sense
> >> >> to expand the argument to those operators but not expand the
> argument to
> >> >> __has_attribute and __has_declspec, so those were both also changed
> in this
> >> >> patch.
> >> >>
> >> >> Note that it might make sense for the other builtins to also expand
> their
> >> >> argument, but it wasn't as clear to me whether the behavior would be
> correct
> >> >> there, and so they were left for a future revision.
> >> >>
> >> >> Added:
> >> >> clang/test/Preprocessor/has_attribute_errors.cpp
> >> >>
> >> >> Modified:
> >> >> clang/docs/ReleaseNotes.rst
> >> >> clang/lib/Lex/PPMacroExpansion.cpp
> >> >> clang/test/Preprocessor/has_attribute.c
> >> >> clang/test/Preprocessor/has_attribute.cpp
> >> >> clang/test/Preprocessor/has_c_attribute.c
> >> >>
> >> >> Removed:
> >> >>
> >> >>
> >> >>
> >> >>
> 
> >> >> diff  --git a/clang/docs/ReleaseNotes.rst
> b/clang/docs/ReleaseNotes.rst
> >> >> index 6501a4870e2a6..263eae83036df 100644
> >> >> --- a/clang/docs/ReleaseNotes.rst
> >> >> +++ b/clang/docs/ReleaseNotes.rst
> >> >> @@ -110,6 +110,13 @@ Attribute Changes in Clang
> >> >>attribute is handled instead, e.g. in ``handleDeclAttribute``.
> >> >>(This was changed in order to better support attributes in code
> completion).
> >> >>
> >> >> +- __has_cpp_attribute, __has_c_attribute, __has_attribute, and
> __has_declspec
> >> >> +  will now macro expand their argument. This causes a change in
> behavior for
> >> >> +  code using ``__has_cpp_attribute(__clang__::attr)`` (and same for
> >> >> +  ``__has_c_attribute``) where it would previously expand to ``0``
> for all
> >> >> +  attributes, but will now issue an error due to the expansion of
> the
> >> >> +  predefined ``__clang__`` macro.
> >> >> +
> >> >>  Windows Support
> >> >>  ---
> >> >>
> >> >>
> >> >> diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp
> b/clang/lib/Lex/PPMacroExpansion.cpp
> >> >> index bf19f538647e6..5a0fa5184e38b 100644
> >> >> --- a/clang/lib/Lex/PPMacroExpansion.cpp
> >> >> +++ b/clang/lib/Lex/PPMacroExpansion.cpp
> >> >> @@ -1293,7 +1293,7 @@ static bool EvaluateHasIncludeNext(Token ,
> >> >>  /// integer values.
> >> >>  static void
> EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
> >> >>  Token ,
> IdentifierInfo *II,
> >> >> -Preprocessor ,
> >> >> +Preprocessor , bool
> ExpandArgs,
> >> >>  llvm::function_ref<
> >> >>int(Token ,
> >> >>bool
> )> Op) {
> >> >> @@ -1319,7 +1319,10 @@ static void
> EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
> >> >>bool SuppressDiagnostic = false;
> >> >>while (true) {
> >> >>  // Parse next token.
> >> >> -PP.LexUnexpandedToken(Tok);
> >> >> +if (ExpandArgs)
> >> >> +  PP.Lex(Tok);
> >> >> +else
> >> >> +  PP.LexUnexpandedToken(Tok);
> >> >
> >> >
> >> > How does this handle things like:
> >> >
> >> > #define RPAREN )
> >> > #if __has_attribute(clang::fallthrough RPAREN
> >> >
> >> > ? I think that should be an error: the ) token should not be produced
> by macro expansion, analogous to the behavior of function-like macros. But
> I imagine unless we're careful here, we'll allow that macro expansion to
> terminate the "macro".
> >>
> >> I agree, I think that should be an error. We handle it reasonably too;
> I get:
> >>
> >> error: missing ')' after 'clang'
> >>
> >> though it appears there is some compiler divergence here:
> >> https://godbolt.org/z/c84cb3PW7
> >
> >
> > Oops, I meant __has_cpp_attribute, not __has_attribute. We mishandle
> that one just like GCC: https://godbolt.org/z/Ej84Kca16


Digging a bit more: https://godbolt.org/z/4Yo578b8n


[PATCH] D112030: [docs] Remove Makefile.sphinx files

2021-10-18 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

We don't use them in libc++, fine by me to remove if the website documentation 
builders don't use them (IDK how that's set up).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112030

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


[PATCH] D112030: [docs] Remove Makefile.sphinx files

2021-10-18 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
tstellar added reviewers: sylvestre.ledru, pcc, silvas.
tstellar requested review of this revision.
Herald added projects: clang, libc++, LLVM.
Herald added subscribers: libcxx-commits, cfe-commits.
Herald added a reviewer: libc++.

Does anyone still use these?  I want to make some changes to the sphinx
html generation and I don't want to have to implement the changes in
two places.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112030

Files:
  clang/docs/Makefile.sphinx
  libcxx/docs/Makefile.sphinx
  llvm/docs/Makefile.sphinx

Index: llvm/docs/Makefile.sphinx
===
--- llvm/docs/Makefile.sphinx
+++ /dev/null
@@ -1,155 +0,0 @@
-# Makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS=
-SPHINXBUILD   = sphinx-build
-PAPER =
-BUILDDIR  = _build
-
-# Internal variables.
-PAPEROPT_a4 = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-# the i18n builder cannot share the environment and doctrees with the others
-I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
-
-all:	html
-
-help:
-	@echo "Please use \`make ' where  is one of"
-	@echo "  html   to make standalone HTML files"
-	@echo "  dirhtmlto make HTML files named index.html in directories"
-	@echo "  singlehtml to make a single large HTML file"
-	@echo "  pickle to make pickle files"
-	@echo "  json   to make JSON files"
-	@echo "  htmlhelp   to make HTML files and a HTML help project"
-	@echo "  qthelp to make HTML files and a qthelp project"
-	@echo "  devhelpto make HTML files and a Devhelp project"
-	@echo "  epub   to make an epub"
-	@echo "  latex  to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
-	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
-	@echo "  text   to make text files"
-	@echo "  manto make manual pages"
-	@echo "  texinfoto make Texinfo files"
-	@echo "  info   to make Texinfo files and run them through makeinfo"
-	@echo "  gettextto make PO message catalogs"
-	@echo "  changesto make an overview of all changed/added/deprecated items"
-	@echo "  linkcheck  to check all external links for integrity"
-	@echo "  doctestto run all doctests embedded in the documentation (if enabled)"
-
-clean:
-	-rm -rf $(BUILDDIR)/*
-
-html:
-	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
-	@echo
-	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-
-dirhtml:
-	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
-	@echo
-	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
-
-singlehtml:
-	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
-	@echo
-	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
-
-pickle:
-	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
-	@echo
-	@echo "Build finished; now you can process the pickle files."
-
-json:
-	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
-	@echo
-	@echo "Build finished; now you can process the JSON files."
-
-htmlhelp:
-	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
-	@echo
-	@echo "Build finished; now you can run HTML Help Workshop with the" \
-	  ".hhp project file in $(BUILDDIR)/htmlhelp."
-
-qthelp:
-	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
-	@echo
-	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
-	  ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
-	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/llvm.qhcp"
-	@echo "To view the help file:"
-	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/llvm.qhc"
-
-devhelp:
-	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
-	@echo
-	@echo "Build finished."
-	@echo "To view the help file:"
-	@echo "# mkdir -p $$HOME/.local/share/devhelp/llvm"
-	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/llvm"
-	@echo "# devhelp"
-
-epub:
-	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
-	@echo
-	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-latex:
-	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-	@echo
-	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
-	@echo "Run \`make' in that directory to run these through (pdf)latex" \
-	  "(use \`make latexpdf' here to do that automatically)."
-
-latexpdf:
-	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-	@echo "Running LaTeX files through pdflatex..."
-	$(MAKE) -C $(BUILDDIR)/latex all-pdf
-	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-text:
-	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) 

Re: [clang] 2edb89c - Lex arguments for __has_cpp_attribute and friends as expanded tokens

2021-10-18 Thread Aaron Ballman via cfe-commits
On Mon, Oct 18, 2021 at 3:52 PM Richard Smith  wrote:
>
>  On Mon, 18 Oct 2021 at 12:48, Aaron Ballman  wrote:
>>
>> On Mon, Oct 18, 2021 at 3:33 PM Richard Smith  wrote:
>> >
>> > On Sun, 17 Oct 2021 at 04:58, Aaron Ballman via cfe-commits 
>> >  wrote:
>> >>
>> >>
>> >> Author: Aaron Ballman
>> >> Date: 2021-10-17T07:54:48-04:00
>> >> New Revision: 2edb89c746848c52964537268bf03e7906bf2542
>> >>
>> >> URL: 
>> >> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542
>> >> DIFF: 
>> >> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542.diff
>> >>
>> >> LOG: Lex arguments for __has_cpp_attribute and friends as expanded tokens
>> >>
>> >> The C and C++ standards require the argument to __has_cpp_attribute and
>> >> __has_c_attribute to be expanded ([cpp.cond]p5). It would make little 
>> >> sense
>> >> to expand the argument to those operators but not expand the argument to
>> >> __has_attribute and __has_declspec, so those were both also changed in 
>> >> this
>> >> patch.
>> >>
>> >> Note that it might make sense for the other builtins to also expand their
>> >> argument, but it wasn't as clear to me whether the behavior would be 
>> >> correct
>> >> there, and so they were left for a future revision.
>> >>
>> >> Added:
>> >> clang/test/Preprocessor/has_attribute_errors.cpp
>> >>
>> >> Modified:
>> >> clang/docs/ReleaseNotes.rst
>> >> clang/lib/Lex/PPMacroExpansion.cpp
>> >> clang/test/Preprocessor/has_attribute.c
>> >> clang/test/Preprocessor/has_attribute.cpp
>> >> clang/test/Preprocessor/has_c_attribute.c
>> >>
>> >> Removed:
>> >>
>> >>
>> >>
>> >> 
>> >> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
>> >> index 6501a4870e2a6..263eae83036df 100644
>> >> --- a/clang/docs/ReleaseNotes.rst
>> >> +++ b/clang/docs/ReleaseNotes.rst
>> >> @@ -110,6 +110,13 @@ Attribute Changes in Clang
>> >>attribute is handled instead, e.g. in ``handleDeclAttribute``.
>> >>(This was changed in order to better support attributes in code 
>> >> completion).
>> >>
>> >> +- __has_cpp_attribute, __has_c_attribute, __has_attribute, and 
>> >> __has_declspec
>> >> +  will now macro expand their argument. This causes a change in behavior 
>> >> for
>> >> +  code using ``__has_cpp_attribute(__clang__::attr)`` (and same for
>> >> +  ``__has_c_attribute``) where it would previously expand to ``0`` for 
>> >> all
>> >> +  attributes, but will now issue an error due to the expansion of the
>> >> +  predefined ``__clang__`` macro.
>> >> +
>> >>  Windows Support
>> >>  ---
>> >>
>> >>
>> >> diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
>> >> b/clang/lib/Lex/PPMacroExpansion.cpp
>> >> index bf19f538647e6..5a0fa5184e38b 100644
>> >> --- a/clang/lib/Lex/PPMacroExpansion.cpp
>> >> +++ b/clang/lib/Lex/PPMacroExpansion.cpp
>> >> @@ -1293,7 +1293,7 @@ static bool EvaluateHasIncludeNext(Token ,
>> >>  /// integer values.
>> >>  static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& 
>> >> OS,
>> >>  Token , IdentifierInfo 
>> >> *II,
>> >> -Preprocessor ,
>> >> +Preprocessor , bool 
>> >> ExpandArgs,
>> >>  llvm::function_ref<
>> >>int(Token ,
>> >>bool 
>> >> )> Op) {
>> >> @@ -1319,7 +1319,10 @@ static void 
>> >> EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
>> >>bool SuppressDiagnostic = false;
>> >>while (true) {
>> >>  // Parse next token.
>> >> -PP.LexUnexpandedToken(Tok);
>> >> +if (ExpandArgs)
>> >> +  PP.Lex(Tok);
>> >> +else
>> >> +  PP.LexUnexpandedToken(Tok);
>> >
>> >
>> > How does this handle things like:
>> >
>> > #define RPAREN )
>> > #if __has_attribute(clang::fallthrough RPAREN
>> >
>> > ? I think that should be an error: the ) token should not be produced by 
>> > macro expansion, analogous to the behavior of function-like macros. But I 
>> > imagine unless we're careful here, we'll allow that macro expansion to 
>> > terminate the "macro".
>>
>> I agree, I think that should be an error. We handle it reasonably too; I get:
>>
>> error: missing ')' after 'clang'
>>
>> though it appears there is some compiler divergence here:
>> https://godbolt.org/z/c84cb3PW7
>
>
> Oops, I meant __has_cpp_attribute, not __has_attribute. We mishandle that one 
> just like GCC: https://godbolt.org/z/Ej84Kca16

Well that's just neat. I was trying to avoid lexing an unexpanded
token and then expanding it later if it was an identifier, but it
sounds like I should be taking that approach here. (Is that even
possible to do?)

~Aaron
___
cfe-commits mailing 

[PATCH] D111529: Specify Clang vector builtins.

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



Comment at: clang/docs/LanguageExtensions.rst:557
+``i in [0, Number of elements / 2)``. If the numbers of elements is not a
+power of 2, the vector is widening with neutral elements for the reduction
+at the end to the next power of 2.

craig.topper wrote:
> widening -> widened
thanks, should be fixed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529

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


[PATCH] D111529: Specify Clang vector builtins.

2021-10-18 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 380500.
fhahn marked an inline comment as done.
fhahn added a comment.

Fix wording: widening -> widened, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -506,6 +506,82 @@
   If it's an extension (OpenCL) vector, it's only available in C and OpenCL C.
   And it selects base on signedness of the condition operands (OpenCL v1.1 
s6.3.9).
 
+Vector Builtins
+---
+
+**Note: The implementation of vector builtins is work-in-progress and 
incomplete.**
+
+In addition to the operators mentioned above, Clang provides a set of builtins
+to perform additional operations on certain scalar and vector types.
+
+Let ``T`` be one of the following types:
+
+* an integer type (as in C2x 6.2.5p19), but excluding enumerated types and 
_Bool
+* the standard floating types float or double
+* a half-precision floating point type, if one is supported on the target
+* a vector type.
+
+For scalar types, consider the operation applied to a vector with a single 
element.
+
+*Elementwise Builtins*
+
+Each builtin returns a vector equivalent to applying the specified operation
+elementwise to the input.
+
+Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = 
±infinity
+
+= 
 
=
+ Name  Operation   
 Supported element types
+= 
 
=
+ T __builtin_elementwise_abs(T x)  return the absolute value of a 
number x   signed integer and floating point types
+ T __builtin_elementwise_ceil(T x) return the smallest integral value 
greater than or equal to x floating point types
+ T __builtin_elementwise_floor(T x)return the largest integral value 
less than or equal to x floating point types
+ T __builtin_elementwise_roundeven(T x)round x to the nearest integer 
value in floating point format,floating point types
+   rounding halfway cases to even 
(that is, to the nearest value
+   that is an even integer), 
regardless of the current rounding
+   direction.
+ T__builtin_elementwise_trunc(T x) return the integral value nearest 
to but no larger in floating point types
+   magnitude than x
+ T __builtin_elementwise_max(T x, T y) return x or y, whichever is larger  
  integer and floating point types
+ T __builtin_elementwise_min(T x, T y) return x or y, whichever is smaller 
  integer and floating point types
+= 
 
=
+
+
+*Reduction Builtins*
+
+Each builtin returns a scalar equivalent to applying the specified
+operation(x, y) as recursive even-odd pairwise reduction to all vector
+elements. ``operation(x, y)`` is repeatedly applied to each non-overlapping
+even-odd element pair with indices ``i * 2`` and ``i * 2 + 1`` with
+``i in [0, Number of elements / 2)``. If the numbers of elements is not a
+power of 2, the vector is widened with neutral elements for the reduction
+at the end to the next power of 2.
+
+Example:
+
+.. code-block:: c++
+
+__builtin_reduce_fadd([e3, e2, e1, e0]) = __builtin_reduced_fadd([e3 + e2, 
e1 + e0])
+= (e3 + e2) + (e1 + e0)
+
+
+Let ``VT`` be a vector type and ``ET`` the element type of ``VT``.
+
+=== 
 
==
+ NameOperation 
   Supported element types
+=== 
 
==
+ ET __builtin_reduce_max(VT a)   return x or y, whichever is larger; 
If exactly one argument is   integer and floating point types
+ a NaN, return the other argument. If 
both arguments are NaNs,
+ fmax() return a NaN.
+ ET __builtin_reduce_min(VT a)   return x 

Re: [clang] 2edb89c - Lex arguments for __has_cpp_attribute and friends as expanded tokens

2021-10-18 Thread Richard Smith via cfe-commits
 On Mon, 18 Oct 2021 at 12:48, Aaron Ballman  wrote:

> On Mon, Oct 18, 2021 at 3:33 PM Richard Smith 
> wrote:
> >
> > On Sun, 17 Oct 2021 at 04:58, Aaron Ballman via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >>
> >> Author: Aaron Ballman
> >> Date: 2021-10-17T07:54:48-04:00
> >> New Revision: 2edb89c746848c52964537268bf03e7906bf2542
> >>
> >> URL:
> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542
> >> DIFF:
> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542.diff
> >>
> >> LOG: Lex arguments for __has_cpp_attribute and friends as expanded
> tokens
> >>
> >> The C and C++ standards require the argument to __has_cpp_attribute and
> >> __has_c_attribute to be expanded ([cpp.cond]p5). It would make little
> sense
> >> to expand the argument to those operators but not expand the argument to
> >> __has_attribute and __has_declspec, so those were both also changed in
> this
> >> patch.
> >>
> >> Note that it might make sense for the other builtins to also expand
> their
> >> argument, but it wasn't as clear to me whether the behavior would be
> correct
> >> there, and so they were left for a future revision.
> >>
> >> Added:
> >> clang/test/Preprocessor/has_attribute_errors.cpp
> >>
> >> Modified:
> >> clang/docs/ReleaseNotes.rst
> >> clang/lib/Lex/PPMacroExpansion.cpp
> >> clang/test/Preprocessor/has_attribute.c
> >> clang/test/Preprocessor/has_attribute.cpp
> >> clang/test/Preprocessor/has_c_attribute.c
> >>
> >> Removed:
> >>
> >>
> >>
> >>
> 
> >> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> >> index 6501a4870e2a6..263eae83036df 100644
> >> --- a/clang/docs/ReleaseNotes.rst
> >> +++ b/clang/docs/ReleaseNotes.rst
> >> @@ -110,6 +110,13 @@ Attribute Changes in Clang
> >>attribute is handled instead, e.g. in ``handleDeclAttribute``.
> >>(This was changed in order to better support attributes in code
> completion).
> >>
> >> +- __has_cpp_attribute, __has_c_attribute, __has_attribute, and
> __has_declspec
> >> +  will now macro expand their argument. This causes a change in
> behavior for
> >> +  code using ``__has_cpp_attribute(__clang__::attr)`` (and same for
> >> +  ``__has_c_attribute``) where it would previously expand to ``0`` for
> all
> >> +  attributes, but will now issue an error due to the expansion of the
> >> +  predefined ``__clang__`` macro.
> >> +
> >>  Windows Support
> >>  ---
> >>
> >>
> >> diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp
> b/clang/lib/Lex/PPMacroExpansion.cpp
> >> index bf19f538647e6..5a0fa5184e38b 100644
> >> --- a/clang/lib/Lex/PPMacroExpansion.cpp
> >> +++ b/clang/lib/Lex/PPMacroExpansion.cpp
> >> @@ -1293,7 +1293,7 @@ static bool EvaluateHasIncludeNext(Token ,
> >>  /// integer values.
> >>  static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream&
> OS,
> >>  Token , IdentifierInfo
> *II,
> >> -Preprocessor ,
> >> +Preprocessor , bool
> ExpandArgs,
> >>  llvm::function_ref<
> >>int(Token ,
> >>bool
> )> Op) {
> >> @@ -1319,7 +1319,10 @@ static void
> EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
> >>bool SuppressDiagnostic = false;
> >>while (true) {
> >>  // Parse next token.
> >> -PP.LexUnexpandedToken(Tok);
> >> +if (ExpandArgs)
> >> +  PP.Lex(Tok);
> >> +else
> >> +  PP.LexUnexpandedToken(Tok);
> >
> >
> > How does this handle things like:
> >
> > #define RPAREN )
> > #if __has_attribute(clang::fallthrough RPAREN
> >
> > ? I think that should be an error: the ) token should not be produced by
> macro expansion, analogous to the behavior of function-like macros. But I
> imagine unless we're careful here, we'll allow that macro expansion to
> terminate the "macro".
>
> I agree, I think that should be an error. We handle it reasonably too; I
> get:
>
> error: missing ')' after 'clang'
>
> though it appears there is some compiler divergence here:
> https://godbolt.org/z/c84cb3PW7


Oops, I meant __has_cpp_attribute, not __has_attribute. We mishandle that
one just like GCC: https://godbolt.org/z/Ej84Kca16
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-18 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Two options come to mind if we really need to be outputting a StringRef:

1. (the simpler option) Pass in a Twine -> `const char *` lambda that the 
caller hooks up to Args.MakeArgString
2. (probably the nicer option) Invent our own MakeArgString that allocates from 
storage owned by RISCVISAInfo itself; lots of ways you can do that

Adding a new library just so we can use MakeArgString seems overkill, even if 
there are other things that perhaps belong in something a bit less shared than 
Support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


Re: [clang] 2edb89c - Lex arguments for __has_cpp_attribute and friends as expanded tokens

2021-10-18 Thread Aaron Ballman via cfe-commits
On Mon, Oct 18, 2021 at 3:33 PM Richard Smith  wrote:
>
> On Sun, 17 Oct 2021 at 04:58, Aaron Ballman via cfe-commits 
>  wrote:
>>
>>
>> Author: Aaron Ballman
>> Date: 2021-10-17T07:54:48-04:00
>> New Revision: 2edb89c746848c52964537268bf03e7906bf2542
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542.diff
>>
>> LOG: Lex arguments for __has_cpp_attribute and friends as expanded tokens
>>
>> The C and C++ standards require the argument to __has_cpp_attribute and
>> __has_c_attribute to be expanded ([cpp.cond]p5). It would make little sense
>> to expand the argument to those operators but not expand the argument to
>> __has_attribute and __has_declspec, so those were both also changed in this
>> patch.
>>
>> Note that it might make sense for the other builtins to also expand their
>> argument, but it wasn't as clear to me whether the behavior would be correct
>> there, and so they were left for a future revision.
>>
>> Added:
>> clang/test/Preprocessor/has_attribute_errors.cpp
>>
>> Modified:
>> clang/docs/ReleaseNotes.rst
>> clang/lib/Lex/PPMacroExpansion.cpp
>> clang/test/Preprocessor/has_attribute.c
>> clang/test/Preprocessor/has_attribute.cpp
>> clang/test/Preprocessor/has_c_attribute.c
>>
>> Removed:
>>
>>
>>
>> 
>> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
>> index 6501a4870e2a6..263eae83036df 100644
>> --- a/clang/docs/ReleaseNotes.rst
>> +++ b/clang/docs/ReleaseNotes.rst
>> @@ -110,6 +110,13 @@ Attribute Changes in Clang
>>attribute is handled instead, e.g. in ``handleDeclAttribute``.
>>(This was changed in order to better support attributes in code 
>> completion).
>>
>> +- __has_cpp_attribute, __has_c_attribute, __has_attribute, and 
>> __has_declspec
>> +  will now macro expand their argument. This causes a change in behavior for
>> +  code using ``__has_cpp_attribute(__clang__::attr)`` (and same for
>> +  ``__has_c_attribute``) where it would previously expand to ``0`` for all
>> +  attributes, but will now issue an error due to the expansion of the
>> +  predefined ``__clang__`` macro.
>> +
>>  Windows Support
>>  ---
>>
>>
>> diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
>> b/clang/lib/Lex/PPMacroExpansion.cpp
>> index bf19f538647e6..5a0fa5184e38b 100644
>> --- a/clang/lib/Lex/PPMacroExpansion.cpp
>> +++ b/clang/lib/Lex/PPMacroExpansion.cpp
>> @@ -1293,7 +1293,7 @@ static bool EvaluateHasIncludeNext(Token ,
>>  /// integer values.
>>  static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
>>  Token , IdentifierInfo *II,
>> -Preprocessor ,
>> +Preprocessor , bool 
>> ExpandArgs,
>>  llvm::function_ref<
>>int(Token ,
>>bool )> 
>> Op) {
>> @@ -1319,7 +1319,10 @@ static void 
>> EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
>>bool SuppressDiagnostic = false;
>>while (true) {
>>  // Parse next token.
>> -PP.LexUnexpandedToken(Tok);
>> +if (ExpandArgs)
>> +  PP.Lex(Tok);
>> +else
>> +  PP.LexUnexpandedToken(Tok);
>
>
> How does this handle things like:
>
> #define RPAREN )
> #if __has_attribute(clang::fallthrough RPAREN
>
> ? I think that should be an error: the ) token should not be produced by 
> macro expansion, analogous to the behavior of function-like macros. But I 
> imagine unless we're careful here, we'll allow that macro expansion to 
> terminate the "macro".

I agree, I think that should be an error. We handle it reasonably too; I get:

error: missing ')' after 'clang'

though it appears there is some compiler divergence here:
https://godbolt.org/z/c84cb3PW7

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


[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-18 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

In D105168#3071152 , @craig.topper 
wrote:

> In D105168#3069499 , @teemperor 
> wrote:
>
>> This broke the modules build:
>>
>>   While building module 'LLVM_Utils' imported from 
>> lvm/lib/Support/TargetParser.cpp:14:
>>   In file included from :209:
>>   llvm/include/llvm/Support/RISCVISAInfo.h:15:10: fatal error: could not 
>> build module 'LLVM_Option'
>>   #include "llvm/Option/ArgList.h"
>>^~~
>>   llvm/lib/Support/TargetParser.cpp:14:10: fatal error: could not build 
>> module 'LLVM_Utils'
>>   #include "llvm/Support/TargetParser.h"
>>^
>>
>> `Support` headers can't include `Option` headers (as `Option` depends on 
>> `Support` already, so that would be a cyclic dependency). I believe folks 
>> here are in the US time zone, so I went ahead and replaced the header 
>> include with a forward decl to unbreak the bots (see 
>> de4d2f80b75e2a1e4b0ac5c25e20f20839633688 
>>  )
>>
>> FWIW, I think there is a better place than `Support` for this new class. 
>> `Support` is a dependency of nearly every single LLVM component, but this 
>> class seems to be used by a handful of files. Could we maybe move this to 
>> some other/new part of LLVM (and make the few components that need it depend 
>> on that)?
>
> Thanks for the header fix. I think we also need to fix the library circular 
> dependency that still exists. The Support library should not use anything 
> from the Option library. Maybe we can partition the function some way that 
> moves the MakeArgStr back into the clang driver code.
>
> I don't know if we have a better library for this new class. I think Support 
> is the only common library between the clang driver and LLVM's MC layer. I 
> supposed we could create a new library, but that might be a hard sell for one 
> file.

IIRC there are some other target-specific classes in Support for the same 
reason. Maybe we can make something such as `TargetSupport` or `SharedTarget`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[PATCH] D111371: [Support][ThinLTO] Move ThinLTO caching to LLVM Support library.

2021-10-18 Thread Noah Shutty via Phabricator via cfe-commits
noajshu updated this revision to Diff 380498.
noajshu added a comment.

Update references to LTO/Caching in Gold plugin and Clang docs; rebase against 
main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111371

Files:
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/LTO.cpp
  lld/ELF/LTO.cpp
  lld/MachO/LTO.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/Caching.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/Support/Caching.h
  llvm/lib/LTO/CMakeLists.txt
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Caching.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -19,10 +19,10 @@
 #include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -362,14 +362,13 @@
   if (HasErrors)
 return 1;
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 std::string Path = OutputFilename + "." + utostr(Task);
 
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S));
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
@@ -378,7 +377,8 @@
 
   NativeObjectCache Cache;
   if (!CacheDir.empty())
-Cache = check(localCache(CacheDir, AddBuffer), "failed to create cache");
+Cache = check(localCache("ThinLTO", "Thin", CacheDir, AddBuffer),
+  "failed to create cache");
 
   check(Lto.run(AddStream, Cache), "LTO::run failed");
   return 0;
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1097,8 +1097,7 @@
 error("writing merged module failed.");
 }
 
-auto AddStream =
-[&](size_t Task) -> std::unique_ptr {
+auto AddStream = [&](size_t Task) -> std::unique_ptr {
   std::string PartFilename = OutputFilename;
   if (Parallelism != 1)
 PartFilename += "." + utostr(Task);
@@ -1108,7 +1107,7 @@
   std::make_unique(PartFilename, EC, sys::fs::OF_None);
   if (EC)
 error("error opening the file '" + PartFilename + "': " + EC.message());
-  return std::make_unique(std::move(S));
+  return std::make_unique(std::move(S));
 };
 
 if (!CodeGen.compileOptimized(AddStream, Parallelism))
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -19,11 +19,11 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/Error.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
 #include "llvm/Support/CachePruning.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
@@ -1081,12 +1081,11 @@
   size_t MaxTasks = Lto->getMaxTasks();
   std::vector, bool>> Files(MaxTasks);
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 Files[Task].second = !SaveTemps;
 int FD = getOutputFileName(Filename, /* TempOutFile */ !SaveTemps,
Files[Task].first, Task);
-return std::make_unique(
+return std::make_unique(
 std::make_unique(FD, true));
   };
 
@@ -1096,7 +1095,7 @@
 
   NativeObjectCache Cache;
   if (!options::cache_dir.empty())
-Cache = check(localCache(options::cache_dir, AddBuffer));
+Cache = check(localCache("ThinLTO", "Thin", options::cache_dir, AddBuffer));
 
   check(Lto->run(AddStream, Cache));
 
Index: llvm/lib/Support/Caching.cpp
===
--- llvm/lib/Support/Caching.cpp
+++ llvm/lib/Support/Caching.cpp
@@ -1,4 +1,4 @@
-//===-Caching.cpp - LLVM Link Time Optimizer Cache Handling ---===//
+//===-Caching.cpp - LLVM File Cache Handling --===//
 //
 // Part of the LLVM 

Re: [clang] 2edb89c - Lex arguments for __has_cpp_attribute and friends as expanded tokens

2021-10-18 Thread Richard Smith via cfe-commits
On Sun, 17 Oct 2021 at 04:58, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Aaron Ballman
> Date: 2021-10-17T07:54:48-04:00
> New Revision: 2edb89c746848c52964537268bf03e7906bf2542
>
> URL:
> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542
> DIFF:
> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542.diff
>
> LOG: Lex arguments for __has_cpp_attribute and friends as expanded tokens
>
> The C and C++ standards require the argument to __has_cpp_attribute and
> __has_c_attribute to be expanded ([cpp.cond]p5). It would make little sense
> to expand the argument to those operators but not expand the argument to
> __has_attribute and __has_declspec, so those were both also changed in this
> patch.
>
> Note that it might make sense for the other builtins to also expand their
> argument, but it wasn't as clear to me whether the behavior would be
> correct
> there, and so they were left for a future revision.
>
> Added:
> clang/test/Preprocessor/has_attribute_errors.cpp
>
> Modified:
> clang/docs/ReleaseNotes.rst
> clang/lib/Lex/PPMacroExpansion.cpp
> clang/test/Preprocessor/has_attribute.c
> clang/test/Preprocessor/has_attribute.cpp
> clang/test/Preprocessor/has_c_attribute.c
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> index 6501a4870e2a6..263eae83036df 100644
> --- a/clang/docs/ReleaseNotes.rst
> +++ b/clang/docs/ReleaseNotes.rst
> @@ -110,6 +110,13 @@ Attribute Changes in Clang
>attribute is handled instead, e.g. in ``handleDeclAttribute``.
>(This was changed in order to better support attributes in code
> completion).
>
> +- __has_cpp_attribute, __has_c_attribute, __has_attribute, and
> __has_declspec
> +  will now macro expand their argument. This causes a change in behavior
> for
> +  code using ``__has_cpp_attribute(__clang__::attr)`` (and same for
> +  ``__has_c_attribute``) where it would previously expand to ``0`` for all
> +  attributes, but will now issue an error due to the expansion of the
> +  predefined ``__clang__`` macro.
> +
>  Windows Support
>  ---
>
>
> diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp
> b/clang/lib/Lex/PPMacroExpansion.cpp
> index bf19f538647e6..5a0fa5184e38b 100644
> --- a/clang/lib/Lex/PPMacroExpansion.cpp
> +++ b/clang/lib/Lex/PPMacroExpansion.cpp
> @@ -1293,7 +1293,7 @@ static bool EvaluateHasIncludeNext(Token ,
>  /// integer values.
>  static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
>  Token , IdentifierInfo
> *II,
> -Preprocessor ,
> +Preprocessor , bool
> ExpandArgs,
>  llvm::function_ref<
>int(Token ,
>bool )>
> Op) {
> @@ -1319,7 +1319,10 @@ static void
> EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
>bool SuppressDiagnostic = false;
>while (true) {
>  // Parse next token.
> -PP.LexUnexpandedToken(Tok);
> +if (ExpandArgs)
> +  PP.Lex(Tok);
> +else
> +  PP.LexUnexpandedToken(Tok);
>

How does this handle things like:

#define RPAREN )
#if __has_attribute(clang::fallthrough RPAREN

? I think that should be an error: the ) token should not be produced by
macro expansion, analogous to the behavior of function-like macros. But I
imagine unless we're careful here, we'll allow that macro expansion to
terminate the "macro".

 already_lexed:
>  switch (Tok.getKind()) {
> @@ -1609,21 +1612,21 @@ void Preprocessor::ExpandBuiltinMacro(Token ) {
>  OS << CounterValue++;
>  Tok.setKind(tok::numeric_constant);
>} else if (II == Ident__has_feature) {
> -EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this,
> +EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
>[this](Token , bool ) -> int {
>  IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
>
> diag::err_feature_check_malformed);
>  return II && HasFeature(*this, II->getName());
>});
>} else if (II == Ident__has_extension) {
> -EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this,
> +EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
>[this](Token , bool ) -> int {
>  IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
>
> diag::err_feature_check_malformed);
>  return II && HasExtension(*this, II->getName());
>});
>} else if (II == Ident__has_builtin) {
> -EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this,
> +EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
>[this](Token , bool ) -> int {
>  IdentifierInfo *II = 

[PATCH] D112028: [RISCV] Remove the HasSideEffects property from riscv_vector.td

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: HsiangKai, kito-cheng, arcbbb, khchen.
Herald added subscribers: achieveartificialintelligence, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.

It was being used to control the nothrow attribute on the builtins. The
nothrow attribute is for C++ exceptions. Even if the vector builtins
have side effects in IR, that's different than the nothrow attribute.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112028

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -153,7 +153,6 @@
   std::string Name; // Builtin name
   std::string MangledName;
   std::string IRName;
-  bool HasSideEffects;
   bool IsMask;
   bool HasMaskedOffOperand;
   bool HasVL;
@@ -171,9 +170,9 @@
 
 public:
   RVVIntrinsic(StringRef Name, StringRef Suffix, StringRef MangledName,
-   StringRef MangledSuffix, StringRef IRName, bool HasSideEffects,
-   bool IsMask, bool HasMaskedOffOperand, bool HasVL,
-   bool HasPolicy, bool HasNoMaskedOverloaded, bool HasAutoDef,
+   StringRef MangledSuffix, StringRef IRName, bool IsMask,
+   bool HasMaskedOffOperand, bool HasVL, bool HasPolicy,
+   bool HasNoMaskedOverloaded, bool HasAutoDef,
StringRef ManualCodegen, const RVVTypes ,
const std::vector ,
StringRef RequiredExtension, unsigned NF);
@@ -181,7 +180,6 @@
 
   StringRef getName() const { return Name; }
   StringRef getMangledName() const { return MangledName; }
-  bool hasSideEffects() const { return HasSideEffects; }
   bool hasMaskedOffOperand() const { return HasMaskedOffOperand; }
   bool hasVL() const { return HasVL; }
   bool hasPolicy() const { return HasPolicy; }
@@ -759,16 +757,16 @@
 //===--===//
 RVVIntrinsic::RVVIntrinsic(StringRef NewName, StringRef Suffix,
StringRef NewMangledName, StringRef MangledSuffix,
-   StringRef IRName, bool HasSideEffects, bool IsMask,
+   StringRef IRName, bool IsMask,
bool HasMaskedOffOperand, bool HasVL, bool HasPolicy,
bool HasNoMaskedOverloaded, bool HasAutoDef,
StringRef ManualCodegen, const RVVTypes ,
const std::vector ,
StringRef RequiredExtension, unsigned NF)
-: IRName(IRName), HasSideEffects(HasSideEffects), IsMask(IsMask),
-  HasMaskedOffOperand(HasMaskedOffOperand), HasVL(HasVL),
-  HasPolicy(HasPolicy), HasNoMaskedOverloaded(HasNoMaskedOverloaded),
-  HasAutoDef(HasAutoDef), ManualCodegen(ManualCodegen.str()), NF(NF) {
+: IRName(IRName), IsMask(IsMask), HasMaskedOffOperand(HasMaskedOffOperand),
+  HasVL(HasVL), HasPolicy(HasPolicy),
+  HasNoMaskedOverloaded(HasNoMaskedOverloaded), HasAutoDef(HasAutoDef),
+  ManualCodegen(ManualCodegen.str()), NF(NF) {
 
   // Init Name and MangledName
   Name = NewName.str();
@@ -1024,11 +1022,7 @@
   OS << "#endif\n";
   for (auto  : Defs) {
 OS << "RISCVV_BUILTIN(__builtin_rvv_" << Def->getName() << ",\""
-   << Def->getBuiltinTypeStr() << "\", ";
-if (!Def->hasSideEffects())
-  OS << "\"n\")\n";
-else
-  OS << "\"\")\n";
+   << Def->getBuiltinTypeStr() << "\", \"n\")\n";
   }
   OS << "#undef RISCVV_BUILTIN\n";
 }
@@ -1099,7 +1093,6 @@
 bool HasVL = R->getValueAsBit("HasVL");
 bool HasPolicy = R->getValueAsBit("HasPolicy");
 bool HasNoMaskedOverloaded = R->getValueAsBit("HasNoMaskedOverloaded");
-bool HasSideEffects = R->getValueAsBit("HasSideEffects");
 std::vector Log2LMULList = R->getValueAsListOfInts("Log2LMUL");
 StringRef ManualCodegen = R->getValueAsString("ManualCodegen");
 StringRef ManualCodegenMask = R->getValueAsString("ManualCodegenMask");
@@ -1171,17 +1164,17 @@
 // Create a non-mask intrinsic
 Out.push_back(std::make_unique(
 Name, SuffixStr, MangledName, MangledSuffixStr, IRName,
-HasSideEffects, /*IsMask=*/false, /*HasMaskedOffOperand=*/false,
-HasVL, HasPolicy, HasNoMaskedOverloaded, HasAutoDef, ManualCodegen,
-Types.getValue(), IntrinsicTypes, RequiredExtension, NF));
+/*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL, 

[clang] 8e46e34 - Revert "[Support][ThinLTO] Move ThinLTO caching to LLVM Support library"

2021-10-18 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-10-18T12:24:05-07:00
New Revision: 8e46e34d243524b9a1f9487718ea60e990b35fa3

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

LOG: Revert "[Support][ThinLTO] Move ThinLTO caching to LLVM Support library"

This reverts commit 92b8cc52bbc8194f2cd6a5f742b874969421afca since
it broke the gold plugin.

Added: 
llvm/include/llvm/LTO/Caching.h
llvm/lib/LTO/Caching.cpp

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
lld/COFF/LTO.cpp
lld/ELF/LTO.cpp
lld/MachO/LTO.cpp
lld/wasm/LTO.cpp
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
llvm/lib/LTO/CMakeLists.txt
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/lib/Support/CMakeLists.txt
llvm/tools/gold/gold-plugin.cpp
llvm/tools/llvm-lto/llvm-lto.cpp
llvm/tools/llvm-lto2/llvm-lto2.cpp

Removed: 
llvm/include/llvm/Support/Caching.h
llvm/lib/Support/Caching.cpp



diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index ff76ef1d9dd88..986c9e8104e9d 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1561,7 +1561,7 @@ static void runThinLTOBackend(
 return;
 
   auto AddStream = [&](size_t Task) {
-return std::make_unique(std::move(OS));
+return std::make_unique(std::move(OS));
   };
   lto::Config Conf;
   if (CGOpts.SaveTempsFilePrefix != "") {

diff  --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp
index 505360663f4f9..ce9c4fd0d51b2 100644
--- a/lld/COFF/LTO.cpp
+++ b/lld/COFF/LTO.cpp
@@ -20,10 +20,10 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/Config.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/SymbolicFile.h"
-#include "llvm/Support/Caching.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
@@ -164,17 +164,16 @@ std::vector 
BitcodeCompiler::compile(COFFLinkerContext ) {
   // The /lldltocache option specifies the path to a directory in which to 
cache
   // native object files for ThinLTO incremental builds. If a path was
   // specified, configure LTO to use it as the cache directory.
-  NativeObjectCache cache;
+  lto::NativeObjectCache cache;
   if (!config->ltoCache.empty())
-cache =
-check(localCache("ThinLTO", "Thin", config->ltoCache,
- [&](size_t task, std::unique_ptr mb) {
-   files[task] = std::move(mb);
- }));
+cache = check(lto::localCache(
+config->ltoCache, [&](size_t task, std::unique_ptr mb) {
+  files[task] = std::move(mb);
+}));
 
   checkError(ltoObj->run(
   [&](size_t task) {
-return std::make_unique(
+return std::make_unique(
 std::make_unique(buf[task]));
   },
   cache));

diff  --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index 5f206fc97b3ca..fb354f81d49d6 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -23,10 +23,10 @@
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/Config.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/SymbolicFile.h"
-#include "llvm/Support/Caching.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
@@ -304,18 +304,18 @@ std::vector BitcodeCompiler::compile() {
   // The --thinlto-cache-dir option specifies the path to a directory in which
   // to cache native object files for ThinLTO incremental builds. If a path was
   // specified, configure LTO to use it as the cache directory.
-  NativeObjectCache cache;
+  lto::NativeObjectCache cache;
   if (!config->thinLTOCacheDir.empty())
-cache =
-check(localCache("ThinLTO", "Thin", config->thinLTOCacheDir,
- [&](size_t task, std::unique_ptr mb) {
-   files[task] = std::move(mb);
- }));
+cache = check(
+lto::localCache(config->thinLTOCacheDir,
+[&](size_t task, std::unique_ptr mb) {
+  files[task] = std::move(mb);
+}));
 
   if (!bitcodeFiles.empty())
 checkError(ltoObj->run(
 [&](size_t task) {
-  return std::make_unique(
+  return std::make_unique(
   std::make_unique(buf[task]));
 },
 cache));

diff  --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index d1eef6a6f8f82..09b05ed0dffee 100644
--- a/lld/MachO/LTO.cpp
+++ b/lld/MachO/LTO.cpp
@@ -17,9 +17,9 @@
 #include "lld/Common/ErrorHandler.h"
 #include "lld/Common/Strings.h"
 

[PATCH] D111009: Update inline builtin handling to honor gnu inline attribute

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

See also: https://github.com/ClangBuiltLinux/linux/issues/1477.  Surprising 
that this didn't show up in newer kernels, just older (but still supported) 
kernel versions. Sorry I missed that in my tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111009

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


[clang] 92b8cc5 - [Support][ThinLTO] Move ThinLTO caching to LLVM Support library

2021-10-18 Thread Petr Hosek via cfe-commits

Author: Noah Shutty
Date: 2021-10-18T12:08:49-07:00
New Revision: 92b8cc52bbc8194f2cd6a5f742b874969421afca

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

LOG: [Support][ThinLTO] Move ThinLTO caching to LLVM Support library

We would like to move ThinLTO’s battle-tested file caching mechanism to
the LLVM Support library so that we can use it elsewhere in LLVM.

Patch By: noajshu

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

Added: 
llvm/include/llvm/Support/Caching.h
llvm/lib/Support/Caching.cpp

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
lld/COFF/LTO.cpp
lld/ELF/LTO.cpp
lld/MachO/LTO.cpp
lld/wasm/LTO.cpp
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
llvm/lib/LTO/CMakeLists.txt
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/lib/Support/CMakeLists.txt
llvm/tools/gold/gold-plugin.cpp
llvm/tools/llvm-lto/llvm-lto.cpp
llvm/tools/llvm-lto2/llvm-lto2.cpp

Removed: 
llvm/include/llvm/LTO/Caching.h
llvm/lib/LTO/Caching.cpp



diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 986c9e8104e9d..ff76ef1d9dd88 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1561,7 +1561,7 @@ static void runThinLTOBackend(
 return;
 
   auto AddStream = [&](size_t Task) {
-return std::make_unique(std::move(OS));
+return std::make_unique(std::move(OS));
   };
   lto::Config Conf;
   if (CGOpts.SaveTempsFilePrefix != "") {

diff  --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp
index ce9c4fd0d51b2..505360663f4f9 100644
--- a/lld/COFF/LTO.cpp
+++ b/lld/COFF/LTO.cpp
@@ -20,10 +20,10 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/Config.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/SymbolicFile.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
@@ -164,16 +164,17 @@ std::vector 
BitcodeCompiler::compile(COFFLinkerContext ) {
   // The /lldltocache option specifies the path to a directory in which to 
cache
   // native object files for ThinLTO incremental builds. If a path was
   // specified, configure LTO to use it as the cache directory.
-  lto::NativeObjectCache cache;
+  NativeObjectCache cache;
   if (!config->ltoCache.empty())
-cache = check(lto::localCache(
-config->ltoCache, [&](size_t task, std::unique_ptr mb) {
-  files[task] = std::move(mb);
-}));
+cache =
+check(localCache("ThinLTO", "Thin", config->ltoCache,
+ [&](size_t task, std::unique_ptr mb) {
+   files[task] = std::move(mb);
+ }));
 
   checkError(ltoObj->run(
   [&](size_t task) {
-return std::make_unique(
+return std::make_unique(
 std::make_unique(buf[task]));
   },
   cache));

diff  --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index fb354f81d49d6..5f206fc97b3ca 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -23,10 +23,10 @@
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/Config.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/SymbolicFile.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
@@ -304,18 +304,18 @@ std::vector BitcodeCompiler::compile() {
   // The --thinlto-cache-dir option specifies the path to a directory in which
   // to cache native object files for ThinLTO incremental builds. If a path was
   // specified, configure LTO to use it as the cache directory.
-  lto::NativeObjectCache cache;
+  NativeObjectCache cache;
   if (!config->thinLTOCacheDir.empty())
-cache = check(
-lto::localCache(config->thinLTOCacheDir,
-[&](size_t task, std::unique_ptr mb) {
-  files[task] = std::move(mb);
-}));
+cache =
+check(localCache("ThinLTO", "Thin", config->thinLTOCacheDir,
+ [&](size_t task, std::unique_ptr mb) {
+   files[task] = std::move(mb);
+ }));
 
   if (!bitcodeFiles.empty())
 checkError(ltoObj->run(
 [&](size_t task) {
-  return std::make_unique(
+  return std::make_unique(
   std::make_unique(buf[task]));
 },
 cache));

diff  --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index 09b05ed0dffee..d1eef6a6f8f82 100644
--- a/lld/MachO/LTO.cpp
+++ 

[PATCH] D111371: [Support][ThinLTO] Move ThinLTO caching to LLVM Support library.

2021-10-18 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92b8cc52bbc8: [Support][ThinLTO] Move ThinLTO caching to 
LLVM Support library (authored by noajshu, committed by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111371

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/LTO.cpp
  lld/ELF/LTO.cpp
  lld/MachO/LTO.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/Caching.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/Support/Caching.h
  llvm/lib/LTO/CMakeLists.txt
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Caching.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -19,10 +19,10 @@
 #include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -362,14 +362,13 @@
   if (HasErrors)
 return 1;
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 std::string Path = OutputFilename + "." + utostr(Task);
 
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S));
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
@@ -378,7 +377,8 @@
 
   NativeObjectCache Cache;
   if (!CacheDir.empty())
-Cache = check(localCache(CacheDir, AddBuffer), "failed to create cache");
+Cache = check(localCache("ThinLTO", "Thin", CacheDir, AddBuffer),
+  "failed to create cache");
 
   check(Lto.run(AddStream, Cache), "LTO::run failed");
   return 0;
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1097,8 +1097,7 @@
 error("writing merged module failed.");
 }
 
-auto AddStream =
-[&](size_t Task) -> std::unique_ptr {
+auto AddStream = [&](size_t Task) -> std::unique_ptr {
   std::string PartFilename = OutputFilename;
   if (Parallelism != 1)
 PartFilename += "." + utostr(Task);
@@ -1108,7 +1107,7 @@
   std::make_unique(PartFilename, EC, sys::fs::OF_None);
   if (EC)
 error("error opening the file '" + PartFilename + "': " + EC.message());
-  return std::make_unique(std::move(S));
+  return std::make_unique(std::move(S));
 };
 
 if (!CodeGen.compileOptimized(AddStream, Parallelism))
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -1081,12 +1081,11 @@
   size_t MaxTasks = Lto->getMaxTasks();
   std::vector, bool>> Files(MaxTasks);
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 Files[Task].second = !SaveTemps;
 int FD = getOutputFileName(Filename, /* TempOutFile */ !SaveTemps,
Files[Task].first, Task);
-return std::make_unique(
+return std::make_unique(
 std::make_unique(FD, true));
   };
 
@@ -1096,7 +1095,7 @@
 
   NativeObjectCache Cache;
   if (!options::cache_dir.empty())
-Cache = check(localCache(options::cache_dir, AddBuffer));
+Cache = check(localCache("ThinLTO", "Thin", options::cache_dir, AddBuffer));
 
   check(Lto->run(AddStream, Cache));
 
Index: llvm/lib/Support/Caching.cpp
===
--- llvm/lib/Support/Caching.cpp
+++ llvm/lib/Support/Caching.cpp
@@ -1,4 +1,4 @@
-//===-Caching.cpp - LLVM Link Time Optimizer Cache Handling ---===//
+//===-Caching.cpp - LLVM File Cache Handling --===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,11 +6,11 @@
 //
 //===--===//
 //
-// This file implements the Caching for ThinLTO.
+// This file implements the Caching used by ThinLTO.
 //
 //===--===//
 
-#include 

[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D105168#3069499 , @teemperor wrote:

> This broke the modules build:
>
>   While building module 'LLVM_Utils' imported from 
> lvm/lib/Support/TargetParser.cpp:14:
>   In file included from :209:
>   llvm/include/llvm/Support/RISCVISAInfo.h:15:10: fatal error: could not 
> build module 'LLVM_Option'
>   #include "llvm/Option/ArgList.h"
>^~~
>   llvm/lib/Support/TargetParser.cpp:14:10: fatal error: could not build 
> module 'LLVM_Utils'
>   #include "llvm/Support/TargetParser.h"
>^
>
> `Support` headers can't include `Option` headers (as `Option` depends on 
> `Support` already, so that would be a cyclic dependency). I believe folks 
> here are in the US time zone, so I went ahead and replaced the header include 
> with a forward decl to unbreak the bots (see 
> de4d2f80b75e2a1e4b0ac5c25e20f20839633688 
>  )
>
> FWIW, I think there is a better place than `Support` for this new class. 
> `Support` is a dependency of nearly every single LLVM component, but this 
> class seems to be used by a handful of files. Could we maybe move this to 
> some other/new part of LLVM (and make the few components that need it depend 
> on that)?

Thanks for the header fix. I think we also need to fix the library circular 
dependency that still exists. The Support library should not use anything from 
the Option library. Maybe we can partition the function some way that moves the 
MakeArgStr back into the clang driver code.

I don't know if we have a better library for this new class. I think Support is 
the only common library between the clang driver and LLVM's MC layer. I 
supposed we could create a new library, but that might be a hard sell for one 
file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[PATCH] D111986: [Clang] Add elementwise abs builtin.

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3109
+  Result = Builder.CreateBinaryIntrinsic(
+  llvm::Intrinsic::abs, Op0, Builder.getFalse(), nullptr, "elt.abs");
+else

craig.topper wrote:
> Did we discuss that this is different than __builtin_abs which is undefined 
> for INT_MIN?
I don't think we add nsw to vector signed integer subtract, so I guess using 
false here is consistent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111986

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


[PATCH] D112001: [Clang] Add min/max reduction builtins.

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



Comment at: clang/lib/Sema/SemaChecking.cpp:16673
+  if (!VecTy)
+  if (!TyA->getAs())
+  return Diag(A->getBeginLoc(), 
diag::err_elementwise_math_invalid_arg_type_2)

craig.topper wrote:
> Is this indented incorrectly? There appear to be 2 ifs at the same level
Yes they were, thanks! The `if (!TyA->getAs())` was a left-over 
from an earlier iteration. Removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112001

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


[PATCH] D112001: [Clang] Add min/max reduction builtins.

2021-10-18 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 380486.
fhahn added a comment.

Remove stray `!TyA->getAs()` check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112001

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c

Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -61,3 +61,31 @@
   i = __builtin_elementwise_min(v, iv);
   // expected-error@-1 {{argument types do not match, 'float4' (vector of 4 'float' values) != 'int3' (vector of 3 'int' values)}}
 }
+
+void test_builtin_reduce_max(int i, float4 v, int3 iv) {
+  struct Foo s = __builtin_reduce_max(iv);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+
+  i = __builtin_reduce_max(v, v);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  i = __builtin_reduce_max();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_reduce_max(i);
+  // expected-error@-1 {{argument must have a vector type, but was 'int'}}
+}
+
+void test_builtin_reduce_min(int i, float4 v, int3 iv) {
+  struct Foo s = __builtin_reduce_min(iv);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+
+  i = __builtin_reduce_min(v, v);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  i = __builtin_reduce_min();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_reduce_min(i);
+  // expected-error@-1 {{argument must have a vector type, but was 'int'}}
+}
Index: clang/test/CodeGen/builtins-elementwise-math.c
===
--- clang/test/CodeGen/builtins-elementwise-math.c
+++ clang/test/CodeGen/builtins-elementwise-math.c
@@ -110,3 +110,33 @@
   // CHECK-NEXT: call <4 x i32> @llvm.umin.v4i32(<4 x i32> [[VU1]], <4 x i32> [[VU2]])
   vu1 = __builtin_elementwise_min(vu1, vu2);
 }
+
+void test_builtin_reduce_max(float4 vf1, si8 vi1, u4 vu1) {
+  // CHECK-LABEL: define void @test_builtin_reduce_max(
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call float @llvm.vector.reduce.fmax.v4f32(<4 x float> [[VF1]])
+  float r1 = __builtin_reduce_max(vf1);
+
+  // CHECK:  [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16
+  // CHECK-NEXT: call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> [[VI1]])
+  short r2 = __builtin_reduce_max(vi1);
+
+  // CHECK:  [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16
+  // CHECK-NEXT: call i32 @llvm.vector.reduce.umax.v4i32(<4 x i32> [[VU1]])
+  unsigned r3 = __builtin_reduce_max(vu1);
+}
+
+void test_builtin_reduce_min(float4 vf1, si8 vi1, u4 vu1) {
+  // CHECK-LABEL: define void @test_builtin_reduce_min(
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call float @llvm.vector.reduce.fmin.v4f32(<4 x float> [[VF1]])
+  float r1 = __builtin_reduce_min(vf1);
+
+  // CHECK:  [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16
+  // CHECK-NEXT: call i16 @llvm.vector.reduce.smin.v8i16(<8 x i16> [[VI1]])
+  short r2 = __builtin_reduce_min(vi1);
+
+  // CHECK:  [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16
+  // CHECK-NEXT: call i32 @llvm.vector.reduce.umin.v4i32(<4 x i32> [[VU1]])
+  unsigned r3 = __builtin_reduce_min(vu1);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1978,11 +1978,14 @@
 
   case Builtin::BI__builtin_elementwise_abs:
 return SemaBuiltinElementwiseMathOneArg(TheCall, TheCallResult);
-
   case Builtin::BI__builtin_elementwise_min:
   case Builtin::BI__builtin_elementwise_max:
 return SemaBuiltinElementwiseMathTwoArgs(TheCall, TheCallResult);
 
+  case Builtin::BI__builtin_reduce_max:
+  case Builtin::BI__builtin_reduce_min:
+return SemaBuiltinReduceMath(TheCall, TheCallResult);
+
   case Builtin::BI__builtin_matrix_transpose:
 return SemaBuiltinMatrixTranspose(TheCall, TheCallResult);
   case Builtin::BI__builtin_matrix_column_major_load:
@@ -16656,6 +16659,23 @@
  _2, _3, _4));
 }
 
+ExprResult Sema::SemaBuiltinReduceMath(CallExpr *TheCall,
+   ExprResult CallResult) {
+  if (checkArgCount(*this, TheCall, 1))
+return ExprError();
+
+  Expr *A = TheCall->getArg(0);
+  QualType TyA = A->getType();
+
+  const VectorType *VecTy 

[PATCH] D111529: Specify Clang vector builtins.

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:557
+``i in [0, Number of elements / 2)``. If the numbers of elements is not a
+power of 2, the vector is widening with neutral elements for the reduction
+at the end to the next power of 2.

widening -> widened


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111529

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


[PATCH] D112024: [clang] diagnose_as attribute for Fortify diagnosing like builtins.

2021-10-18 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield created this revision.
mbenfield added a reviewer: george.burgess.iv.
Herald added a reviewer: aaron.ballman.
mbenfield 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/D112024

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/warn-fortify-source.c

Index: clang/test/Sema/warn-fortify-source.c
===
--- clang/test/Sema/warn-fortify-source.c
+++ clang/test/Sema/warn-fortify-source.c
@@ -181,6 +181,17 @@
   sprintf(buf, "5%.1e", 9.f); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 8}}
 }
 
+void *test_memcpy(const void *src, size_t c, void *dst) __attribute__((diagnose_as(__builtin_memcpy, 3, 1, 2))) {
+  return __builtin_memcpy(dst, src, c);
+}
+
+void call_test_memcpy() {
+  char bufferA[10];
+  char bufferB[11];
+  test_memcpy(bufferB, 10, bufferA);
+  test_memcpy(bufferB, 11, bufferA); // expected-warning {{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
+}
+
 #ifdef __cplusplus
 template  struct S {
   void mf() const {
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1001,6 +1001,38 @@
 };
 }
 
+static void handleDiagnoseAsAttr(Sema , Decl *D, const ParsedAttr ) {
+  SmallVector Indices;
+  for (unsigned I = 1; I < AL.getNumArgs(); ++I) {
+if (!AL.isArgExpr(I)) {
+  S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+  << AL << AANT_ArgumentIntegerConstant;
+  return;
+}
+
+Expr *IndexExpr = AL.getArgAsExpr(I);
+uint32_t Index;
+
+// If the expression is not parseable as a uint32_t we have a problem.
+if (!checkUInt32Argument(S, AL, IndexExpr, Index, UINT_MAX, false)) {
+  S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds)
+  << AL << I << IndexExpr->getSourceRange();
+  return;
+}
+
+Indices.push_back(Index - 1);
+  }
+
+  if (!AL.isArgExpr(0)) {
+S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+<< AL << AANT_ArgumentConstantExpr;
+return;
+  }
+
+  D->addAttr(::new (S.Context) DiagnoseAsAttr(S.Context, AL, AL.getArgAsExpr(0),
+  Indices.data(), Indices.size()));
+}
+
 static void handleDiagnoseIfAttr(Sema , Decl *D, const ParsedAttr ) {
   S.Diag(AL.getLoc(), diag::ext_clang_diagnose_if);
 
@@ -8029,6 +8061,9 @@
   case ParsedAttr::AT_DiagnoseIf:
 handleDiagnoseIfAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_DiagnoseAs:
+handleDiagnoseAsAttr(S, D, AL);
+break;
   case ParsedAttr::AT_NoBuiltin:
 handleNoBuiltinAttr(S, D, AL);
 break;
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -594,20 +594,51 @@
   isConstantEvaluated())
 return;
 
-  unsigned BuiltinID = FD->getBuiltinID(/*ConsiderWrappers=*/true);
+  bool UseDAIAttr = false;
+  FunctionDecl *UseDecl = FD;
+
+  auto DAIAttr = FD->getAttr();
+  if (DAIAttr) {
+DeclRefExpr *F = dyn_cast_or_null(DAIAttr->getFunction());
+if (!F)
+  return;
+FunctionDecl *AttrDecl = dyn_cast_or_null(F->getFoundDecl());
+if (!AttrDecl)
+  return;
+UseDecl = AttrDecl;
+UseDAIAttr = true;
+  }
+
+  unsigned BuiltinID = UseDecl->getBuiltinID(/*ConsiderWrappers=*/true);
+
   if (!BuiltinID)
 return;
 
   const TargetInfo  = getASTContext().getTargetInfo();
   unsigned SizeTypeWidth = TI.getTypeWidth(TI.getSizeType());
 
+  auto TranslateIndex = [&](unsigned Index) -> Optional {
+if (UseDAIAttr) {
+  if (Index >= DAIAttr->argIndices_size())
+return llvm::None;
+  return DAIAttr->argIndices_begin()[Index];
+}
+return Index;
+  };
+
   auto ComputeExplicitObjectSizeArgument =
   [&](unsigned Index) -> Optional {
+auto IndexOptional = TranslateIndex(Index);
+if (!IndexOptional)
+  return llvm::None;
+unsigned NewIndex = IndexOptional.getValue();
 Expr::EvalResult Result;
-Expr *SizeArg = TheCall->getArg(Index);
+Expr *SizeArg = TheCall->getArg(NewIndex);
 if (!SizeArg->EvaluateAsInt(Result, getASTContext()))
   return llvm::None;
-return Result.Val.getInt();
+auto Integer = Result.Val.getInt();
+Integer.setIsUnsigned(true);
+return Integer;
   };
 
   auto ComputeSizeArgument = [&](unsigned Index) -> Optional {
@@ -616,10 +647,15 @@
 // type 0.
 int BOSType = 0;
 if (const auto *POS =
-FD->getParamDecl(Index)->getAttr())
+

[clang] 5b949a6 - Fix crash when diagnosing a CTAD failure in an array new expression

2021-10-18 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-10-18T14:01:55-04:00
New Revision: 5b949a649aff0406a878e8eb8d7d5efba0a55e4a

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

LOG: Fix crash when diagnosing a CTAD failure in an array new expression

This appears to be a think-o where the developer was trying to check for a null
pointer but was actually checking (redundantly) whether the optional held a
valid value or not. We now properly check the pointer for null.

This fixes PR51547.

Added: 
clang/test/SemaCXX/new-delete-array.cpp

Modified: 
clang/lib/Sema/SemaExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 6b091364c911f..0f3f50c8f6c6f 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1967,10 +1967,10 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
   if (Deduced && isa(Deduced)) {
 if (ArraySize)
   return ExprError(
-  Diag(ArraySize ? (*ArraySize)->getExprLoc() : TypeRange.getBegin(),
+  Diag(*ArraySize ? (*ArraySize)->getExprLoc() : TypeRange.getBegin(),
diag::err_deduced_class_template_compound_type)
   << /*array*/ 2
-  << (ArraySize ? (*ArraySize)->getSourceRange() : TypeRange));
+  << (*ArraySize ? (*ArraySize)->getSourceRange() : TypeRange));
 
 InitializedEntity Entity
   = InitializedEntity::InitializeNew(StartLoc, AllocType);

diff  --git a/clang/test/SemaCXX/new-delete-array.cpp 
b/clang/test/SemaCXX/new-delete-array.cpp
new file mode 100644
index 0..fca1ec132acca
--- /dev/null
+++ b/clang/test/SemaCXX/new-delete-array.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 %s -verify=cxx17
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 %s -verify=cxx14
+
+namespace PR51547 {
+template struct A; // cxx14-note {{template is declared here}}
+auto p = new A[]{}; // cxx14-error {{use of class template 'A' requires 
template arguments}} \
+   cxx17-error {{cannot form array of deduced class 
template specialization type}}
+}
+



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


[PATCH] D112022: [WebAssembly] Add prototype relaxed swizzle instructions

2021-10-18 Thread Ng Zhi An via Phabricator via cfe-commits
ngzhian added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td:1365
+
+def wasm_relaxed_swizzle : SDNode<"WebAssemblyISD::RELAXED_SWIZZLE", 
wasm_swizzle_t>;
+

@tlively i'm not 100% sure if this is needed or the right thing to do, i looked 
at what i8x16.swizzle currently does and just replaced the name and opcode. LMK 
if this needs to be changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112022

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


[PATCH] D112022: [WebAssembly] Add prototype relaxed swizzle instructions

2021-10-18 Thread Ng Zhi An via Phabricator via cfe-commits
ngzhian created this revision.
ngzhian added a reviewer: tlively.
Herald added subscribers: ecnelises, sunfish, hiraditya, jgravelle-google, 
sbc100, dschuff.
ngzhian requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, aheejin.
Herald added projects: clang, LLVM.

Add i8x16 relaxed_swizzle instructions. These are only
exposed as builtins, and require user opt-in.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112022

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -803,4 +803,7 @@
 # CHECK: i64x2.laneselect # encoding: [0xfd,0xd3,0x01]
 i64x2.laneselect
 
+# CHECK: i8x16.relaxed_swizzle # encoding: [0xfd,0xa2,0x01]
+i8x16.relaxed_swizzle
+
 end_function
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -192,6 +192,16 @@
   ret <16 x i8> %v
 }
 
+; CHECK-LABEL: relaxed_swizzle_v16i8:
+; CHECK-NEXT: .functype relaxed_swizzle_v16i8 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: i8x16.relaxed_swizzle $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8>, <16 x i8>)
+define <16 x i8> @relaxed_swizzle_v16i8(<16 x i8> %x, <16 x i8> %y) {
+  %a = call <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8> %x, <16 x i8> %y)
+  ret <16 x i8> %a
+}
+
 ; ==
 ; 8 x i16
 ; ==
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1361,3 +1361,14 @@
 defm "" : SIMDLANESELECT;
 defm "" : SIMDLANESELECT;
 defm "" : SIMDLANESELECT;
+
+def wasm_relaxed_swizzle : SDNode<"WebAssemblyISD::RELAXED_SWIZZLE", wasm_swizzle_t>;
+
+defm RELAXED_SWIZZLE :
+  RELAXED_I<(outs V128:$dst), (ins V128:$src, V128:$mask), (outs), (ins),
+ [(set (v16i8 V128:$dst),
+   (wasm_relaxed_swizzle (v16i8 V128:$src), (v16i8 V128:$mask)))],
+ "i8x16.relaxed_swizzle\t$dst, $src, $mask", "i8x16.relaxed_swizzle", 162>;
+
+def : Pat<(int_wasm_relaxed_swizzle (v16i8 V128:$src), (v16i8 V128:$mask)),
+  (RELAXED_SWIZZLE $src, $mask)>;
Index: llvm/lib/Target/WebAssembly/WebAssemblyISD.def
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISD.def
+++ llvm/lib/Target/WebAssembly/WebAssemblyISD.def
@@ -49,3 +49,6 @@
 HANDLE_MEM_NODETYPE(GLOBAL_GET)
 HANDLE_MEM_NODETYPE(GLOBAL_SET)
 HANDLE_MEM_NODETYPE(TABLE_SET)
+
+// Relaxed SIMD proposal.
+HANDLE_NODETYPE(RELAXED_SWIZZLE)
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -200,6 +200,11 @@
 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
 
+def int_wasm_relaxed_swizzle :
+  Intrinsic<[llvm_v16i8_ty],
+[llvm_v16i8_ty, llvm_v16i8_ty],
+[IntrNoMem, IntrSpeculatable]>;
+
 //===--===//
 // Thread-local storage intrinsics
 //===--===//
Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -732,3 +732,8 @@
   // WEBASSEMBLY-SAME: <2 x i64> %a, <2 x i64> %b, <2 x i64> %c)
   // WEBASSEMBLY-NEXT: ret
 }
+
+i8x16 relaxed_swizzle_i8x16(i8x16 x, i8x16 y) {
+  return __builtin_wasm_relaxed_swizzle_i8x16(x, y);
+  // WEBASSEMBLY: call <16 x i8> @llvm.wasm.relaxed.swizzle(<16 x i8> %x, <16 x i8> %y)
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -18319,6 +18319,12 @@
 CGM.getIntrinsic(Intrinsic::wasm_laneselect, A->getType());
 return Builder.CreateCall(Callee, {A, B, C});
   }
+  case 

[PATCH] D112020: [RISCV] Use clang_builtin_alias for all RISCV vector intrinsics.

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: khchen, arcbbb, kito-cheng, HsiangKai, evandro.
Herald added subscribers: achieveartificialintelligence, jeroen.dobbelaere, 
StephenFan, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, 
Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.

Previously we used builtin_alias for overloaded intrinsics, but
macros for the non-overloaded version. This patch changes the
non-overloaded versions to also use builtin_alias, but without
the overloadable attribute.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112020

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -202,7 +202,7 @@
   void emitCodeGenSwitchBody(raw_ostream ) const;
 
   // Emit the macros for mapping C/C++ intrinsic function to builtin functions.
-  void emitIntrinsicMacro(raw_ostream ) const;
+  void emitIntrinsicFuncDef(raw_ostream ) const;
 
   // Emit the mangled function definition.
   void emitMangledFuncDef(raw_ostream ) const;
@@ -860,21 +860,17 @@
   OS << "  break;\n";
 }
 
-void RVVIntrinsic::emitIntrinsicMacro(raw_ostream ) const {
-  OS << "#define " << getName() << "(";
-  if (!InputTypes.empty()) {
-ListSeparator LS;
-for (unsigned i = 0, e = InputTypes.size(); i != e; ++i)
-  OS << LS << "op" << i;
-  }
-  OS << ") \\\n";
-  OS << "__builtin_rvv_" << getName() << "(";
+void RVVIntrinsic::emitIntrinsicFuncDef(raw_ostream ) const {
+  OS << "__attribute__((clang_builtin_alias(";
+  OS << "__builtin_rvv_" << getName() << ")))\n";
+  OS << OutputType->getTypeStr() << " " << getName() << "(";
+  // Emit function arguments
   if (!InputTypes.empty()) {
 ListSeparator LS;
-for (unsigned i = 0, e = InputTypes.size(); i != e; ++i)
-  OS << LS << "(" << InputTypes[i]->getTypeStr() << ")(op" << i << ")";
+for (unsigned i = 0; i < InputTypes.size(); ++i)
+  OS << LS << InputTypes[i]->getTypeStr() << " op" << i;
   }
-  OS << ")\n";
+  OS << ");\n\n";
 }
 
 void RVVIntrinsic::emitMangledFuncDef(raw_ostream ) const {
@@ -986,11 +982,17 @@
  return A->getRISCVExtensions() < B->getRISCVExtensions();
});
 
+  OS << "#define __rvv_ai static inline "
+"__attribute__((__always_inline__, __nodebug__))\n";
+
   // Print intrinsic functions with macro
   emitArchMacroAndBody(Defs, OS, [](raw_ostream , const RVVIntrinsic ) 
{
-Inst.emitIntrinsicMacro(OS);
+OS << "__rvv_ai ";
+Inst.emitIntrinsicFuncDef(OS);
   });
 
+  OS << "#undef __rvv_ai\n";
+
   OS << "#define __riscv_v_intrinsic_overloading 1\n";
 
   // Print Overloaded APIs
@@ -1004,6 +1006,8 @@
 Inst.emitMangledFuncDef(OS);
   });
 
+  OS << "#undef __rvv_overloaded\n";
+
   OS << "\n#ifdef __cplusplus\n";
   OS << "}\n";
   OS << "#endif // __cplusplus\n";


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -202,7 +202,7 @@
   void emitCodeGenSwitchBody(raw_ostream ) const;
 
   // Emit the macros for mapping C/C++ intrinsic function to builtin functions.
-  void emitIntrinsicMacro(raw_ostream ) const;
+  void emitIntrinsicFuncDef(raw_ostream ) const;
 
   // Emit the mangled function definition.
   void emitMangledFuncDef(raw_ostream ) const;
@@ -860,21 +860,17 @@
   OS << "  break;\n";
 }
 
-void RVVIntrinsic::emitIntrinsicMacro(raw_ostream ) const {
-  OS << "#define " << getName() << "(";
-  if (!InputTypes.empty()) {
-ListSeparator LS;
-for (unsigned i = 0, e = InputTypes.size(); i != e; ++i)
-  OS << LS << "op" << i;
-  }
-  OS << ") \\\n";
-  OS << "__builtin_rvv_" << getName() << "(";
+void RVVIntrinsic::emitIntrinsicFuncDef(raw_ostream ) const {
+  OS << "__attribute__((clang_builtin_alias(";
+  OS << "__builtin_rvv_" << getName() << ")))\n";
+  OS << OutputType->getTypeStr() << " " << getName() << "(";
+  // Emit function arguments
   if (!InputTypes.empty()) {
 ListSeparator LS;
-for (unsigned i = 0, e = InputTypes.size(); i != e; ++i)
-  OS << LS << "(" << InputTypes[i]->getTypeStr() << ")(op" << i << ")";
+for (unsigned i = 0; i < InputTypes.size(); ++i)
+  OS << LS << InputTypes[i]->getTypeStr() << " op" << i;
   }
-  OS << ")\n";
+  OS << ");\n\n";
 }
 
 void RVVIntrinsic::emitMangledFuncDef(raw_ostream ) const {
@@ -986,11 +982,17 @@
  return A->getRISCVExtensions() < B->getRISCVExtensions();
});
 
+  OS << "#define __rvv_ai static 

[PATCH] D112019: [clang-format] [PR51412] AlignConsecutiveMacros fights with Visual Studio and resource.h

2021-10-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: curdeius, HazardyKnusperkeks, krasimir.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.

clang-format `AlignConsecutiveMacros` feature causes real problems when using 
Win32 resource.h files via the resource editor in Visual Studio when editing RC 
files.

VS produces the following for the resource.h files

  ...
  // Microsoft Visual C++ generated include file.
  // Used by MyTest.rc
  //
  #define IDP_OLE_INIT_FAILED 100
  #define IDP_FAILED_TO_CREATE102
  #define ID_STATUSBAR_SHOW   108
  #define ID_STATUSBAR_TEXT   109

Visual Studio generates a resource.h with Alignment macros which start at 40 
characters, but `AlignConsecutiveMacros`  will determine the starting point but 
assume a minimum of 0 meaning a clang-format will result in:

  #define IDP_OLE_INIT_FAILED  100
  #define IDP_FAILED_TO_CREATE 102
  #define ID_STATUSBAR_SHOW108
  #define ID_STATUSBAR_TEXT109

This is would be good until you make a new rc file change which results in VS 
writing out the resource.h (back in its own form) - (even clang-format VS 
plugin to format on save doesn't resolve this. The writing of resource.h seems 
outside of the normal save system)

This situation is made worse, if it encounters a long symbol, in the VS case it 
treats this as a one off, but clang-format will assume this is the new minimum.

  #define IDP_OLE_INIT_FAILED 100
  #define IDP_FAILED_TO_CREATE102
  #define ID_VERYVERYVERYVERY_LONG_LONG_LONG_LONG_RESOURCE 33221
  #define ID_STATUSBAR_SHOW   108
  #define ID_STATUSBAR_TEXT   109

and will become via clang-format

  #define IDP_OLE_INIT_FAILED  100
  #define IDP_FAILED_TO_CREATE 102
  #define ID_VERYVERYVERYVERY_LONG_LONG_LONG_LONG_RESOURCE 33221
  #define ID_STATUSBAR_SHOW108
  #define ID_STATUSBAR_TEXT109

This patch contains 2 new options

1. Set the minimum to a fixed integer (which for VS should be 40), this means 
all id numbers will begin at 40
2. An option to allow very long macro names to break the Alignment, meaning the 
next line will reset back to the previous configured minimum (40 in our case)

These 2 option have functionality that could be useful on their own, however 
the goal is to allow `AlignConsecutiveMacros` to be useful for Windows Win32 
developers and minimize the clang-format changes that the RC editor causes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112019

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14954,6 +14954,31 @@
Style));
 }
 
+TEST_F(FormatTest, AlignConsecutiveMacrosMinWidth) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignConsecutiveMacros = FormatStyle::ACS_Consecutive;
+  verifyFormat("#define a3\n"
+   "#define  4\n"
+   "#define ccc  (5)",
+   Style);
+  Style.AlignConsecutiveMacrosMinWidth = 30;
+  verifyFormat("#define a 3\n"
+   "#define   4\n"
+   "#define ccc   (5)",
+   Style);
+
+  verifyFormat("#define a 3\n"
+   "#define vveylonglonglongmacro 4\n"
+   "#define ccc   (5)",
+   Style);
+
+  Style.AlignConsecutiveMacrosIgnoreMax = true;
+  verifyFormat("#define a 3\n"
+   "#define vveylonglonglongmacro 4\n"
+   "#define ccc   (5)",
+   Style);
+}
+
 TEST_F(FormatTest, AlignConsecutiveAssignmentsAcrossEmptyLines) {
   FormatStyle Alignment = getLLVMStyle();
   Alignment.AlignConsecutiveMacros = FormatStyle::ACS_Consecutive;
@@ -18245,6 +18270,7 @@
 TEST_F(FormatTest, ParsesConfigurationBools) {
   FormatStyle Style = {};
   Style.Language = FormatStyle::LK_Cpp;
+  CHECK_PARSE_BOOL(AlignConsecutiveMacrosIgnoreMax);
   CHECK_PARSE_BOOL(AlignTrailingComments);
   CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
@@ -18367,6 +18393,9 @@
   CHECK_PARSE("AlignConsecutiveAssignments: AcrossEmptyLinesAndComments",
   AlignConsecutiveAssignments,
   FormatStyle::ACS_AcrossEmptyLinesAndComments);
+  CHECK_PARSE("AlignConsecutiveMacrosMinWidth: 32",
+  AlignConsecutiveMacrosMinWidth, 

[PATCH] D111986: [Clang] Add elementwise abs builtin.

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3109
+  Result = Builder.CreateBinaryIntrinsic(
+  llvm::Intrinsic::abs, Op0, Builder.getFalse(), nullptr, "elt.abs");
+else

Did we discuss that this is different than __builtin_abs which is undefined for 
INT_MIN?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111986

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


[clang] 2e4e200 - Fix a comment in SemaSYCL to make sure I can commit

2021-10-18 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-10-18T10:12:28-07:00
New Revision: 2e4e2004afc51303bbb8836e886363f2056d73eb

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

LOG: Fix a comment in SemaSYCL to make sure I can commit

Added: 


Modified: 
clang/lib/Sema/SemaSYCL.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp
index 481725eb0924..815463307ecc 100644
--- a/clang/lib/Sema/SemaSYCL.cpp
+++ b/clang/lib/Sema/SemaSYCL.cpp
@@ -38,7 +38,7 @@ bool Sema::checkSYCLDeviceFunction(SourceLocation Loc, 
FunctionDecl *Callee) {
  "Should only be called during SYCL compilation");
   assert(Callee && "Callee may not be null.");
 
-  // Errors in unevaluated context don't need to be generated,
+  // Errors in an unevaluated context don't need to be generated,
   // so we can safely skip them.
   if (isUnevaluatedContext() || isConstantEvaluated())
 return true;



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


[PATCH] D112001: [Clang] Add min/max reduction builtins.

2021-10-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:16673
+  if (!VecTy)
+  if (!TyA->getAs())
+  return Diag(A->getBeginLoc(), 
diag::err_elementwise_math_invalid_arg_type_2)

Is this indented incorrectly? There appear to be 2 ifs at the same level


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112001

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


[PATCH] D111863: [libunwind] Add an interface for dynamic .eh_frame registration

2021-10-18 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

I don't know enough about Dwarf unwinding but the implementation looks 
generally good. Can you please add a testcase indicating how ORCJIT is planning 
to use it?




Comment at: libunwind/src/DwarfParser.hpp:158
+   FDE_Info *fdeInfo, CIE_Info *cieInfo,
+   bool useCIEInfo = false);
   static bool parseFDEInstructions(A , const FDE_Info ,

Can you document how and when this parameter should be used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111863

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


[PATCH] D111870: [clangd] Add a way to enable IncludeCleaner through config

2021-10-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Config.h:89
 
   /// Controls warnings and errors when parsing code.
+  enum IncludeCleanerPolicy { UnusedHeaders, None };

you've accidentally split this comment from its decl



Comment at: clang-tools-extra/clangd/Config.h:90
   /// Controls warnings and errors when parsing code.
+  enum IncludeCleanerPolicy { UnusedHeaders, None };
   struct {

structure, as discussed offline...

"include cleaner" refers to a set of features to do with header hygiene, 
related but I think we still want to configure them individually.

"Unused headers" is the feature we're trying to configure, so I think it's a 
key rather than a value. Its value could be a boolean, (and configure other 
aspects separately), or we could make it an enum so we can choose a policy at 
the same time.
My suspicion is that the major knob here is strictness: do we warn when a 
header doesn't *directly* provide any used symbols, or also indirectly?

So I'd probably call this `UnusedInclude: Strict` 



Comment at: clang-tools-extra/clangd/Config.h:94
 llvm::StringSet<> Suppress;
+IncludeCleanerPolicy IncludeCleaner = None;
 

don't group with the generic suppression bits



Comment at: clang-tools-extra/clangd/ConfigFragment.h:213
 
+/// Valid values are:
+/// - UnusedHeaders

This is where the documentation for the feature goes :-)



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:215
+D.Message = "Included header is unused";
+D.Name = "clangd-include-cleaner";
+// FIXME: This range should be the whole line with target #include.

Source should be `Clangd` I think (our first?).

Name should be something like "unused-include": this doesn't need to echo the 
tool name.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:216
+D.Name = "clangd-include-cleaner";
+// FIXME: This range should be the whole line with target #include.
+D.Range.start.line = Inc->HashLine;

remove FIXEDME



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:221
+D.Range.end.character =
+Code.drop_front(Inc->HashOffset).find_first_of("\n\1A");
+D.Fixes.emplace_back();

This doesn't handle hitting EOF correctly, and also gets encodings wrong 
(should be UTF-16 code units, unless we're in another mode).

I think you want:
```
D.range.end.character = 
lspLength(Code.drop_front(Inc->HashOffset).take_until([](char C) { return c == 
'\n' || c == '\r'; }));
```

You could make this a function in SourceCode.h if you like.
(I'm fairly sure we're not clean when it comes to using `\r` being a line 
separator in the rest of the code BTW)



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:226
+D.Fixes.back().Edits.back().range.start.line = Inc->HashLine;
+// LSP uses [start; end) ranges: this will span the deletion range to EOL.
+D.Fixes.back().Edits.back().range.end.line = Inc->HashLine + 1;

No need to explain the ranges thing, this is ubiquitous and documented on the 
structs.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:229
+D.InsideMainFile = true;
+AST.getSourceManager();
+D.File = AST.getSourceManager()

no-op



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:230
+AST.getSourceManager();
+D.File = AST.getSourceManager()
+ .getFileEntryForID(AST.getSourceManager().getMainFileID())

don't do this in the loop



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:235
+D.Severity = DiagnosticsEngine::Warning;
+Result.push_back(std::move(D));
+  }

D.Tags.push_back(Unneccesary)

This produces nice rendering in vscode



Comment at: clang-tools-extra/clangd/IncludeCleaner.h:67
+std::vector issueUnusedIncludesDiagnostics(ParsedAST ,
+ StringRef Code);
+

nit: llvm::StringRef



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:380
 if (IsClangTidyDiag) {
   if (Cfg.Diagnostics.Suppress.contains(CheckName))
 return DiagnosticsEngine::Ignored;

You're bypassing this logic, which is OK, but you'll need to duplicate it 
somewhere. (Probably wherever is looking at cfg anyway)



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:519
   }
-  return ParsedAST(Inputs.Version, std::move(Preamble), std::move(Clang),
+  ParsedAST Result(Inputs.Version, std::move(Preamble), std::move(Clang),
std::move(Action), std::move(Tokens), std::move(Macros),

You're missing tests for this functionality



Comment at: 

[PATCH] D111975: [clang-format] [PR52015] clang-format should put __attribute__((foo)) on its own line before @interface / @implementation / @protocol

2021-10-18 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111975

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


[PATCH] D111534: [analyzer][NFC] Refactor CallEvent::isCalled()

2021-10-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal marked 3 inline comments as done.
steakhal added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:1289
+  /// E.g. { "std", "vector", "data" } -> "vector", "std"
+  auto begin_qualified_name_parts() const {
+return std::next(QualifiedName.rbegin());

ASDenysPetrov wrote:
> What rules did you use to name this functions? It seems that it goes against 
> [[ 
> https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
>  | LLVM naming rules]].
Not exactly. There is an exception for `begin()` and `end()`.
That being said, `begin` should have been a suffix instead of being a prefix.
But I still like this more :D



Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:336-352
+  const auto ExactMatchArgAndParamCounts =
+  [](const CallEvent , const CallDescription ) -> bool {
+const bool ArgsMatch =
+!CD.RequiredArgs || CD.RequiredArgs == Call.getNumArgs();
+const bool ParamsMatch =
+!CD.RequiredParams || CD.RequiredParams == Call.parameters().size();
+return ArgsMatch && ParamsMatch;

ASDenysPetrov wrote:
> Can we move these lambdas in separate functions? IMO it could make the code 
> even more readable.
We could, but I'm not planning to move them.
That would be more appropriate to move all `CallDescription` implementation to 
its own translation unit.



Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:349
+[](const DeclContext *Ctx) -> const DeclContext * {
+  while (Ctx && !isa(Ctx) && !isa(Ctx))
+Ctx = Ctx->getParent();

martong wrote:
> steakhal wrote:
> > TBH I don't understand why doesn't `isa()` work. 
> > I could have used this variadic form so many times.
> > WDYT, should I propose turning `isa` and `isa_and_nonnull`˙into variadic 
> > functions?
> > TBH I don't understand why doesn't `isa()` work. 
> > I could have used this variadic form so many times.
> > WDYT, should I propose turning `isa` and `isa_and_nonnull`˙into variadic 
> > functions?
> 
> Yes, that's a good idea!
Actually, it's already variadic :D
I created a follow-up patch for addressing similar issues in D111982.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111534

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


[PATCH] D106681: [analyzer][NFC] Move a block from `getBindingForElement` to separate functions

2021-10-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 380441.
ASDenysPetrov retitled this revision from "[analyzer] Retrieve a value from 
list initialization of constant multi-dimensional array." to "[analyzer][NFC] 
Move a block from `getBindingForElement` to separate functions".
ASDenysPetrov edited the summary of this revision.
ASDenysPetrov added reviewers: martong, steakhal.
ASDenysPetrov set the repository for this revision to rG LLVM Github Monorepo.
ASDenysPetrov added a comment.

@martong
Please, look. As you suggested in D111542#inline-1064497 
 I made an intermediate patch 
making next patches easer for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106681

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -437,6 +437,10 @@
 
   RegionBindingsRef removeSubRegionBindings(RegionBindingsConstRef B,
 const SubRegion *R);
+  Optional getConstantValFromConstArrayInitializer(
+  RegionBindingsConstRef B, const VarRegion *VR, const ElementRegion *R);
+  Optional getSValFromInitListExpr(const InitListExpr *ILE,
+ uint64_t Offset, QualType ElemT);
 
 public: // Part of public interface to class.
 
@@ -1625,6 +1629,93 @@
   return Result;
 }
 
+Optional RegionStoreManager::getConstantValFromConstArrayInitializer(
+RegionBindingsConstRef B, const VarRegion *VR, const ElementRegion *R) {
+  assert(R && VR && "Regions should not be null");
+
+  // Array should be immutable.
+  const VarDecl *VD = VR->getDecl();
+  if (!VD->getType().isConstQualified() &&
+  !R->getElementType().isConstQualified() &&
+  (!B.isMainAnalysis() || !VD->hasGlobalStorage()))
+return None;
+
+  // Array's declaration should have ConstantArrayType type.
+  const ConstantArrayType *CAT = Ctx.getAsConstantArrayType(VD->getType());
+  if (!CAT)
+return None;
+
+  // Array should be one-dimensional.
+  // TODO: Support multidimensional array.
+  if (isa(CAT->getElementType())) // is multidimensional
+return None;
+
+  // Array's offset should be a concrete value.
+  // Return Unknown value if symbolic index presented.
+  // FIXME: We also need to take ElementRegions with symbolic
+  // indexes into account.
+  const auto OffsetVal = R->getIndex().getAs();
+  if (!OffsetVal.hasValue())
+return UnknownVal();
+
+  // Check offset for being out of bounds.
+  // C++20 [expr.add] 7.6.6.4 (excerpt):
+  //   If P points to an array element i of an array object x with n
+  //   elements, where i < 0 or i > n, the behavior is undefined.
+  //   Dereferencing is not allowed on the "one past the last
+  //   element", when i == n.
+  // Example:
+  //   const int arr[4] = {1, 2};
+  //   const int *ptr = arr;
+  //   int x0 = ptr[0];  // 1
+  //   int x1 = ptr[1];  // 2
+  //   int x2 = ptr[2];  // 0
+  //   int x3 = ptr[3];  // 0
+  //   int x4 = ptr[4];  // UB
+  //   int x5 = ptr[-1]; // UB
+  const llvm::APSInt  = OffsetVal->getValue();
+  const auto Offset = static_cast(OffsetInt.getExtValue());
+  // Use `getZExtValue` because array extent can not be negative.
+  const uint64_t Extent = CAT->getSize().getZExtValue();
+  // Check for `OffsetInt < 0` but NOT for `Offset < 0`, because `OffsetInt`
+  // CAN be negative, but `Offset` can NOT, because `Offset` is an uint64_t.
+  if (OffsetInt < 0 || Offset >= Extent)
+return UndefinedVal();
+  // From here `Offset` is in the bounds.
+
+  // Array's declaration should have an initializer.
+  const Expr *Init = VD->getAnyInitializer();
+  if (!Init)
+return None;
+
+  // Handle InitListExpr.
+  if (const auto *ILE = dyn_cast(Init))
+return getSValFromInitListExpr(ILE, Offset, R->getElementType());
+
+  // FIXME: Handle StringLiteral.
+
+  // FIXME: Handle CompoundLiteralExpr.
+
+  return None;
+}
+
+Optional
+RegionStoreManager::getSValFromInitListExpr(const InitListExpr *ILE,
+uint64_t Offset, QualType ElemT) {
+  assert(ILE && "InitListExpr should not be null");
+
+  // C++20 [expr.add] 9.4.17.5 (excerpt):
+  //   i-th array element is value-initialized for each k < i ≤ n,
+  //   where k is an expression-list size and n is an array extent.
+  if (Offset >= ILE->getNumInits())
+return svalBuilder.makeZeroVal(ElemT);
+
+  // Return a constant value, if it is presented.
+  // FIXME: Support other SVals.
+  const Expr *E = ILE->getInit(Offset);
+  return svalBuilder.getConstantVal(E);
+}
+
 SVal RegionStoreManager::getBindingForElement(RegionBindingsConstRef B,
   const ElementRegion* R) {
   // Check if the region has a 

[PATCH] D74531: [WebAssembly] Emit clangast in custom section aligned by 4 bytes

2021-10-18 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: llvm/lib/MC/WasmObjectWriter.cpp:374
+  // Custom sections in wasm also have a string identifier with extra paddings
+  // for alignment for special sections.
+  // TODO: support section alignment at asm and llvm level?

I would leave the first sentence alone which that applies to all custom 
sections.The second part of this sentence (the new part) is maybe not 
needed since you have a comment already on line 378.

Also, how about keeping the simpler form in the default case, and putting this 
new code in a new method. e.g.:

```
if (Name != "__clangast") {
  writeString(Name);
} else {
  writeStringWithAlignment(Name, 4);
}
```

Then the entire new method can be marked with the TODO to remove it if/when we 
change the section mapping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74531

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


[PATCH] D112013: [clang][ASTImporter] Fix for importing functions with EST_Unevaluated prototype.

2021-10-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, whisperity, martong, teemperor, gamesh411, 
Szelethus, dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix for importing functions where the TypeSourceInfo is set and the
exception specification information contains reference to the function
declaration itself.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112013

Files:
  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
@@ -6145,6 +6145,57 @@
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportTypeSourceInfoWithExceptionSpecUnevaluated) {
+  // This code results in a lambda with implicit constructor.
+  // The constructor should have a "unevaluated" exception specification in its
+  // prototype information.
+  // In some cases the constructor has a TypeSourceInfo that contains the
+  // function's prototype, but often the TypeSourceInfo is not set
+  // (like in the code used here).
+  // The test sets the TypeSourceInfo artifically to simulate a case when it is
+  // set. The test verifies that AST import of such AST does not crash.
+  // (Here the function's TypeSourceInfo references the function itself in the
+  // exception information of the prototype.)
+  // A lambda and implicit constructor of it is used because the problem was
+  // encountered in a similar real code.
+  Decl *FromTU =
+  getTuDecl("void f() { auto X = [](){}; }", Lang_CXX11, "input0.cc");
+
+  CXXRecordDecl *FromL = FirstDeclMatcher()
+ .match(FromTU, lambdaExpr())
+ ->getLambdaClass();
+
+  CXXConstructorDecl *FromCtor = *FromL->ctor_begin();
+  QualType FromTy = FromCtor->getType();
+  const auto *FromFPT = FromTy->getAs();
+  ASSERT_TRUE(FromFPT);
+  FunctionProtoType::ExtProtoInfo FromEPI = FromFPT->getExtProtoInfo();
+  // If type is EST_Unevaluated, SourceDecl should be set to the parent decl.
+  EXPECT_EQ(FromEPI.ExceptionSpec.Type, EST_Unevaluated);
+  EXPECT_EQ(FromEPI.ExceptionSpec.SourceDecl, FromCtor);
+
+  // No TypeSourceInfo for the constructor.
+  ASSERT_FALSE(FromCtor->getTypeSourceInfo());
+  // Set a TypeSourceInfo for the function, this state may occur in reality.
+  TypeSourceInfo *FromTSI = FromTU->getASTContext().getTrivialTypeSourceInfo(
+  FromTy, FromCtor->getBeginLoc());
+  FromCtor->setTypeSourceInfo(FromTSI);
+
+  // Import it.
+  auto ToL = Import(FromL, Lang_CXX11);
+
+  // Check if the import was correct.
+  CXXConstructorDecl *ToCtor = *ToL->ctor_begin();
+  const auto *ToFPT = ToCtor->getType()->getAs();
+  ASSERT_TRUE(FromFPT);
+  FunctionProtoType::ExtProtoInfo ToEPI = ToFPT->getExtProtoInfo();
+  EXPECT_EQ(ToEPI.ExceptionSpec.Type, EST_Unevaluated);
+  EXPECT_EQ(ToEPI.ExceptionSpec.SourceDecl, ToCtor);
+  EXPECT_TRUE(ToCtor->getTypeSourceInfo());
+  EXPECT_EQ(ToCtor->getTypeSourceInfo()->getType().getTypePtr(), ToFPT);
+}
+
 struct ImportAutoFunctions : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportAutoFunctions, ReturnWithTypedefDeclaredInside) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3422,11 +3422,14 @@
 return std::move(Err);
 
   QualType FromTy = D->getType();
+  TypeSourceInfo *FromTSI = D->getTypeSourceInfo();
   // Set to true if we do not import the type of the function as is. There are
   // cases when the original type would result in an infinite recursion during
   // the import. To avoid an infinite recursion when importing, we create the
   // FunctionDecl with a simplified function type and update it only after the
   // relevant AST nodes are already imported.
+  // The type is related to TypeSourceInfo (it references the type), so we must
+  // do the same with TypeSourceInfo.
   bool UsedDifferentProtoType = false;
   if (const auto *FromFPT = FromTy->getAs()) {
 QualType FromReturnTy = FromFPT->getReturnType();
@@ -3453,11 +3456,13 @@
 }
 FromTy = Importer.getFromContext().getFunctionType(
 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
+FromTSI = Importer.getFromContext().getTrivialTypeSourceInfo(
+FromTy, D->getBeginLoc());
   }
 
   Error Err = Error::success();
   auto T = importChecked(Err, FromTy);
-  auto TInfo = importChecked(Err, D->getTypeSourceInfo());
+  auto TInfo = importChecked(Err, FromTSI);
   auto ToInnerLocStart = importChecked(Err, D->getInnerLocStart());
   auto ToEndLoc = importChecked(Err, D->getEndLoc());
   auto ToQualifierLoc = importChecked(Err, D->getQualifierLoc());
@@ 

[clang] 1fb24fe - Reland [clang] Pass -clear-ast-before-backend in Clang::ConstructJob()

2021-10-18 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-10-18T09:08:16-07:00
New Revision: 1fb24fe85a19ae71b00875ff6c96ef1831dcf7e3

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

LOG: Reland [clang] Pass -clear-ast-before-backend in Clang::ConstructJob()

This clears the memory used for the Clang AST before we run LLVM passes.

https://llvm-compile-time-tracker.com/compare.php?from=d0a5f61c4f6fccec87fd5207e3fcd9502dd59854=b7437fee79e04464dd968e1a29185495f3590481=max-rss
shows significant memory savings with no slowdown (in fact -O0 slightly speeds 
up).

For more background, see
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068930.html.

Turn this off for the interpreter since it does codegen multiple times.

Relanding with fix for -print-stats: D111973

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Interpreter/Interpreter.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d2c08412d5932..83afbc3952d84 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4660,6 +4660,7 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   // cleanup.
   if (!C.isForDiagnostics())
 CmdArgs.push_back("-disable-free");
+  CmdArgs.push_back("-clear-ast-before-backend");
 
 #ifdef NDEBUG
   const bool IsAssertBuild = false;

diff  --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 02b3025297b67..d14940d2e1321 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -113,6 +113,10 @@ CreateCI(const llvm::opt::ArgStringList ) {
 
   Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
 
+  // Don't clear the AST before backend codegen since we do codegen multiple
+  // times, reusing the same AST.
+  Clang->getCodeGenOpts().ClearASTBeforeBackend = false;
+
   return std::move(Clang);
 }
 



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


[PATCH] D112008: Add -extra-arg-clang-tidy to {clang-tidy-diff,run-clang-tidy}.py

2021-10-18 Thread Xavier Roche via Phabricator via cfe-commits
Xavier updated this revision to Diff 380436.

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

https://reviews.llvm.org/D112008

Files:
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -81,8 +81,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter):
+extra_arg, extra_arg_before, extra_arg_clang_tidy,
+quiet, config, line_filter):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary, '--use-color']
   if allow_enabling_alpha_checkers:
@@ -109,6 +109,7 @@
   start.append('-quiet')
   if config:
   start.append('-config=' + config)
+  start += extra_arg_clang_tidy
   start.append(f)
   return start
 
@@ -168,7 +169,8 @@
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter)
+ args.extra_arg_clang_tidy, args.quiet,
+ args.config, args.line_filter)
 
 proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 output, err = proc.communicate()
@@ -241,6 +243,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true',
   help='Run clang-tidy in quiet mode')
   args = parser.parse_args()
Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -158,6 +158,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true', default=False,
   help='Run clang-tidy in quiet mode')
   clang_tidy_args = []
@@ -233,6 +236,7 @@
 common_clang_tidy_args.append('-extra-arg=%s' % arg)
   for arg in args.extra_arg_before:
 common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
+  common_clang_tidy_args += args.extra_arg_clang_tidy
 
   for name in lines_by_file:
 line_filter_json = json.dumps(


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -81,8 +81,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter):
+extra_arg, extra_arg_before, extra_arg_clang_tidy,
+quiet, config, line_filter):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary, '--use-color']
   if allow_enabling_alpha_checkers:
@@ -109,6 +109,7 @@
   start.append('-quiet')
   if config:
   start.append('-config=' + config)
+  start += extra_arg_clang_tidy
   start.append(f)
   return start
 
@@ -168,7 +169,8 @@
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter)
+ args.extra_arg_clang_tidy, args.quiet,
+ args.config, args.line_filter)
 
 proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 output, err = 

[PATCH] D112008: Add -extra-arg-clang-tidy to {clang-tidy-diff,run-clang-tidy}.py

2021-10-18 Thread Xavier Roche via Phabricator via cfe-commits
Xavier added a comment.

**Note**: manually tested the two scripts;

- For `clang-tidy-diff.py`

  git diff -U0 --no-prefix --no-color $(git merge-base origin/master 
HEAD)..HEAD \
  | ~/git/llvm-project/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
-quiet -clang-tidy-binary clang-tidy-12 -path=build -j8 \
  -checks='-*,clang-analyzer-*' 
-extra-arg-clang-tidy='-warnings-as-errors=-*,clang-analyzer-*'



- For `run-clang-tidy.py`

  ~/git/llvm-project/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \
  -checks='-*,clang-analyzer-*' -clang-tidy-binary clang-tidy-12 -p build 
-extra-arg-clang-tidy='-warnings-as-errors=-*,clang-analyzer-*' 


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

https://reviews.llvm.org/D112008

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


[PATCH] D111909: [clang-tidy] DefinitionsInHeadersCheck: Added option for checking C Code

2021-10-18 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D111909#3070593 , @schrc3b6 wrote:

> I guess you don't want that to be cought if it is actually a tentative 
> definition. If I remember correctly for clang and gcc -fno-common is the 
> default.
> I think we could do one of two things here either create no warning if there 
> is a VarDelc without initialization or we could try to detect common linkage.
> I will have a look if I can detect a change from inside the checker if the 
> linkage of the variable changes via the fcommon compiler flag.

My personal belief after having encountered common linkage is that it is 
disgusting and it's good that Clang doesn't support them (by default).

But I do not have any stake or practical experience with working long term on 
//C// programs to have a well-educated opinion on this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111909

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


[PATCH] D112008: Add -extra-arg-clang-tidy to {clang-tidy-diff,run-clang-tidy}.py

2021-10-18 Thread Xavier Roche via Phabricator via cfe-commits
Xavier updated this revision to Diff 380431.

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

https://reviews.llvm.org/D112008

Files:
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -81,8 +81,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter):
+extra_arg, extra_arg_before, extra_arg_clang_tidy,
+quiet, config, line_filter):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary, '--use-color']
   if allow_enabling_alpha_checkers:
@@ -104,6 +104,7 @@
   start.append('-extra-arg=%s' % arg)
   for arg in extra_arg_before:
   start.append('-extra-arg-before=%s' % arg)
+  start += extra_arg_clang_tidy
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
@@ -168,7 +169,8 @@
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter)
+ args.extra_arg_clang_tidy, args.quiet,
+ args.config, args.line_filter)
 
 proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 output, err = proc.communicate()
@@ -241,6 +243,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true',
   help='Run clang-tidy in quiet mode')
   args = parser.parse_args()
Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -158,6 +158,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true', default=False,
   help='Run clang-tidy in quiet mode')
   clang_tidy_args = []
@@ -233,6 +236,7 @@
 common_clang_tidy_args.append('-extra-arg=%s' % arg)
   for arg in args.extra_arg_before:
 common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
+  common_clang_tidy_args += args.extra_arg_clang_tidy
 
   for name in lines_by_file:
 line_filter_json = json.dumps(


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -81,8 +81,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter):
+extra_arg, extra_arg_before, extra_arg_clang_tidy,
+quiet, config, line_filter):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary, '--use-color']
   if allow_enabling_alpha_checkers:
@@ -104,6 +104,7 @@
   start.append('-extra-arg=%s' % arg)
   for arg in extra_arg_before:
   start.append('-extra-arg-before=%s' % arg)
+  start += extra_arg_clang_tidy
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
@@ -168,7 +169,8 @@
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter)
+ args.extra_arg_clang_tidy, args.quiet,
+

[PATCH] D112008: Add -extra-arg-clang-tidy to {clang-tidy-diff,run-clang-tidy}.py

2021-10-18 Thread Xavier Roche via Phabricator via cfe-commits
Xavier updated this revision to Diff 380429.

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

https://reviews.llvm.org/D112008

Files:
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -104,6 +104,7 @@
   start.append('-extra-arg=%s' % arg)
   for arg in extra_arg_before:
   start.append('-extra-arg-before=%s' % arg)
+  start += args.extra_arg_clang_tidy
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
@@ -241,6 +242,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true',
   help='Run clang-tidy in quiet mode')
   args = parser.parse_args()
Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -158,6 +158,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true', default=False,
   help='Run clang-tidy in quiet mode')
   clang_tidy_args = []
@@ -233,6 +236,7 @@
 common_clang_tidy_args.append('-extra-arg=%s' % arg)
   for arg in args.extra_arg_before:
 common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
+  common_clang_tidy_args += args.extra_arg_clang_tidy
 
   for name in lines_by_file:
 line_filter_json = json.dumps(


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -104,6 +104,7 @@
   start.append('-extra-arg=%s' % arg)
   for arg in extra_arg_before:
   start.append('-extra-arg-before=%s' % arg)
+  start += args.extra_arg_clang_tidy
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
@@ -241,6 +242,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true',
   help='Run clang-tidy in quiet mode')
   args = parser.parse_args()
Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -158,6 +158,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true', default=False,
   help='Run clang-tidy in quiet mode')
   clang_tidy_args = []
@@ -233,6 +236,7 @@
 common_clang_tidy_args.append('-extra-arg=%s' % arg)
   for arg in args.extra_arg_before:
 common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
+  common_clang_tidy_args += args.extra_arg_clang_tidy
 
   for name in lines_by_file:
 line_filter_json = json.dumps(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111909: [clang-tidy] DefinitionsInHeadersCheck: Added option for checking C Code

2021-10-18 Thread Max Schroetter via Phabricator via cfe-commits
schrc3b6 added a comment.

In D111909#3069668 , @whisperity 
wrote:

> Will `int I;` being in a header, with no initialiser, be caught?

Currently it will be caught.

  1 warning generated.
  ./foo.h:1:5: warning: variable 'i' defined in a header file; variable 
definitions in header files can lead to ODR violations 
[misc-definitions-in-headers]
  int i;

I guess you don't want that to be cought if it is actually a tentative 
definition. If I remember correctly for clang and gcc -fno-common is the 
default.
I think we could do one of two things here either create no warning if there is 
a VarDelc without initialization or we could try to detect common linkage.
I will have a look if I can detect a change from inside the checker if the 
linkage of the variable changes via the fcommon compiler flag.

> It would be interesting to add a test for this.

I will do so.

Thanks for the feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111909

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


[PATCH] D111534: [analyzer][NFC] Refactor CallEvent::isCalled()

2021-10-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

Thank you for adding me. I'll make a deeper review later.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:1289
+  /// E.g. { "std", "vector", "data" } -> "vector", "std"
+  auto begin_qualified_name_parts() const {
+return std::next(QualifiedName.rbegin());

What rules did you use to name this functions? It seems that it goes against [[ 
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
 | LLVM naming rules]].



Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:336-352
+  const auto ExactMatchArgAndParamCounts =
+  [](const CallEvent , const CallDescription ) -> bool {
+const bool ArgsMatch =
+!CD.RequiredArgs || CD.RequiredArgs == Call.getNumArgs();
+const bool ParamsMatch =
+!CD.RequiredParams || CD.RequiredParams == Call.parameters().size();
+return ArgsMatch && ParamsMatch;

Can we move these lambdas in separate functions? IMO it could make the code 
even more readable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111534

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


[PATCH] D111870: [clangd] Add a way to enable IncludeCleaner through config

2021-10-18 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 380426.
kbobyrev added a comment.

Fix the warning range.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111870

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -67,6 +67,7 @@
 CheckOptions:
   IgnoreMacros: true
   example-check.ExampleOption: 0
+  IncludeCleaner: UnusedHeaders
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
@@ -83,6 +84,8 @@
   EXPECT_THAT(Results[3].Diagnostics.ClangTidy.CheckOptions,
   ElementsAre(PairVal("IgnoreMacros", "true"),
   PairVal("example-check.ExampleOption", "0")));
+  EXPECT_TRUE(Results[3].Diagnostics.IncludeCleaner);
+  EXPECT_EQ("UnusedHeaders", *Results[3].Diagnostics.IncludeCleaner.getValue());
 }
 
 TEST(ParseYAML, Locations) {
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -244,6 +244,25 @@
   }
 }
 
+TEST_F(ConfigCompileTests, DiagnosticsIncludeCleaner) {
+  // Defaults to None.
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.IncludeCleaner,
+Config::IncludeCleanerPolicy::None);
+
+  Frag = {};
+  Frag.Diagnostics.IncludeCleaner.emplace("None");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.IncludeCleaner,
+Config::IncludeCleanerPolicy::None);
+
+  Frag = {};
+  Frag.Diagnostics.IncludeCleaner.emplace("UnusedHeaders");
+  EXPECT_TRUE(compileAndApply());
+  EXPECT_EQ(Conf.Diagnostics.IncludeCleaner,
+Config::IncludeCleanerPolicy::UnusedHeaders);
+}
+
 TEST_F(ConfigCompileTests, DiagnosticSuppression) {
   Frag.Diagnostics.Suppress.emplace_back("bugprone-use-after-move");
   Frag.Diagnostics.Suppress.emplace_back("unreachable-code");
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -18,6 +18,7 @@
 #include "FeatureModule.h"
 #include "Headers.h"
 #include "HeuristicResolver.h"
+#include "IncludeCleaner.h"
 #include "IncludeFixer.h"
 #include "Preamble.h"
 #include "SourceCode.h"
@@ -342,6 +343,7 @@
   llvm::Optional FixIncludes;
   // No need to run clang-tidy or IncludeFixerif we are not going to surface
   // diagnostics.
+  const Config  = Config::current();
   if (PreserveDiags) {
 trace::Span Tracer("ClangTidyInit");
 tidy::ClangTidyOptions ClangTidyOpts =
@@ -366,7 +368,6 @@
   Check->registerMatchers();
 }
 
-const Config  = Config::current();
 ASTDiags.setLevelAdjuster([&](DiagnosticsEngine::Level DiagLevel,
   const clang::Diagnostic ) {
   if (Cfg.Diagnostics.SuppressAll ||
@@ -515,10 +516,16 @@
   Diags->insert(Diags->end(), D.begin(), D.end());
 }
   }
-  return ParsedAST(Inputs.Version, std::move(Preamble), std::move(Clang),
+  ParsedAST Result(Inputs.Version, std::move(Preamble), std::move(Clang),
std::move(Action), std::move(Tokens), std::move(Macros),
std::move(Marks), std::move(ParsedDecls), std::move(Diags),
std::move(Includes), std::move(CanonIncludes));
+  if (Result.Diags && Cfg.Diagnostics.IncludeCleaner ==
+  Config::IncludeCleanerPolicy::UnusedHeaders)
+for (const auto  :
+ issueUnusedIncludesDiagnostics(Result, Inputs.Contents))
+  Result.Diags->push_back(D);
+  return Result;
 }
 
 ParsedAST::ParsedAST(ParsedAST &) = default;
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -63,6 +63,9 @@
 
 std::vector computeUnusedIncludes(ParsedAST );
 
+std::vector issueUnusedIncludesDiagnostics(ParsedAST ,
+ StringRef Code);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp

[PATCH] D112008: Add -extra-arg-clang-tidy to {clang-tidy-diff,run-clang-tidy}.py

2021-10-18 Thread Xavier Roche via Phabricator via cfe-commits
Xavier created this revision.
Xavier added a reviewer: alexfh.
Xavier added a project: clang-tools-extra.
Xavier requested review of this revision.
Herald added a subscriber: cfe-commits.

This small patch adds a new `-extra-arg-clang-tidy` option to clang-tidy-diff 
and run-clang-tidy scripts. This is especially handy in addition to the 
`-checks` option, to tune the executed checks.

//Example//:

  clang-tidy-diff.py -checks='-*,clang-analyzer-*' 
-extra-arg-clang-tidy='-warnings-as-errors=-*,clang-analyzer-*'


https://reviews.llvm.org/D112008

Files:
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -104,6 +104,7 @@
   start.append('-extra-arg=%s' % arg)
   for arg in extra_arg_before:
   start.append('-extra-arg-before=%s' % arg)
+  common_clang_tidy_args += args.extra_arg_clang_tidy
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
@@ -241,6 +242,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true',
   help='Run clang-tidy in quiet mode')
   args = parser.parse_args()
Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -158,6 +158,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true', default=False,
   help='Run clang-tidy in quiet mode')
   clang_tidy_args = []
@@ -233,6 +236,7 @@
 common_clang_tidy_args.append('-extra-arg=%s' % arg)
   for arg in args.extra_arg_before:
 common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
+  common_clang_tidy_args += args.extra_arg_clang_tidy
 
   for name in lines_by_file:
 line_filter_json = json.dumps(


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -104,6 +104,7 @@
   start.append('-extra-arg=%s' % arg)
   for arg in extra_arg_before:
   start.append('-extra-arg-before=%s' % arg)
+  common_clang_tidy_args += args.extra_arg_clang_tidy
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
@@ -241,6 +242,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true',
   help='Run clang-tidy in quiet mode')
   args = parser.parse_args()
Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -158,6 +158,9 @@
   action='append', default=[],
   help='Additional argument to prepend to the compiler '
   'command line.')
+  parser.add_argument('-extra-arg-clang-tidy', dest='extra_arg_clang_tidy',
+  action='append', default=[],
+  help='Additional argument to use with clang-tidy.')
   parser.add_argument('-quiet', action='store_true', default=False,
   help='Run clang-tidy in quiet mode')
   clang_tidy_args = []
@@ -233,6 +236,7 @@
 common_clang_tidy_args.append('-extra-arg=%s' % arg)
   for arg in args.extra_arg_before:
 common_clang_tidy_args.append('-extra-arg-before=%s' % arg)
+  common_clang_tidy_args += args.extra_arg_clang_tidy
 
   for name in lines_by_file:
 line_filter_json = json.dumps(

[PATCH] D111973: [clang] Disable -clear-ast-before-backend with -print-stats

2021-10-18 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D111973#3070519 , @aeubanks wrote:

> In D111973#3069304 , @dblaikie 
> wrote:
>
>> Could you check some of the stats output is valid/expected, not just 
>> corrupt/garbage? "just doesn't crash" isn't a great criteria for a test.
>
> forgot to upload the diff, but I did so in the committed change

oh wait phab updated with the committed change, I didn't know that happened


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111973

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


  1   2   >