[PATCH] D143665: [Clang][RISCV] Guard vector int64, float32, float64 with semantic analysis

2023-02-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 497223.
eopXD added a comment.

Update code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143665

Files:
  clang/include/clang/Basic/RISCVVTypes.def
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/test/Sema/riscv-vector-float32-check.c
  clang/test/Sema/riscv-vector-float64-check.c
  clang/test/Sema/riscv-vector-int64-check.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -376,23 +376,19 @@
   printType(*T);
   }
 
-  OS << "#if (__riscv_v_elen_fp >= 32)\n";
   for (int Log2LMUL : Log2LMULs) {
 auto T = TypeCache.computeType(BasicType::Float32, Log2LMUL,
PrototypeDescriptor::Vector);
 if (T)
   printType(*T);
   }
-  OS << "#endif\n";
 
-  OS << "#if (__riscv_v_elen_fp >= 64)\n";
   for (int Log2LMUL : Log2LMULs) {
 auto T = TypeCache.computeType(BasicType::Float64, Log2LMUL,
PrototypeDescriptor::Vector);
 if (T)
   printType(*T);
   }
-  OS << "#endif\n\n";
 
   OS << "#define __riscv_v_intrinsic_overloading 1\n";
 
Index: clang/test/Sema/riscv-vector-int64-check.c
===
--- /dev/null
+++ clang/test/Sema/riscv-vector-int64-check.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +zve32x -target-feature +zfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+#include 
+
+vint64m1_t foo() { /* expected-error {{RISC-V type 'vint64m1_t' (aka '__rvv_int64m1_t') requires the 'zve64x' extension}} */
+} /* expected-warning {{non-void function does not return a value}}*/
Index: clang/test/Sema/riscv-vector-float64-check.c
===
--- /dev/null
+++ clang/test/Sema/riscv-vector-float64-check.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +zve64f -target-feature +zfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+#include 
+
+vfloat64m1_t foo() { /* expected-error {{RISC-V type 'vfloat64m1_t' (aka '__rvv_float64m1_t') requires the 'zve64d' extension}} */
+} /* expected-warning {{non-void function does not return a value}}*/
Index: clang/test/Sema/riscv-vector-float32-check.c
===
--- /dev/null
+++ clang/test/Sema/riscv-vector-float32-check.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +zve32x -target-feature +zfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+#include 
+
+vfloat32m1_t foo() { /* expected-error {{RISC-V type 'vfloat32m1_t' (aka '__rvv_float32m1_t') requires the 'zve32f' extension}} */
+} /* expected-warning {{non-void function does not return a value}}*/
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -169,8 +169,6 @@
 
 void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
   const TargetInfo &TI = Context.getTargetInfo();
-  bool HasVectorFloat32 = TI.hasFeature("zve32f");
-  bool HasVectorFloat64 = TI.hasFeature("zve64d");
   bool HasRV64 = TI.hasFeature("64bit");
   bool HasFullMultiply = TI.hasFeature("v");
 
@@ -222,12 +220,6 @@
 continue;
 
   // Check requirement.
-  if (BaseType == BasicType::Float32 && !HasVectorFloat32)
-continue;
-
-  if (BaseType == BasicType::Float64 && !HasVectorFloat64)
-continue;
-
   if (((Record.RequiredExtensions & RVV_REQ_RV64) == RVV_REQ_RV64) &&
   !HasRV64)
 continue;
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -2039,11 +2039,20 @@
 targetDiag(D->getLocation(), diag::note_defined_here, FD) << D;
 }
 
+// RISC-V vector builtin types (RISCVVTypes.def)
+if (Ty->isRVVType(/* Bitwidth */ 64, /* IsFloat */ false) &&
+!Context.getTargetInfo().hasFeature("zve64x"))
+  Diag(Loc, diag::err_riscv_type_requires_extension, FD) << Ty << "zve64x";
 if (Ty->isRVVType(/* Bitwidth */ 16, /* IsFloat */ true) &&
-!Context.getTargetInfo().hasFeature("experimental-zvfh")) {
+!Context.getTargetInfo().hasFeature("experimental-zvfh"))
   Diag(Loc, diag::err_riscv_type_requires_extension, FD)
   << 

[PATCH] D143665: [Clang][RISCV] Guard vector int64, float32, float64 with semantic analysis

2023-02-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 497224.
eopXD added a comment.

Update code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143665

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/test/Sema/riscv-vector-float32-check.c
  clang/test/Sema/riscv-vector-float64-check.c
  clang/test/Sema/riscv-vector-int64-check.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -376,23 +376,19 @@
   printType(*T);
   }
 
-  OS << "#if (__riscv_v_elen_fp >= 32)\n";
   for (int Log2LMUL : Log2LMULs) {
 auto T = TypeCache.computeType(BasicType::Float32, Log2LMUL,
PrototypeDescriptor::Vector);
 if (T)
   printType(*T);
   }
-  OS << "#endif\n";
 
-  OS << "#if (__riscv_v_elen_fp >= 64)\n";
   for (int Log2LMUL : Log2LMULs) {
 auto T = TypeCache.computeType(BasicType::Float64, Log2LMUL,
PrototypeDescriptor::Vector);
 if (T)
   printType(*T);
   }
-  OS << "#endif\n\n";
 
   OS << "#define __riscv_v_intrinsic_overloading 1\n";
 
Index: clang/test/Sema/riscv-vector-int64-check.c
===
--- /dev/null
+++ clang/test/Sema/riscv-vector-int64-check.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +zve32x -target-feature +zfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+#include 
+
+vint64m1_t foo() { /* expected-error {{RISC-V type 'vint64m1_t' (aka '__rvv_int64m1_t') requires the 'zve64x' extension}} */
+} /* expected-warning {{non-void function does not return a value}}*/
Index: clang/test/Sema/riscv-vector-float64-check.c
===
--- /dev/null
+++ clang/test/Sema/riscv-vector-float64-check.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +zve64f -target-feature +zfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+#include 
+
+vfloat64m1_t foo() { /* expected-error {{RISC-V type 'vfloat64m1_t' (aka '__rvv_float64m1_t') requires the 'zve64d' extension}} */
+} /* expected-warning {{non-void function does not return a value}}*/
Index: clang/test/Sema/riscv-vector-float32-check.c
===
--- /dev/null
+++ clang/test/Sema/riscv-vector-float32-check.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +zve32x -target-feature +zfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+#include 
+
+vfloat32m1_t foo() { /* expected-error {{RISC-V type 'vfloat32m1_t' (aka '__rvv_float32m1_t') requires the 'zve32f' extension}} */
+} /* expected-warning {{non-void function does not return a value}}*/
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -169,8 +169,6 @@
 
 void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
   const TargetInfo &TI = Context.getTargetInfo();
-  bool HasVectorFloat32 = TI.hasFeature("zve32f");
-  bool HasVectorFloat64 = TI.hasFeature("zve64d");
   bool HasRV64 = TI.hasFeature("64bit");
   bool HasFullMultiply = TI.hasFeature("v");
 
@@ -222,12 +220,6 @@
 continue;
 
   // Check requirement.
-  if (BaseType == BasicType::Float32 && !HasVectorFloat32)
-continue;
-
-  if (BaseType == BasicType::Float64 && !HasVectorFloat64)
-continue;
-
   if (((Record.RequiredExtensions & RVV_REQ_RV64) == RVV_REQ_RV64) &&
   !HasRV64)
 continue;
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -2039,11 +2039,20 @@
 targetDiag(D->getLocation(), diag::note_defined_here, FD) << D;
 }
 
+// RISC-V vector builtin types (RISCVVTypes.def)
+if (Ty->isRVVType(/* Bitwidth */ 64, /* IsFloat */ false) &&
+!Context.getTargetInfo().hasFeature("zve64x"))
+  Diag(Loc, diag::err_riscv_type_requires_extension, FD) << Ty << "zve64x";
 if (Ty->isRVVType(/* Bitwidth */ 16, /* IsFloat */ true) &&
-!Context.getTargetInfo().hasFeature("experimental-zvfh")) {
+!Context.getTargetInfo().hasFeature("experimental-zvfh"))
   Diag(Loc, diag::err_riscv_type_requires_extension, FD)
   << Ty << "zvfh";
-}
+if (Ty->isRVVType(

[PATCH] D143960: [Fuchsia] Set /winsysroot in windows runtimes linker flags

2023-02-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:91
 set(WINDOWS_LINK_FLAGS
-/vfsoverlay:${LLVM_VFSOVERLAY}
-# TODO: On Windows, linker is invoked by cmake instead of the clang-cl 
driver,
-# so we have to manually set the libpath. We use clang-cl driver if we 
can
-# and remove these libpath flags.
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
--libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
+  # TODO: lld-link has a bug that it cannot infer the machine type
+  # correctly when /winsysroot is set while Windows libraries search paths

Can you please file an LLVM issue for this and reference it here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143960

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


[PATCH] D143906: [include-cleaner] Better support ambiguous std symbols

2023-02-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks!




Comment at: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp:85
 
+Hints isPublicHeader(const FileEntry *FE, const PragmaIncludes *PI) {
+  return (PI->isPrivate(FE) || !PI->isSelfContained(FE)) ? Hints::None

we actually need to nullcheck for PI here, defaulting to PublicHeader when it 
isn't present.



Comment at: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp:86
+Hints isPublicHeader(const FileEntry *FE, const PragmaIncludes *PI) {
+  return (PI->isPrivate(FE) || !PI->isSelfContained(FE)) ? Hints::None
+ : Hints::PublicHeader;

nit: maybe unwrap this? e.g:
```
if (PI->isPrivate(..) ... ) return Hints::None;
return Hints::PublicHeader;
```



Comment at: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp:95
+Results.emplace_back(H, Hints::PublicHeader);
+for (const auto *Export : PI->getExporters(H, SM.getFileManager()))
+  Results.emplace_back(Header(Export), isPublicHeader(Export, PI));

we need to nullcheck for `PI` here



Comment at: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp:134
+  }
+  return hintedHeadersForStdHeaders(Headers, SM, PI);
+}

can you also wrap this in `applyHints(..., Hints::CompleteSymbol)`, similar to 
what `locateSymbol` does for rest of the stdlib symbols


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143906

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


[clang] 46cdf7f - [Tooling][Stdlib][NFC] Reflow comments and strip clang-format pragmas

2023-02-14 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2023-02-14T09:46:41+01:00
New Revision: 46cdf7f0991280a3601a777a80fbc460196fb033

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

LOG: [Tooling][Stdlib][NFC] Reflow comments and strip clang-format pragmas

Added: 


Modified: 
clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc

Removed: 




diff  --git a/clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc
index 7fd17ed49c72c..2733cb3f2ec4b 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc
@@ -1,6 +1,5 @@
-// These are derived from N4100[fs.filesystem.synopsis], final
-// draft for experimental filesystem.
-// clang-format off
+// These are derived from N4100[fs.filesystem.synopsis], final draft for
+// experimental filesystem.
 SYMBOL(absolute, std::experimental::filesystem::, )
 SYMBOL(canonical, std::experimental::filesystem::, )
 SYMBOL(copy, std::experimental::filesystem::, )
@@ -51,4 +50,3 @@ SYMBOL(symlink_status, std::experimental::filesystem::, 
)
 SYMBOL(temp_directory_path, std::experimental::filesystem::, 
)
 SYMBOL(u8path, std::experimental::filesystem::, )
-// clang-format on



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


[PATCH] D143906: [include-cleaner] Better support ambiguous std symbols

2023-02-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 497233.
hokein marked 2 inline comments as done.
hokein added a comment.

handle the case where PI is null.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143906

Files:
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -278,25 +278,31 @@
 
 class HeadersForSymbolTest : public FindHeadersTest {
 protected:
-  llvm::SmallVector headersForFoo() {
+  llvm::SmallVector headersFor(llvm::StringRef Name) {
 struct Visitor : public RecursiveASTVisitor {
   const NamedDecl *Out = nullptr;
+  llvm::StringRef Name;
+  Visitor(llvm::StringRef Name) : Name(Name) {}
   bool VisitNamedDecl(const NamedDecl *ND) {
-if (ND->getName() == "foo") {
+if (auto *TD = ND->getDescribedTemplate())
+  ND = TD;
+
+if (ND->getName() == Name) {
   EXPECT_TRUE(Out == nullptr || Out == ND->getCanonicalDecl())
-  << "Found multiple matches for foo.";
+  << "Found multiple matches for " << Name << ".";
   Out = cast(ND->getCanonicalDecl());
 }
 return true;
   }
 };
-Visitor V;
+Visitor V(Name);
 V.TraverseDecl(AST->context().getTranslationUnitDecl());
 if (!V.Out)
-  ADD_FAILURE() << "Couldn't find any decls named foo.";
+  ADD_FAILURE() << "Couldn't find any decls named " << Name << ".";
 assert(V.Out);
 return headersForSymbol(*V.Out, AST->sourceManager(), &PI);
   }
+  llvm::SmallVector headersForFoo() { return headersFor("foo"); }
 };
 
 TEST_F(HeadersForSymbolTest, Deduplicates) {
@@ -430,5 +436,55 @@
   EXPECT_THAT(headersForFoo(), ElementsAre(Header(StringRef("\"public.h\"")),
physicalHeader("foo.h")));
 }
+
+TEST_F(HeadersForSymbolTest, AmbiguousStdSymbols) {
+  struct {
+llvm::StringRef Code;
+llvm::StringRef Name;
+
+llvm::StringRef ExpectedHeader;
+  } TestCases[] = {
+  {
+  R"cpp(
+namespace std {
+ template 
+ constexpr OutputIt move(InputIt first, InputIt last, OutputIt dest);
+})cpp",
+  "move",
+  "",
+  },
+  {
+  R"cpp(
+namespace std {
+  template constexpr T move(T&& t) noexcept;
+})cpp",
+  "move",
+  "",
+  },
+  {
+  R"cpp(
+namespace std {
+  template
+  ForwardIt remove(ForwardIt first, ForwardIt last, const T& value);
+})cpp",
+  "remove",
+  "",
+  },
+  {
+  "namespace std { int remove(const char*); }",
+  "remove",
+  "",
+  },
+  };
+
+  for (const auto &T : TestCases) {
+Inputs.Code = T.Code;
+buildAST();
+EXPECT_THAT(headersFor(T.Name),
+UnorderedElementsAre(
+Header(*tooling::stdlib::Header::named(T.ExpectedHeader;
+  }
+}
+
 } // namespace
 } // namespace clang::include_cleaner
Index: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
===
--- clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -82,16 +82,68 @@
   llvm_unreachable("unhandled Symbol kind!");
 }
 
+Hints isPublicHeader(const FileEntry *FE, const PragmaIncludes &PI) {
+  if (PI.isPrivate(FE) || !PI.isSelfContained(FE))
+return Hints::None;
+  return Hints::PublicHeader;
+}
+
+llvm::SmallVector>
+hintedHeadersForStdHeaders(llvm::ArrayRef Headers,
+   const SourceManager &SM, const PragmaIncludes *PI) {
+  llvm::SmallVector> Results;
+  for (const auto &H : Headers) {
+Results.emplace_back(H, Hints::PublicHeader);
+if (!PI)
+  continue;
+for (const auto *Export : PI->getExporters(H, SM.getFileManager()))
+  Results.emplace_back(Header(Export), isPublicHeader(Export, *PI));
+  }
+  // StandardLibrary returns headers in preference order, so only mark the
+  // first.
+  if (!Results.empty())
+Results.front().Hint |= Hints::PreferredHeader;
+  return Results;
+}
+
+// Special-case the ambiguous standard library symbols (e.g. std::move) which
+// are not supported by the tooling stdlib lib.
+llvm::SmallVector>
+headersForSpecialSymbol(const Symbol &S, const SourceManager &SM,
+const PragmaIncludes *PI) {
+  if (S.kind() != Symbol::Declaration || !S.declaration().isInStdNamespace())
+return {};
+
+  const auto *FD = S.declaration().getAsFunction();
+  if (!FD)
+return

[PATCH] D143906: [include-cleaner] Better support ambiguous std symbols

2023-02-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

Thanks for the review!




Comment at: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp:85
 
+Hints isPublicHeader(const FileEntry *FE, const PragmaIncludes *PI) {
+  return (PI->isPrivate(FE) || !PI->isSelfContained(FE)) ? Hints::None

kadircet wrote:
> we actually need to nullcheck for PI here, defaulting to PublicHeader when it 
> isn't present.
ah, I think we can make it a reference, all callsites can guarantee the PI is 
nonnull.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143906

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


[PATCH] D127910: [Clang][AArch64][SME] Add vector load/store (ld1/st1) intrinsics

2023-02-14 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/lib/Headers/CMakeLists.txt:332
+  # Generate arm_sme.h
+  clang_generate_header(-gen-arm-sme-header arm_sme.td arm_sme.h)
   # Generate arm_bf16.h

bryanpkc wrote:
> bryanpkc wrote:
> > sdesmalen wrote:
> > > The ACLE specification is still in a draft (ALP) state, which means there 
> > > may still be subject to significant changes. To avoid users from using 
> > > this implementation with the expectation that their code is compliant 
> > > going forward, it would be good to rename the header file to something 
> > > that makes it very clear this feature is not yet ready to use. I'm 
> > > thinking of something like `arm_sme_draft_spec_subject_to_change.h`. When 
> > > the specification goes out of draft, we can rename it to `arm_sme.h`. 
> > > Could you rename the file for now?
> > Would something shorter like `arm_sme_draft.h` or `arm_sme_experimental.h` 
> > suffice?
> Renamed to `arm_sme_experimental.h`.
While `arm_sme_experimental.h` is indeed shorter, it should be unequivocally 
clear to the user that they shouldn't rely on the function prototypes defined 
in this header file yet because the specification itself is not finalised. I 
think that adding the `draft_spec_subject_to_change` to the name makes that 
more clear than `experimental`, as the latter might suggest that the support is 
not yet entirely stable or complete. There probably isn't that much to gain 
from making the user experience better by using a shorter name, if the whole 
point is to prevent people from using it for any production code. So from that 
perspective, I still have a slight preference for 
`arm_sme_draft_spec_subject_to_change.h`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127910

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


[PATCH] D143917: [clang-tidy] Clarify bugprone-branch-clone diagnostic message

2023-02-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

@donat.nagy Are you available to push the commit yourself? Otherwise I can help 
you with that, please let me know your name and email (must match those on your 
Github account) for attribution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143917

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


[clang] 1ba93c3 - [Modules] Don't re-generate template specialization in the importer

2023-02-14 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-02-14T17:15:33+08:00
New Revision: 1ba93c3c30dcdf2659e3020ba462e0025187d8e1

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

LOG: [Modules] Don't re-generate template specialization in the importer

Close https://github.com/llvm/llvm-project/issues/60693.

In this issue, we can find that the importer will try to generate the
template specialization again in the importer, which is not good and
wastes time. This patch tries to address the problem.

Added: 
clang/test/Modules/pr60693.cppm

Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Modules/pr59780.cppm

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 006063e21eb3d..0f4decc14579b 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3043,7 +3043,7 @@ class ASTContext : public RefCountedBase {
   }
 
   GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const;
-  GVALinkage GetGVALinkageForVariable(const VarDecl *VD);
+  GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const;
 
   /// Determines if the decl can be CodeGen'ed or deserialized from PCH
   /// lazily, only when used; this is only relevant for function or file scoped

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a188837d4144c..a5f7f6a019f87 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -11764,7 +11764,7 @@ static GVALinkage basicGVALinkageForVariable(const 
ASTContext &Context,
   llvm_unreachable("Invalid Linkage!");
 }
 
-GVALinkage ASTContext::GetGVALinkageForVariable(const VarDecl *VD) {
+GVALinkage ASTContext::GetGVALinkageForVariable(const VarDecl *VD) const {
   return adjustGVALinkageForExternalDefinitionKind(*this, VD,
adjustGVALinkageForAttributes(*this, VD,
  basicGVALinkageForVariable(*this, VD)));

diff  --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index 9e1e58a7fa7e2..69d192612bccf 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1068,7 +1068,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
   if (D->getStorageDuration() == SD_Static) {
 bool ModulesCodegen = false;
 if (Writer.WritingModule &&
-!D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo()) {
+!D->getDescribedVarTemplate()) {
   // When building a C++20 module interface unit or a partition unit, a
   // strong definition in the module interface is provided by the
   // compilation of that unit, not by its users. (Inline variables are 
still
@@ -1077,7 +1077,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
   (Writer.WritingModule->isInterfaceOrPartition() ||
(D->hasAttr() &&
 Writer.Context->getLangOpts().BuildingPCHWithObjectFile)) &&
-  Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal;
+   Writer.Context->GetGVALinkageForVariable(D) >= GVA_StrongExternal;
 }
 Record.push_back(ModulesCodegen);
 if (ModulesCodegen)
@@ -2550,7 +2550,7 @@ void ASTRecordWriter::AddFunctionDefinition(const 
FunctionDecl *FD) {
   // compilation of that unit, not by its users. (Inline functions are 
still
   // emitted in module users.)
   Linkage = Writer->Context->GetGVALinkageForFunction(FD);
-  ModulesCodegen = *Linkage == GVA_StrongExternal;
+  ModulesCodegen = *Linkage >= GVA_StrongExternal;
 }
 if (Writer->Context->getLangOpts().ModulesCodegen ||
 (FD->hasAttr() &&

diff  --git a/clang/test/Modules/pr59780.cppm b/clang/test/Modules/pr59780.cppm
index 9578325b976ba..d4bbd52c13f1a 100644
--- a/clang/test/Modules/pr59780.cppm
+++ b/clang/test/Modules/pr59780.cppm
@@ -33,8 +33,8 @@ struct Y {
 
 int Y::value = 0;
 
-// CHECK-NOT: @_ZW1a1xIiE = {{.*}}available_externally{{.*}}global
-// CHECK-NOT: @_ZNW1a1YIiE5valueE = {{.*}}available_externally{{.*}}global
+// CHECK-NOT: @_ZW1a1xIiE = {{.*}}external{{.*}}global
+// CHECK-NOT: @_ZNW1a1YIiE5valueE = {{.*}}external{{.*}}global
 
 //--- use.cpp
 import a;
@@ -42,5 +42,5 @@ int foo() {
 return x + Y::value;
 }
 
-// CHECK: @_ZW1a1xIiE = {{.*}}available_externally{{.*}}global
-// CHECK: @_ZNW1a1YIiE5valueE = {{.*}}available_externally{{.*}}global
+// CHECK: @_ZW1a1xIiE = {{.*}}external{{.*}}global
+// CHECK: @_ZNW1a1YIiE5valueE = {{.*}}external{{.*}}global

diff  --git a/clang/test/Modules/pr60693.cppm b/clang/test/Modules/pr60693.cppm
new file mode 100644
index 0..117a0f2753d0a
--- /dev/null
+++ b/clang/test/Modules/pr60693.cppm
@@ -0,0 +1,54 @@
+/

[PATCH] D142893: [NFC] Class for building MultilibSet

2023-02-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/include/clang/Driver/MultilibBuilder.h:117
+  /// Add an optional Multilib segment
+  MultilibSetBuilder &Maybe(const MultilibBuilder &M);
+

MaskRay wrote:
> Use `camelCase` for new function names.
These functions were copies from the existing `MultilibSet` class so I'm fine 
keeping the original names to reduce the amount of changes. If we decide to 
change the names, it would ideally be done in a follow up change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142893

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


[clang-tools-extra] 504aa8a - [include-cleaner] Better support ambiguous std symbols

2023-02-14 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-02-14T10:18:38+01:00
New Revision: 504aa8ae941ea8e09b89a91cfbbbeb8a7b8fdc24

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

LOG: [include-cleaner] Better support ambiguous std symbols

By special-casing them at the moment. The tooling stdlib lib doesn't
support these symbols (most important one is std::move).

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

Added: 


Modified: 
clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp 
b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
index 030ce61701494..ae2a3a858a38c 100644
--- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -82,16 +82,68 @@ llvm::StringRef symbolName(const Symbol &S) {
   llvm_unreachable("unhandled Symbol kind!");
 }
 
+Hints isPublicHeader(const FileEntry *FE, const PragmaIncludes &PI) {
+  if (PI.isPrivate(FE) || !PI.isSelfContained(FE))
+return Hints::None;
+  return Hints::PublicHeader;
+}
+
+llvm::SmallVector>
+hintedHeadersForStdHeaders(llvm::ArrayRef Headers,
+   const SourceManager &SM, const PragmaIncludes *PI) {
+  llvm::SmallVector> Results;
+  for (const auto &H : Headers) {
+Results.emplace_back(H, Hints::PublicHeader);
+if (!PI)
+  continue;
+for (const auto *Export : PI->getExporters(H, SM.getFileManager()))
+  Results.emplace_back(Header(Export), isPublicHeader(Export, *PI));
+  }
+  // StandardLibrary returns headers in preference order, so only mark the
+  // first.
+  if (!Results.empty())
+Results.front().Hint |= Hints::PreferredHeader;
+  return Results;
+}
+
+// Special-case the ambiguous standard library symbols (e.g. std::move) which
+// are not supported by the tooling stdlib lib.
+llvm::SmallVector>
+headersForSpecialSymbol(const Symbol &S, const SourceManager &SM,
+const PragmaIncludes *PI) {
+  if (S.kind() != Symbol::Declaration || !S.declaration().isInStdNamespace())
+return {};
+
+  const auto *FD = S.declaration().getAsFunction();
+  if (!FD)
+return {};
+
+  llvm::StringRef FName = FD->getName();
+  llvm::SmallVector Headers;
+  if (FName == "move") {
+if (FD->getNumParams() == 1)
+  // move(T&& t)
+  Headers.push_back(*tooling::stdlib::Header::named(""));
+if (FD->getNumParams() == 3)
+  // move(InputIt first, InputIt last, OutputIt dest);
+  Headers.push_back(*tooling::stdlib::Header::named(""));
+  } else if (FName == "remove") {
+if (FD->getNumParams() == 1)
+  // remove(const char*);
+  Headers.push_back(*tooling::stdlib::Header::named(""));
+if (FD->getNumParams() == 3)
+  // remove(ForwardIt first, ForwardIt last, const T& value);
+  Headers.push_back(*tooling::stdlib::Header::named(""));
+  }
+  return applyHints(hintedHeadersForStdHeaders(Headers, SM, PI),
+Hints::CompleteSymbol);
+}
+
 } // namespace
 
 llvm::SmallVector> findHeaders(const SymbolLocation &Loc,
   const SourceManager &SM,
   const PragmaIncludes *PI) {
-  auto IsPublicHeader = [&PI](const FileEntry *FE) {
-return (PI->isPrivate(FE) || !PI->isSelfContained(FE))
-   ? Hints::None
-   : Hints::PublicHeader;
-  };
   llvm::SmallVector> Results;
   switch (Loc.kind()) {
   case SymbolLocation::Physical: {
@@ -102,11 +154,11 @@ llvm::SmallVector> findHeaders(const 
SymbolLocation &Loc,
 if (!PI)
   return {{FE, Hints::PublicHeader}};
 while (FE) {
-  Hints CurrentHints = IsPublicHeader(FE);
+  Hints CurrentHints = isPublicHeader(FE, *PI);
   Results.emplace_back(FE, CurrentHints);
   // FIXME: compute transitive exporter headers.
   for (const auto *Export : PI->getExporters(FE, SM.getFileManager()))
-Results.emplace_back(Export, IsPublicHeader(Export));
+Results.emplace_back(Export, isPublicHeader(Export, *PI));
 
   if (auto Verbatim = PI->getPublic(FE); !Verbatim.empty()) {
 Results.emplace_back(Verbatim,
@@ -123,16 +175,7 @@ llvm::SmallVector> findHeaders(const 
SymbolLocation &Loc,
 return Results;
   }
   case SymbolLocation::Standard: {
-for (const auto &H : Loc.standard().headers()) {
-  Results.emplace_back(H, Hints::PublicHeader);
-  for (const auto *Export : PI->getExporters(H, SM.getFileManager()))
-Results.emplace_back(Header(Export), IsPublicHeader(Export));
-}
-// StandardLibrary returns headers in preference order, so only mark the
-// first.
-if (!Results.empty())
-  

[PATCH] D143906: [include-cleaner] Better support ambiguous std symbols

2023-02-14 Thread Haojian Wu 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 rG504aa8ae941e: [include-cleaner] Better support ambiguous std 
symbols (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143906

Files:
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -278,25 +278,31 @@
 
 class HeadersForSymbolTest : public FindHeadersTest {
 protected:
-  llvm::SmallVector headersForFoo() {
+  llvm::SmallVector headersFor(llvm::StringRef Name) {
 struct Visitor : public RecursiveASTVisitor {
   const NamedDecl *Out = nullptr;
+  llvm::StringRef Name;
+  Visitor(llvm::StringRef Name) : Name(Name) {}
   bool VisitNamedDecl(const NamedDecl *ND) {
-if (ND->getName() == "foo") {
+if (auto *TD = ND->getDescribedTemplate())
+  ND = TD;
+
+if (ND->getName() == Name) {
   EXPECT_TRUE(Out == nullptr || Out == ND->getCanonicalDecl())
-  << "Found multiple matches for foo.";
+  << "Found multiple matches for " << Name << ".";
   Out = cast(ND->getCanonicalDecl());
 }
 return true;
   }
 };
-Visitor V;
+Visitor V(Name);
 V.TraverseDecl(AST->context().getTranslationUnitDecl());
 if (!V.Out)
-  ADD_FAILURE() << "Couldn't find any decls named foo.";
+  ADD_FAILURE() << "Couldn't find any decls named " << Name << ".";
 assert(V.Out);
 return headersForSymbol(*V.Out, AST->sourceManager(), &PI);
   }
+  llvm::SmallVector headersForFoo() { return headersFor("foo"); }
 };
 
 TEST_F(HeadersForSymbolTest, Deduplicates) {
@@ -430,5 +436,55 @@
   EXPECT_THAT(headersForFoo(), ElementsAre(Header(StringRef("\"public.h\"")),
physicalHeader("foo.h")));
 }
+
+TEST_F(HeadersForSymbolTest, AmbiguousStdSymbols) {
+  struct {
+llvm::StringRef Code;
+llvm::StringRef Name;
+
+llvm::StringRef ExpectedHeader;
+  } TestCases[] = {
+  {
+  R"cpp(
+namespace std {
+ template 
+ constexpr OutputIt move(InputIt first, InputIt last, OutputIt dest);
+})cpp",
+  "move",
+  "",
+  },
+  {
+  R"cpp(
+namespace std {
+  template constexpr T move(T&& t) noexcept;
+})cpp",
+  "move",
+  "",
+  },
+  {
+  R"cpp(
+namespace std {
+  template
+  ForwardIt remove(ForwardIt first, ForwardIt last, const T& value);
+})cpp",
+  "remove",
+  "",
+  },
+  {
+  "namespace std { int remove(const char*); }",
+  "remove",
+  "",
+  },
+  };
+
+  for (const auto &T : TestCases) {
+Inputs.Code = T.Code;
+buildAST();
+EXPECT_THAT(headersFor(T.Name),
+UnorderedElementsAre(
+Header(*tooling::stdlib::Header::named(T.ExpectedHeader;
+  }
+}
+
 } // namespace
 } // namespace clang::include_cleaner
Index: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
===
--- clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -82,16 +82,68 @@
   llvm_unreachable("unhandled Symbol kind!");
 }
 
+Hints isPublicHeader(const FileEntry *FE, const PragmaIncludes &PI) {
+  if (PI.isPrivate(FE) || !PI.isSelfContained(FE))
+return Hints::None;
+  return Hints::PublicHeader;
+}
+
+llvm::SmallVector>
+hintedHeadersForStdHeaders(llvm::ArrayRef Headers,
+   const SourceManager &SM, const PragmaIncludes *PI) {
+  llvm::SmallVector> Results;
+  for (const auto &H : Headers) {
+Results.emplace_back(H, Hints::PublicHeader);
+if (!PI)
+  continue;
+for (const auto *Export : PI->getExporters(H, SM.getFileManager()))
+  Results.emplace_back(Header(Export), isPublicHeader(Export, *PI));
+  }
+  // StandardLibrary returns headers in preference order, so only mark the
+  // first.
+  if (!Results.empty())
+Results.front().Hint |= Hints::PreferredHeader;
+  return Results;
+}
+
+// Special-case the ambiguous standard library symbols (e.g. std::move) which
+// are not supported by the tooling stdlib lib.
+llvm::SmallVector>
+headersForSpecialSymbol(const Symbol &S, const SourceManager &SM,
+const PragmaIncludes *PI) {
+  if (S.kind() != Symbol::Declaration || !S.declaration().isInStdNamespace())

[clang-tools-extra] 64dad4b - Use llvm::bit_cast (NFC)

2023-02-14 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-02-14T01:22:12-08:00
New Revision: 64dad4ba9af603330458a7673e39a873afdf3d4d

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

LOG: Use llvm::bit_cast (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/Quality.cpp
llvm/include/llvm/ADT/APInt.h
llvm/include/llvm/Support/EndianStream.h
llvm/lib/BinaryFormat/MsgPackReader.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
llvm/lib/Target/AMDGPU/MCTargetDesc/SIMCCodeEmitter.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index 318488f269f8c..8840f805f0e87 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -538,7 +538,7 @@ static uint32_t encodeFloat(float F) {
   constexpr uint32_t TopBit = ~(~uint32_t{0} >> 1);
 
   // Get the bits of the float. Endianness is the same as for integers.
-  uint32_t U = llvm::FloatToBits(F);
+  uint32_t U = llvm::bit_cast(F);
   // IEEE 754 floats compare like sign-magnitude integers.
   if (U & TopBit)// Negative float.
 return 0 - U;// Map onto the low half of integers, order reversed.

diff  --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 83734c4fc11cf..9eabccdbdb87c 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -1665,7 +1665,7 @@ class [[nodiscard]] APInt {
   /// The conversion does not do a translation from integer to double, it just
   /// re-interprets the bits as a double. Note that it is valid to do this on
   /// any bit width. Exactly 64 bits will be translated.
-  double bitsToDouble() const { return BitsToDouble(getWord(0)); }
+  double bitsToDouble() const { return llvm::bit_cast(getWord(0)); }
 
   /// Converts APInt bits to a float
   ///
@@ -1673,7 +1673,7 @@ class [[nodiscard]] APInt {
   /// re-interprets the bits as a float. Note that it is valid to do this on
   /// any bit width. Exactly 32 bits will be translated.
   float bitsToFloat() const {
-return BitsToFloat(static_cast(getWord(0)));
+return llvm::bit_cast(static_cast(getWord(0)));
   }
 
   /// Converts a double to APInt bits.
@@ -1681,7 +1681,7 @@ class [[nodiscard]] APInt {
   /// The conversion does not do a translation from double to integer, it just
   /// re-interprets the bits of the double.
   static APInt doubleToBits(double V) {
-return APInt(sizeof(double) * CHAR_BIT, DoubleToBits(V));
+return APInt(sizeof(double) * CHAR_BIT, llvm::bit_cast(V));
   }
 
   /// Converts a float to APInt bits.
@@ -1689,7 +1689,7 @@ class [[nodiscard]] APInt {
   /// The conversion does not do a translation from float to integer, it just
   /// re-interprets the bits of the float.
   static APInt floatToBits(float V) {
-return APInt(sizeof(float) * CHAR_BIT, FloatToBits(V));
+return APInt(sizeof(float) * CHAR_BIT, llvm::bit_cast(V));
   }
 
   /// @}

diff  --git a/llvm/include/llvm/Support/EndianStream.h 
b/llvm/include/llvm/Support/EndianStream.h
index ed941c61fbebc..d2289ccfa8932 100644
--- a/llvm/include/llvm/Support/EndianStream.h
+++ b/llvm/include/llvm/Support/EndianStream.h
@@ -32,13 +32,13 @@ inline void write(raw_ostream &os, value_type value, 
endianness endian) {
 
 template <>
 inline void write(raw_ostream &os, float value, endianness endian) {
-  write(os, FloatToBits(value), endian);
+  write(os, llvm::bit_cast(value), endian);
 }
 
 template <>
 inline void write(raw_ostream &os, double value,
   endianness endian) {
-  write(os, DoubleToBits(value), endian);
+  write(os, llvm::bit_cast(value), endian);
 }
 
 template 

diff  --git a/llvm/lib/BinaryFormat/MsgPackReader.cpp 
b/llvm/lib/BinaryFormat/MsgPackReader.cpp
index 146edaa95b81e..2599d75efa084 100644
--- a/llvm/lib/BinaryFormat/MsgPackReader.cpp
+++ b/llvm/lib/BinaryFormat/MsgPackReader.cpp
@@ -74,7 +74,8 @@ Expected Reader::read(Object &Obj) {
   return make_error(
   "Invalid Float32 with insufficient payload",
   std::make_error_code(std::errc::invalid_argument));
-Obj.Float = BitsToFloat(endian::read(Current));
+Obj.Float =
+llvm::b

[PATCH] D143989: [AArch64][NFC] Rename AEK_SMEF64 and AEK_SMEI64 feature flags

2023-02-14 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
CarolineConcatto requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update clang feature flag names for:
AEK_SMEF6  to AEK_SMEF64F64
and
AEK_SMEI64 to AEK_SMEI16I64
These feature flags had their name changed in this previous patch
 https://reviews.llvm.org/D135974


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143989

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h


Index: clang/lib/Basic/Targets/AArch64.h
===
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -64,8 +64,8 @@
   bool HasCCDP = false;
   bool HasFRInt3264 = false;
   bool HasSME = false;
-  bool HasSMEF64 = false;
-  bool HasSMEI64 = false;
+  bool HasSMEF64F64 = false;
+  bool HasSMEI16I64 = false;
   bool HasSB = false;
   bool HasPredRes = false;
   bool HasSSBS = false;
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -663,8 +663,8 @@
   .Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
   .Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
   .Case("sme", HasSME)
-  .Case("sme-f64f64", HasSMEF64)
-  .Case("sme-i16i64", HasSMEI64)
+  .Case("sme-f64f64", HasSMEF64F64)
+  .Case("sme-i16i64", HasSMEI16I64)
   .Cases("memtag", "memtag2", HasMTE)
   .Case("sb", HasSB)
   .Case("predres", HasPredRes)
@@ -780,12 +780,12 @@
 }
 if (Feature == "+sme-f64f64") {
   HasSME = true;
-  HasSMEF64 = true;
+  HasSMEF64F64 = true;
   HasBFloat16 = true;
 }
 if (Feature == "+sme-i16i64") {
   HasSME = true;
-  HasSMEI64 = true;
+  HasSMEI16I64 = true;
   HasBFloat16 = true;
 }
 if (Feature == "+sb")


Index: clang/lib/Basic/Targets/AArch64.h
===
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -64,8 +64,8 @@
   bool HasCCDP = false;
   bool HasFRInt3264 = false;
   bool HasSME = false;
-  bool HasSMEF64 = false;
-  bool HasSMEI64 = false;
+  bool HasSMEF64F64 = false;
+  bool HasSMEI16I64 = false;
   bool HasSB = false;
   bool HasPredRes = false;
   bool HasSSBS = false;
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -663,8 +663,8 @@
   .Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
   .Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
   .Case("sme", HasSME)
-  .Case("sme-f64f64", HasSMEF64)
-  .Case("sme-i16i64", HasSMEI64)
+  .Case("sme-f64f64", HasSMEF64F64)
+  .Case("sme-i16i64", HasSMEI16I64)
   .Cases("memtag", "memtag2", HasMTE)
   .Case("sb", HasSB)
   .Case("predres", HasPredRes)
@@ -780,12 +780,12 @@
 }
 if (Feature == "+sme-f64f64") {
   HasSME = true;
-  HasSMEF64 = true;
+  HasSMEF64F64 = true;
   HasBFloat16 = true;
 }
 if (Feature == "+sme-i16i64") {
   HasSME = true;
-  HasSMEI64 = true;
+  HasSMEI16I64 = true;
   HasBFloat16 = true;
 }
 if (Feature == "+sb")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142932: [NFC] Multilib YAML parsing

2023-02-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

For the existing YAML files within LLVM, we most commonly used the `PascalCase` 
for field names and less commonly `lisp-case`. This change uses `camelCase` 
which is unusual and unless there's a particular reason for using this scheme 
such as compatibility with an existing format, I'd prefer keeping the format 
consistent with the rest of LLVM and using `PascalCase` or `lisp-case`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142932

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


[clang] 6240627 - [docs] Fix bullet list formatting

2023-02-14 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2023-02-14T19:14:03+09:00
New Revision: 6240627cfda444550975ccaea20a3b6d68c9ad15

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

LOG: [docs] Fix bullet list formatting

reST requires an empty line before a bullet list.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 20c8bb5de044..99f8cd59abec 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -797,6 +797,7 @@ emulation.
 ``_Float16`` will be supported on more targets as they define ABIs for it.
 
 ``__bf16`` is purely a storage format; it is currently only supported on the 
following targets:
+
 * 32-bit ARM
 * 64-bit ARM (AArch64)
 * X86 (see below)



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


[clang] e8d4484 - [docs] Update the ACLE URL

2023-02-14 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2023-02-14T19:14:04+09:00
New Revision: e8d44841c5d5f1e7ca2013ab2ae23bb4cec45d1e

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

LOG: [docs] Update the ACLE URL

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 99f8cd59abec..faebc024df11 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -808,7 +808,7 @@ includes all 64-bit and all recent 32-bit processors.
 ``__fp16`` is a storage and interchange format only.  This means that values of
 ``__fp16`` are immediately promoted to (at least) ``float`` when used in 
arithmetic
 operations, so that e.g. the result of adding two ``__fp16`` values has type 
``float``.
-The behavior of ``__fp16`` is specified by the ARM C Language Extensions 
(`ACLE 
`_).
+The behavior of ``__fp16`` is specified by the Arm C Language Extensions 
(`ACLE `_).
 Clang uses the ``binary16`` format from IEEE 754-2008 for ``__fp16``, not the 
ARM
 alternative format.
 
@@ -3791,8 +3791,8 @@ ARM/AArch64 Language Extensions
 Memory Barrier Intrinsics
 ^
 Clang implements the ``__dmb``, ``__dsb`` and ``__isb`` intrinsics as defined
-in the `ARM C Language Extensions Release 2.0
-`_.
+in the `Arm C Language Extensions
+`_.
 Note that these intrinsics are implemented as motion barriers that block
 reordering of memory accesses and side effect instructions. Other instructions
 like simple arithmetic may be reordered around the intrinsic. If you expect to



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


[PATCH] D142473: [UTC] Add --version argument

2023-02-14 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Sorry, I did not interpret those comments as blocking concerns. Happy to revert 
this if they were intended as such -- this is effectively an NFC patch until 
DEFAULT_VERSION gets bumped, so we can still backtrack to a different approach 
(though I'm not aware of any that would have less maintenance burden).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142473

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


[PATCH] D137526: [C++20] [Modules] [NFC] Add Preprocessor methods for named modules - for ClangScanDeps (1/4)

2023-02-14 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

It looks like this causes a minor compile-time regression (about 0.2% on `O0` 
builds): 
http://llvm-compile-time-tracker.com/compare.php?from=ad81d019a62d33e5d1f232844b83d3e164e4b160&to=6470706bc0ed2425704bc8c9e121a72e2d272616&stat=instructions:u

I wanted to check whether this is expected (as I don't think CTMark even 
compiles anything in C++20 mode).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137526

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


[PATCH] D143825: [clang-format] Put ports on separate lines in Verilog module headers

2023-02-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2836
+  Tok = Tok->getNextNonComment();
+  } else if (Tok->is(tok::hashhash)) {
+// Concatenation. Skip.

are we covering these cases in the unit tests



Comment at: clang/lib/Format/TokenAnnotator.cpp:2846
+// The name may have dots like `interface_foo.modport_foo`.
+while (Tok != nullptr && Tok->isOneOf(tok::period, tok::coloncolon) &&
+   (Tok = Tok->getNextNonComment())) {

are we covering these cases in the unit tests



Comment at: clang/lib/Format/TokenAnnotator.cpp:4365
+if (Right.is(tok::l_paren) && Right.is(TT_VerilogStrength))
+  return true;
   }

Is this an unrelated change? if not can you add an test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143825

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


[PATCH] D143755: [clang-format] Add a space between an overloaded operator and '>'

2023-02-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D143755

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


[PATCH] D143630: [clang] update test case

2023-02-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Added  Nikita as reviewer, since this is about opaque pointers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143630

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


[PATCH] D143996: [clang-tidy][doc] Remove unused variable

2023-02-14 Thread Björn Svensson via Phabricator via cfe-commits
bjosv created this revision.
Herald added subscribers: kbarton, xazax.hun, nemanjai.
Herald added a reviewer: njames93.
Herald added a project: All.
bjosv requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Remove mention of a variable that is not used in the example for checker:
cppcoreguidelines-avoid-non-const-global-variables


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143996

Files:
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst


Index: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
@@ -32,7 +32,7 @@
 char h = 0;
 };
 
-Variables: ``a``, ``c``, ``c_ptr1``, ``c_ptr2``, ``c_const_ptr`` and
+Variables: ``a``, ``c``, ``c_ptr1``, ``c_const_ptr`` and
 ``c_reference``, will all generate warnings since they are either:
 a globally accessible variable and non-const, a pointer or reference providing
 global access to non-const data or both.


Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
@@ -32,7 +32,7 @@
 char h = 0;
 };
 
-Variables: ``a``, ``c``, ``c_ptr1``, ``c_ptr2``, ``c_const_ptr`` and
+Variables: ``a``, ``c``, ``c_ptr1``, ``c_const_ptr`` and
 ``c_reference``, will all generate warnings since they are either:
 a globally accessible variable and non-const, a pointer or reference providing
 global access to non-const data or both.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143630: [clang] update test case

2023-02-14 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Hm, I don't think the clang/test/CodeGen/X86/x86-builtins-intrinsic.cl file 
exists on current main? Is this based on top of some other patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143630

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


[PATCH] D122573: [TBAA] Emit distinct TBAA tags for pointers with different depths,types.

2023-02-14 Thread Biplob Mishra via Phabricator via cfe-commits
bipmis added a comment.
Herald added a subscriber: StephenFan.

@fhahn We are also observing scenarios where this maybe necessary. A couple of 
points on where it may be missing

1. createScalarTypeNode(OutName, AnyPtr, Size) -> This will generate different 
Base type. However the accessTy being "any pointer" , the check "access to the 
base object is through a field of the subobject's type" will return alias as we 
traverse from BaseTag Node until we reach Root or we find a SubobjectTag 
BaseType. In this case the match would be true on "any pointer". Can this be 
potentially be thought of as  createScalarTypeNode(OutName, getChar(), Size) as 
a pointer type can edge to char?

2. The pointer type is restricted to isa(Ty). There can be 
potential scenarios where we may want pointer to struct or class.

I can provide some examples if that would be helpful. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122573

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


[PATCH] D143917: [clang-tidy] Clarify bugprone-branch-clone diagnostic message

2023-02-14 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

Thanks for the feedback! I can push the commit and I'll do so after a few days 
(if no changes are suggested).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143917

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


[PATCH] D142630: [clang][Interp] Implement virtual function calls

2023-02-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 497276.

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

https://reviews.llvm.org/D142630

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Context.h
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Function.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpState.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/Pointer.h
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++14 -verify %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify %s
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple i686 -verify %s
 // RUN: %clang_cc1 -verify=ref %s
 // RUN: %clang_cc1 -verify=ref -std=c++14 %s
+// RUN: %clang_cc1 -verify=ref -std=c++20 %s
 // RUN: %clang_cc1 -verify=ref -triple i686 %s
 
 struct BoolPair {
@@ -286,6 +288,7 @@
 };
 
 namespace DeriveFailures {
+#if __cplusplus < 202002L
   struct Base { // ref-note 2{{declared here}}
 int Val;
   };
@@ -301,10 +304,12 @@
// ref-note {{in call to 'Derived(12)'}} \
// ref-note {{declared here}} \
// expected-error {{must be initialized by a constant expression}}
+
   static_assert(D.Val == 0, ""); // ref-error {{not an integral constant expression}} \
  // ref-note {{initializer of 'D' is not a constant expression}} \
  // expected-error {{not an integral constant expression}} \
  // expected-note {{read of object outside its lifetime}}
+#endif
 
   struct AnotherBase {
 int Val;
@@ -354,3 +359,121 @@
   static_assert(getS(true).a == 12, "");
   static_assert(getS(false).a == 13, "");
 };
+
+#if __cplusplus >= 202002L
+namespace VirtualCalls {
+namespace Obvious {
+
+  class A {
+  public:
+constexpr A(){}
+constexpr virtual int foo() {
+  return 3;
+}
+  };
+  class B : public A {
+  public:
+constexpr int foo() override {
+  return 6;
+}
+  };
+
+  constexpr int getFooB(bool b) {
+A *a;
+A myA;
+B myB;
+
+if (b)
+  a = &myA;
+else
+  a = &myB;
+
+return a->foo();
+  }
+  static_assert(getFooB(true) == 3, "");
+  static_assert(getFooB(false) == 6, "");
+}
+
+namespace MultipleBases {
+  class A {
+  public:
+constexpr virtual int getInt() const { return 10; }
+  };
+  class B {
+  public:
+  };
+  class C : public A, public B {
+  public:
+constexpr int getInt() const override { return 20; }
+  };
+
+  constexpr int callGetInt(const A& a) { return a.getInt(); }
+  static_assert(callGetInt(C()) == 20, "");
+  static_assert(callGetInt(A()) == 10, "");
+}
+
+namespace Destructors {
+  class Base {
+  public:
+int i;
+constexpr Base(int &i) : i(i) {i++;}
+constexpr virtual ~Base() {i--;}
+  };
+
+  class Derived : public Base {
+  public:
+constexpr Derived(int &i) : Base(i) {}
+constexpr virtual ~Derived() {i--;}
+  };
+
+  constexpr int test() {
+int i = 0;
+Derived d(i);
+return i;
+  }
+  static_assert(test() == 1);
+}
+
+
+namespace QualifiedCalls {
+  class A {
+  public:
+  constexpr virtual int foo() const {
+  return 5;
+  }
+  };
+  class B : public A {};
+  class C : public B {
+  public:
+  constexpr int foo() const override {
+  return B::foo(); // B doesn't have a foo(), so this should call A::foo().
+  }
+  constexpr int foo2() const {
+return this->A::foo();
+  }
+  };
+  constexpr C c;
+  static_assert(c.foo() == 5);
+  static_assert(c.foo2() == 5);
+
+
+  struct S {
+int _c = 0;
+virtual constexpr int foo() const { return 1; }
+  };
+
+  struct SS : S {
+int a;
+constexpr SS() {
+  a = S::foo();
+}
+constexpr int foo() const override {
+  return S::foo();
+}
+  };
+
+  constexpr SS ss;
+  static_assert(ss.a == 1);
+}
+};
+#endif
Index: clang/lib/AST/Interp/Pointer.h
===
--- clang/lib/AST/Interp/Pointer.h
+++ clang/lib/AST/Interp/Pointer.h
@@ -206,6 +206,8 @@
   /// Returns the type of the innermost field.
   QualType getType() const { return getFieldDesc()->getType(); }
 
+  Pointer getDeclPtr() const { return Pointer(Pointee); }
+
   /// Returns the element size of the innermost field.
   size_t elemSize() const {
 if (Base == RootPtrMark)
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Inte

[PATCH] D142630: [clang][Interp] Implement virtual function calls

2023-02-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:1560
+  // is the furthest we might go up in the hierarchy.
+  ThisPtr = ThisPtr.getDeclPtr();
+}

I think this test case was from the function pointer review, but this fixes:
```
struct S {
  virtual constexpr int func() const { return 1; }
};

struct Middle : S {
  constexpr Middle(int i) : i(i) {}
  int i;
};

struct Other {
  constexpr Other(int k) : k(k) {}
  int k;
};

struct S2 : Middle, Other {
  int j;
  constexpr S2(int i, int j, int k) : Middle(i), Other(k), j(j) {}
  virtual constexpr int func() const { return i + j + k  + S::func(); }
};


constexpr S s;
constexpr decltype(&S::func) foo = &S::func;
constexpr S2 s2(1, 2, 3);
constexpr int value3 = (s2.*foo)();
```

even I am confused by all of this now, so the comment might not be the clearest 
:)

(I did not add that test case since it needs other changes in`classify()` and 
`VisitBinaryOperator()`, but can do that in a follow-up commit.)


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

https://reviews.llvm.org/D142630

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


[PATCH] D143418: [libclang] Add API to set preferred temp dir path

2023-02-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D143418#4125098 , @vedgy wrote:

>> `uint32_t Size; // = sizeof(struct CIndexOptions), used for option 
>> versioning`
>
> 1. `uint32_t` was introduced in C99. Can/should it be used in //Index.h//? 
> Only built-in `[unsigned] (int|long)` types are currently used in this file.

That is a really good question. I couldn't spot anything existing in the header 
file that requires C99 or later (no // comments, no C99 types like _Bool or 
uint32_t, etc). I think the common pattern would be to use `unsigned`, which is 
also variably-sized (as are all the integer types, technically, thanks to 
CHAR_BIT), but we do have one existing use of `size_t` in the file, which is 
probably the best type to use there given that we expect people to assign the 
results of `sizeof` into it. WDYT about using `size_t`?

I don't have the historical context to know whether we expect this header to be 
C89 compatible, so it's not clear to me how disruptive it would be to use 
stdint.h. One alternative would be to use stdint.h if it's available (via 
`__has_include`) and otherwise fallback on a C89 custom definition of uint32_t, 
but that strikes me as being more likely to introduce problems on systems we 
don't test on or for compilers we don't test with.

> 2. Should `int excludeDeclarationsFromPCH` and `int displayDiagnostics` 
> currently passed to `clang_createIndex()` also be included in the struct? 
> Then only a single argument will be passed to 
> `clang_createIndexWithOptions()`: `CXIndexOptions`.

I think that makes sense to me. It does raise the question of whether we want 
to pack these boolean-like fields together, as in:

  struct CXIndexOptions {
size_t Size;
  
int ExcludeDeclsFromPCH : 1;
int DisplayDiagnostics : 1;
int Reserved : 30;
  
const char *PreambleStoragePath;
...
  };

This makes it a little less likely to need to grow the structure when adding 
new options.

> 3. `clang_createIndex()` initializes global options based on environment 
> variable values:
>
>   if (getenv("LIBCLANG_BGPRIO_INDEX"))
>   CIdxr->setCXGlobalOptFlags(CIdxr->getCXGlobalOptFlags() |
>  
> CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
> if (getenv("LIBCLANG_BGPRIO_EDIT"))
>   CIdxr->setCXGlobalOptFlags(CIdxr->getCXGlobalOptFlags() |
>  
> CXGlobalOpt_ThreadBackgroundPriorityForEditing);
>
> The recommended in documentation usage of `clang_CXIndex_setGlobalOptions` is:
>
>   * \code
>   * CXIndex idx = ...;
>   * clang_CXIndex_setGlobalOptions(idx,
>   * clang_CXIndex_getGlobalOptions(idx) |
>   * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
>   * \endcode
>
> So making these options part of `struct CXIndexOptions` and deprecating 
> `clang_CXIndex_setGlobalOptions` requires introducing another global function 
> that would read the environment variables:
>
>   CINDEX_LINKAGE unsigned clang_getDefaultGlobalOptions();
>
> Is this the right approach?

Hmm, to make this patch easier, I think we might want to leave the environment 
variable behavior alone and not shift these into the options structure (yet?). 
Naively, I think it makes sense for these to eventually live in the options 
structure, but we could expose them in a few different ways (an option to 
prefer the env variable over a manual value as it is today or an option to 
prefer the manual value over the env variable for folks who want more hermetic 
behavior). WDYT? My opinion here isn't super strong, so if you have a strong 
desire to deprecate and add a replacement API, I think that's a defensible 
course to take.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143418

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


[clang] 463fa25 - [clang][NFC] Adjust tests to not un/define predefined macros

2023-02-14 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2023-02-14T13:55:03Z
New Revision: 463fa25c34d6e569862a9b74b24db3aa5522d84b

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

LOG: [clang][NFC] Adjust tests to not un/define predefined macros

An upcoming patch will be making all defining or undefining of
predefined macros to be warning (currently only some give a warning).
In preparation for this adjust some tests that would emit a warning:
 * In thread-specifier.c the undefine is done to avoid a different
   warning, but we get that warning just because __thread and
   __private_extern__ are the wrong way around so we can just swap
   them.
 * There are a couple of objective-c tests that redefine IBAction to
   what it's already defined as, so we can just remove the define.

Added: 


Modified: 
clang/test/Sema/thread-specifier.c
clang/test/SemaObjC/method-attributes.m
clang/test/SemaObjC/super-dealloc-attribute.m

Removed: 




diff  --git a/clang/test/Sema/thread-specifier.c 
b/clang/test/Sema/thread-specifier.c
index af6dcd9cb8d90..66f1d0f26697a 100644
--- a/clang/test/Sema/thread-specifier.c
+++ b/clang/test/Sema/thread-specifier.c
@@ -6,11 +6,6 @@
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern 
-verify=expected,thread-local -pedantic -x c++ %s -DC11 
-D__thread=_Thread_local -std=c++11 -Wno-deprecated
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern 
-verify=expected,thread-local -pedantic %s -std=c99 -D__thread=_Thread_local 
-DC99
 
-#ifdef __cplusplus
-// In C++, we define __private_extern__ to extern.
-#undef __private_extern__
-#endif
-
 __thread int t1; // thread-local-warning {{'_Thread_local' is a C11 extension}}
 __thread extern int t2; // thread-local-warning {{'_Thread_local' is a C11 
extension}}
 __thread static int t3; // thread-local-warning {{'_Thread_local' is a C11 
extension}}
@@ -19,7 +14,7 @@ __thread static int t3; // thread-local-warning 
{{'_Thread_local' is a C11 exten
 // expected-warning@-3 {{'__thread' before 'static'}}
 #endif
 
-__thread __private_extern__ int t4; // thread-local-warning {{'_Thread_local' 
is a C11 extension}}
+__private_extern__ __thread int t4; // thread-local-warning {{'_Thread_local' 
is a C11 extension}}
 struct t5 { __thread int x; }; // thread-local-warning {{'_Thread_local' is a 
C11 extension}}
 #ifdef __cplusplus
 // expected-error-re@-2 {{'{{__thread|_Thread_local|thread_local}}' is only 
allowed on variable declarations}}
@@ -47,7 +42,7 @@ int f(__thread int t7) { // expected-error {{' is only 
allowed on variable decla
 #endif
   extern __thread int t9; // thread-local-warning {{'_Thread_local' is a C11 
extension}}
   static __thread int t10; // thread-local-warning {{'_Thread_local' is a C11 
extension}}
-  __thread __private_extern__ int t11; // thread-local-warning 
{{'_Thread_local' is a C11 extension}}
+  __private_extern__ __thread int t11; // thread-local-warning 
{{'_Thread_local' is a C11 extension}}
 #if __cplusplus < 201103L
   __thread auto int t12a; // expected-error-re {{cannot combine with previous 
'{{__thread|_Thread_local}}' declaration specifier}} \
   // thread-local-warning {{'_Thread_local' is a C11 
extension}}

diff  --git a/clang/test/SemaObjC/method-attributes.m 
b/clang/test/SemaObjC/method-attributes.m
index 110e6811e0f8a..14e192637855d 100644
--- a/clang/test/SemaObjC/method-attributes.m
+++ b/clang/test/SemaObjC/method-attributes.m
@@ -37,7 +37,6 @@ - (void) dep __attribute__((deprecated)) { } // OK private 
methodn
 
 
 // rdar://10529259
-#define IBAction void)__attribute__((ibaction)
 
 @interface Foo 
 - (void)doSomething1:(id)sender;

diff  --git a/clang/test/SemaObjC/super-dealloc-attribute.m 
b/clang/test/SemaObjC/super-dealloc-attribute.m
index ecab109d3089e..37429cde0543e 100644
--- a/clang/test/SemaObjC/super-dealloc-attribute.m
+++ b/clang/test/SemaObjC/super-dealloc-attribute.m
@@ -87,7 +87,6 @@ + (void)registerClass:(id)name {
 @end
 
 // rdar://14251387
-#define IBAction void)__attribute__((ibaction)
 
 @interface UIViewController @end
 



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


[PATCH] D133863: [RISCV] Add MC support of RISCV zcmt Extension

2023-02-14 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 497293.
VincentWu added a comment.
Herald added subscribers: luke, emaste.

update to v1.0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133863

Files:
  clang/test/Preprocessor/riscv-target-features.c
  lld/ELF/InputSection.h
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVSchedRocket.td
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
  llvm/lib/Target/RISCV/RISCVSystemOperands.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcmt-invalid.s
  llvm/test/MC/RISCV/rv32zcmt-valid.s
  llvm/test/MC/RISCV/rvzcmt-user-csr-name.s

Index: llvm/test/MC/RISCV/rvzcmt-user-csr-name.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzcmt-user-csr-name.s
@@ -0,0 +1,29 @@
+# RUN: llvm-mc %s -triple=riscv32 -riscv-no-aliases -mattr=+experimental-zcmt -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ENC %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zcmt < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zcmt - \
+# RUN: | FileCheck -check-prefix=CHECK-INST-ALIAS %s
+#
+# RUN: llvm-mc %s -triple=riscv64 -riscv-no-aliases -mattr=+experimental-zcmt -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ENC %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zcmt < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zcmt - \
+# RUN: | FileCheck -check-prefix=CHECK-INST-ALIAS %s
+
+##
+# Jump Vector Table CSR
+##
+
+# jvt
+# name
+# CHECK-INST: csrrs t1, jvt, zero
+# CHECK-ENC:  encoding: [0x73,0x23,0x70,0x01]
+# CHECK-INST-ALIAS: csrr t1, jvt
+# uimm12
+# CHECK-INST: csrrs t2, jvt, zero
+# CHECK-ENC:  encoding: [0xf3,0x23,0x70,0x01]
+# CHECK-INST-ALIAS: csrr t2, jvt
+# name
+csrrs t1, jvt, zero
+# uimm12
+csrrs t2, 0x017, zero
Index: llvm/test/MC/RISCV/rv32zcmt-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zcmt-valid.s
@@ -0,0 +1,39 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zcmt\
+# RUN:  -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zcmt\
+# RUN:  -mattr=m < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zcmt\
+# RUN:  -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zcmt\
+# RUN:  -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zcmt\
+# RUN:  -mattr=m < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zcmt\
+# RUN:  -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv32 \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: cm.jt 1
+# CHECK-ASM: encoding: [0x06,0xa0]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zcmt' (table jump instuctions for code-size reduction){{$}}
+cm.jt 1
+
+# CHECK-ASM: cm.jalt 1
+# CHECK-OBJ: cm.jt 1
+# CHECK-ASM: encoding: [0x06,0xa0]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zcmt' (table jump instuctions for code-size reduction){{$}}
+cm.jalt 1
+
+# CHECK-ASM-AND-OBJ: cm.jalt 32
+# CHECK-ASM: encoding: [0x82,0xa0]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zcmt' (table jump instuctions for code-size reduction){{$}}
+cm.jalt 32
Index: llvm/test/MC/RISCV/rv32zcmt-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zcmt-invalid.s
@@ -0,0 +1,10 @@
+# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-zcmt -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-ERROR %s
+# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-zcmt -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: error: immediate must be an integer in the range [0, 31]
+cm.jt 64
+
+# CHECK-ERROR: error: immediate must be an integer in the range [0, 255]
+cm.jalt 256
Index: llvm/test/MC/RISCV/attribute-arch.s
===
---

[PATCH] D144003: [clang][analyzer] Improve bug reports of StdLibraryFunctionsChecker.

2023-02-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, gamesh411, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a reviewer: NoQ.
Herald added a project: All.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add an additional explanation of what is wrong if a constraint is
not satisfied, in some cases.
Additionally the bug report generation is changed to use raw_ostream.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144003

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp

Index: clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp
+++ clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp
@@ -78,34 +78,36 @@
 int __range_out_1_2__4_6(int); // [1, 2], [4, 6]
 int __range_out_1_2__4_inf(int); // [1, 2], [4, inf]
 
+int __test_case_range_1_2__4_6(int);
+
 void test_range_values(int x) {
   switch (x) {
   case 0:
-__single_val_0(1); // expected-warning{{should be zero}}
+__single_val_0(1); // expected-warning{{should be zero but is 1}}
 break;
   case 1:
-__single_val_1(2); // expected-warning{{should be 1}}
+__single_val_1(2); // expected-warning{{should be 1 but is 2}}
 break;
   case 2:
-__range_1_2(3); // expected-warning{{should be 1 or 2}}
+__range_1_2(3); // expected-warning{{should be 1 or 2 but is 3}}
 break;
   case 3:
-__range_m1_1(3); // expected-warning{{should be between -1 and 1}}
+__range_m1_1(3); // expected-warning{{should be between -1 and 1 but is 3}}
 break;
   case 4:
-__range_m2_m1(1); // expected-warning{{should be -2 or -1}}
+__range_m2_m1(1); // expected-warning{{should be -2 or -1 but is 1}}
 break;
   case 5:
-__range_m10_10(11); // expected-warning{{should be between -10 and 10}}
+__range_m10_10(11); // expected-warning{{should be between -10 and 10 but is 11}}
 break;
   case 6:
-__range_m10_10(-11); // expected-warning{{should be between -10 and 10}}
+__range_m10_10(-11); // expected-warning{{should be between -10 and 10 but is -11}}
 break;
   case 7:
-__range_1_2__4_6(3); // expected-warning{{should be 1 or 2 or 4, 5 or 6}}
+__range_1_2__4_6(3); // expected-warning{{should be 1 or 2 or 4, 5 or 6 but is 3}}
 break;
   case 8:
-__range_1_2__4_inf(3); // expected-warning{{should be 1 or 2 or >= 4}}
+__range_1_2__4_inf(3); // expected-warning{{should be 1 or 2 or >= 4 but is 3}}
 break;
   }
 }
@@ -113,22 +115,22 @@
 void test_range_values_inf(int x) {
   switch (x) {
   case 1:
-__range_m1_inf(-2); // expected-warning{{should be >= -1}}
+__range_m1_inf(-2); // expected-warning{{should be >= -1 but is -2}}
 break;
   case 2:
-__range_0_inf(-1); // expected-warning{{should be >= 0}}
+__range_0_inf(-1); // expected-warning{{should be >= 0 but is -1}}
 break;
   case 3:
-__range_1_inf(0); // expected-warning{{should be > 0}}
+__range_1_inf(0); // expected-warning{{should be > 0 but is 0}}
 break;
   case 4:
-__range_minf_m1(0); // expected-warning{{should be < 0}}
+__range_minf_m1(0); // expected-warning{{should be < 0 but is 0}}
 break;
   case 5:
-__range_minf_0(1); // expected-warning{{should be <= 0}}
+__range_minf_0(1); // expected-warning{{should be <= 0 but is 1}}
 break;
   case 6:
-__range_minf_1(2); // expected-warning{{should be <= 1}}
+__range_minf_1(2); // expected-warning{{should be <= 1 but is 2}}
 break;
   }
 }
@@ -136,28 +138,28 @@
 void test_range_values_out(int x) {
   switch (x) {
   case 0:
-__single_val_out_0(0); // expected-warning{{should be nonzero}}
+__single_val_out_0(0); // expected-warning{{should be nonzero but is 0}}
 break;
   case 1:
-__single_val_out_1(1); // expected-warning{{should be not equal to 1}}
+__single_val_out_1(1); // expected-warning{{should be not equal to 1 but is 1}}
 break;
   case 2:
-__range_out_1_2(2); // expected-warning{{should be not 1 and not 2}}
+__range_out_1_2(2); // expected-warning{{should be not 1 and not 2 but is 2}}
 break;
   case 3:
-__range_out_m1_1(-1); // expected-warning{{should be not between -1 and 1}}
+__range_out_m1_1(-1); // expected-warning{{should be not between -1 and 1 but is -1}}
 break;
   case 4:
-__range_out_m2_m1(-2); // expected-warning{{should be not -2 and not -1}}
+__range_out_m2_m1(-2); // expected-warning{{should be not -2 and not -1 but is -2}}
 break;
   case 5:
-__range_out_m10_10(0); // expected-warning{{should be not between -10 and 10}}
+__range_o

[PATCH] D138777: [clang-tidy] Add check bugprone-multiple-new-in-one-expression.

2023-02-14 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp:44-45
+return BinOp->getOpcode() == BO_Assign &&
+   BinOp->getRHS()->IgnoreParenCasts() == E;
+
+  return isa(ParentE);

In general, a value can be stored by passing it to a CompoundAssignOperator. 
This is not relevant in the current application (pointers do not appear on the 
RHS of compound assignment operators); but perhaps it's worth to mention this 
in a short comment in case someone wishes to reuse this function in some other 
checker.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/multiple-new-in-one-expression.rst:9-14
+C++ does often not specify the exact order of evaluation of the operands of an 
operator or arguments of a function.
+Therefore if a first allocation succeeds and a second fails, in an exception 
handler it is not possible to tell which allocation has failed and free the 
memory.
+Even if the order is fixed the result of a first ``new`` may be stored in a 
temporary location that is not reachable at the time when a second allocation 
fails.
+It is best to avoid any expression that contains more than one operator 
``new`` call, if exception handling is used to check for allocation errors.
+Different rules apply for are the short-circuit operators ``||`` and ``&&`` 
and the ``,`` operator, where evaluation of one side must be completed before 
the other starts.
+Similarly, condition of a ``?`` operator is evaluated before the branches are 
evaluated.

Eugene.Zelenko wrote:
> Please follow 80 characters limit.
I think the handling of the case of the short-circuiting operators is ambiguous 
in this long paragraph: without the examples it's unclear whether the checker 
reports e.g. `f2(new A) || f1(new B);` as an error ("Even if the order is fixed 
... It is best to avoid any expression that contains more than one operator 
``new`` call ... " suggests that even these cases are reported). Try to 
restructure this description, perhaps by splitting it into two paragraphs: (1) 
quote/state all the relevant rules of C++ evaluation order (2) describe how 
"bad" ordering of the two allocation causes a memory leak.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138777

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


[PATCH] D143533: [clang] Allow gnu::aligned attribute to work with templated type alias declarations

2023-02-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: erichkeane.
aaron.ballman added a comment.

Adding Erich as attributes code owner.




Comment at: clang/lib/AST/ASTContext.cpp:2154
+  if (uint64_t Result = SubstTypeVisitor(Ctx, SubType->getReplacementType())
+.TryEval(Attr->getAlignmentExpr())) {
+TI.Align = Result;

rsmith wrote:
> I don't think this approach is going to work out well. There are many cases 
> this gets wrong, fixing them would require reinventing template substitution 
> here, and generally we shouldn't be doing this substitution as part of 
> alignment computation at all -- we should have `TreeTransform` produce the 
> right alignment value during template instantiation and just pull it back out 
> of the `Type` here. We can't really use the same approach as we do for 
> `TypedefDecl`s, though, because we don't instantiate a `TypeAliasDecl` for 
> each use of a `TypeAliasTemplateDecl`, so there's nowhere to hang an 
> instantiated attribute. But the handling for `TypedefType`s is also fairly 
> painful, so I think we should be considering an approach that makes both of 
> them more elegant. Here's what I suggest:
> 
> - We add a new sugar-only `Type` subclass that represents an alignment 
> attribute. Maybe we can model this as an `AttributedType` for the 
> `AlignedAttr`, or maybe we create a new kind of type node.
> - We translate `AlignedAttr`s on typedef and type alias declarations into 
> this new kind of `Type` wrapping the declared type.
> - We make `getTypeInfoImpl` special-case that type sugar node instead of 
> special-casing `TypedefType` sugar.
> - We make sure that `TreeTransform` properly instantiates the new node, in 
> particular performing substitution within the argument.
I think this approach makes sense to me, but it's worth noting: the alignment 
attributes (vendor specific or standard) are declaration attributes and not 
type attributes. I think this is a design mistake; alignment is a fundamental 
property of a type (see http://eel.is/c++draft/basic.align#1), so I'm in favor 
of modeling this as a type attribute, but the standard `alignas` attribute does 
not have type semantics: http://eel.is/c++draft/dcl.align#1. Should we approach 
the standards committees about this or are we not concerned about `alignas` 
behavior?

(If we expect `alignas` to be a declaration attribute and `[[gnu::aligned]]` to 
be a type attribute, another question is whether we should split them in 
Attr.td.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143533

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


[PATCH] D142507: [AMDGPU] Split dot7 feature

2023-02-14 Thread Aaron Siddhartha Mondal via Phabricator via cfe-commits
aaronmondal added subscribers: jhuber6, aaronmondal.
aaronmondal added a comment.

Would it be possible to backport this to Clang 16?

If 
https://github.com/RadeonOpenCompute/ROCm-Device-Libs/commit/8dc779e19cbf2ccfd3307b60f7db57cf4203a5be
 makes it into ROCm 5.5 no distro would be able to build it with "vanilla" 
Clang 16, potentially causing pain for users that try to build ROCm 5.5 with a 
Clang from a package manager (a realistic scenario, considering that one may 
want to invest 5 min to build ROCm but not 40 min to build Clang). ROCm 5.5 
will be the first release to officially support the 7900XT and 7900XTX, so not 
having this potentially causes issues for users with recent AMD hardware. (See 
https://github.com/RadeonOpenCompute/ROCm/issues/1880 for extensive, related 
discussion).

@jhuber6 This wouldn't exactly "solve" 
https://github.com/llvm/llvm-project/issues/60660, but I think this could also 
be a workaround (with potentially better user experience), as allowing users 
build ROCm with regular Clang 16 prevents that deadlock where we can't build 
ROCm anymore. This is entirely based on speculation that ROCm 5.5 won't 
introduce other breakages before its release though, so I'd totally understand 
if this is not a satisfactory solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142507

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


[PATCH] D143891: [Clang] Adjust triviality computation in QualType::isTrivialType to C++20 cases.

2023-02-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D143891#4122731 , @aaron.ballman 
wrote:

> In D143891#4122668 , @royjacobson 
> wrote:
>
>> In D143891#4122660 , 
>> @aaron.ballman wrote:
>>
>>> This is an ABI breaking change, isn't it? (The type trait now returns 
>>> something different than it did before, which could change instantiations 
>>> or object layout.)
>>
>> Technically it is, but it only affects code that relies on constrained 
>> default constructors, which we're only going to support in Clang 16. So if 
>> we backport this to 16 it's not very problematic.
>
> Hmmm, if it's true that this only changes the behavior of a type with a 
> constrained default constructor, then I think it's fine despite being an ABI 
> break (we never claimed full support for concepts, so anyone relying on a 
> particular behavior was mistaken to do that). I can't quite convince myself 
> this doesn't impact other cases though -- the logic for computing triviality 
> is nontrivial itself (pun intended), so I'm really only concerned that 
> `__is_trivial` and friends return a different value for a non-constrained 
> type. However, I also can't come up with a test case whose behavior changes 
> either.

Avoiding hte rest of the discussion, because I cannot even:
ABI Breaks like this are typically OK, BUT we need to update the 
ClangABIVersion stuff, which includes only implementing this in the newest 
version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143891

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


[PATCH] D141666: [RISCV] Proper support of extensions Zicsr and Zifencei

2023-02-14 Thread Elena Lepilkina via Phabricator via cfe-commits
eklepilkina added a comment.

@reames Thank you for fixing documentation, missed this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141666

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


[PATCH] D143891: [Clang] Adjust triviality computation in QualType::isTrivialType to C++20 cases.

2023-02-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D143891#4125954 , @erichkeane 
wrote:

> In D143891#4122731 , @aaron.ballman 
> wrote:
>
>> In D143891#4122668 , @royjacobson 
>> wrote:
>>
>>> In D143891#4122660 , 
>>> @aaron.ballman wrote:
>>>
 This is an ABI breaking change, isn't it? (The type trait now returns 
 something different than it did before, which could change instantiations 
 or object layout.)
>>>
>>> Technically it is, but it only affects code that relies on constrained 
>>> default constructors, which we're only going to support in Clang 16. So if 
>>> we backport this to 16 it's not very problematic.
>>
>> Hmmm, if it's true that this only changes the behavior of a type with a 
>> constrained default constructor, then I think it's fine despite being an ABI 
>> break (we never claimed full support for concepts, so anyone relying on a 
>> particular behavior was mistaken to do that). I can't quite convince myself 
>> this doesn't impact other cases though -- the logic for computing triviality 
>> is nontrivial itself (pun intended), so I'm really only concerned that 
>> `__is_trivial` and friends return a different value for a non-constrained 
>> type. However, I also can't come up with a test case whose behavior changes 
>> either.
>
> Avoiding hte rest of the discussion, because I cannot even:
> ABI Breaks like this are typically OK, BUT we need to update the 
> ClangABIVersion stuff, which includes only implementing this in the newest 
> version.

Aaron points out offline that this is Concepts specific, and can only be run 
into with a concept.  I didn't realize on first read the 'ineligible' was 
'disabled with a constraint'.  If so, we don't really make any guarantees about 
ABI compat with Concepts yet, so the ClangABIVersion stuff is likely 
unnecessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143891

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


[PATCH] D143414: [clang] refactor FileManager::GetUniqueIDMapping

2023-02-14 Thread Richard Howell via Phabricator via cfe-commits
rmaz updated this revision to Diff 497309.
rmaz added a comment.

remove `header_file_size()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143414

Files:
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -169,17 +169,10 @@
 
   const HeaderSearch &HS = PP.getHeaderSearchInfo();
 
-  SmallVector FilesByUID;
-  HS.getFileMgr().GetUniqueIDMapping(FilesByUID);
-
-  if (FilesByUID.size() > HS.header_file_size())
-FilesByUID.resize(HS.header_file_size());
-
-  for (unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
-const FileEntry *File = FilesByUID[UID];
-if (!File)
-  continue;
+  SmallVector FileEntries;
+  HS.getFileMgr().getSeenNonVirtualFileEntries(FileEntries);
 
+  for (auto File : FileEntries) {
 const HeaderFileInfo *HFI =
 HS.getExistingFileInfo(File, /*WantExternal*/ false);
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
@@ -1918,16 +1911,10 @@
 }
   }
 
-  SmallVector FilesByUID;
-  HS.getFileMgr().GetUniqueIDMapping(FilesByUID);
+  SmallVector FileEntries;
+  HS.getFileMgr().getSeenNonVirtualFileEntries(FileEntries);
 
-  if (FilesByUID.size() > HS.header_file_size())
-FilesByUID.resize(HS.header_file_size());
-
-  for (unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
-const FileEntry *File = FilesByUID[UID];
-if (!File)
-  continue;
+  for (auto File : FileEntries) {
 
 // Get the file info. This will load info from the external source if
 // necessary. Skip emitting this file if we have no information on it
@@ -1941,7 +1928,7 @@
   continue;
 
 // Massage the file path into an appropriate form.
-StringRef Filename = File->getName();
+StringRef Filename = File.getName();
 SmallString<128> FilenameTmp(Filename);
 if (PreparePathForOutput(FilenameTmp)) {
   // If we performed any translation on the file name at all, we need to
@@ -1950,9 +1937,8 @@
   SavedStrings.push_back(Filename.data());
 }
 
-HeaderFileInfoTrait::key_type Key = {
-  Filename, File->getSize(), getTimestampForOutput(File)
-};
+HeaderFileInfoTrait::key_type Key = {Filename, File.getSize(),
+ getTimestampForOutput(File)};
 HeaderFileInfoTrait::data_type Data = {
   *HFI, HS.getModuleMap().findResolvedModulesForHeader(File), {}
 };
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -611,25 +611,26 @@
   return std::error_code();
 }
 
-void FileManager::GetUniqueIDMapping(
-SmallVectorImpl &UIDToFiles) const {
-  UIDToFiles.clear();
-  UIDToFiles.resize(NextFileUID);
-
-  // Map file entries
-  for (llvm::StringMap,
-   llvm::BumpPtrAllocator>::const_iterator
-   FE = SeenFileEntries.begin(),
-   FEEnd = SeenFileEntries.end();
-   FE != FEEnd; ++FE)
-if (llvm::ErrorOr Entry = FE->getValue()) {
-  if (const auto *FE = Entry->V.dyn_cast())
-UIDToFiles[FE->getUID()] = FE;
-}
+void FileManager::getSeenNonVirtualFileEntries(
+SmallVectorImpl &Entries) const {
+  Entries.reserve(SeenFileEntries.size());
+
+  for (const auto &Entry : SeenFileEntries) {
+if (auto Value = Entry.getValue())
+  // Ignore VFS-mapped entries, they will have a separate on-disk
+  // file entry.
+  if (Value->V.is())
+Entries.push_back(FileEntryRef(Entry));
+  }
+
+  // We want the file entries in deterministic order for
+  // module serialization.
+  llvm::sort(Entries, [](FileEntryRef &A, FileEntryRef &B) {
+if (A.getUID() != B.getUID())
+  return A.getUID() < B.getUID();
 
-  // Map virtual file entries
-  for (const auto &VFE : VirtualFileEntries)
-UIDToFiles[VFE->getUID()] = VFE;
+return A.getName() < B.getName();
+  });
 }
 
 StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
Index: clang/include/clang/Lex/HeaderSearch.h
===
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -793,8 +793,6 @@
   /// Retrieve the module map.
   const ModuleMap &getModuleMap() const { return ModMap; }
 
-  unsigned header_file_size() const { return FileInfo.size(); }
-
   /// Return the HeaderFileInfo structure for the specified FileEntry,
   /// in preparation for updating it in some way.
   HeaderFileInfo &getFileInfo(const FileEntry *FE);
Index: clang/include/clang/Basic/FileManager.h
===

[PATCH] D143745: Make section attribute and -ffunction-sections play nicely

2023-02-14 Thread Paul Robinson via Phabricator via cfe-commits
probinson abandoned this revision.
probinson added a comment.

Discussion on the GCC bug has persuaded me this is not a good idea.  I'll solve 
my user's problem a different way.
@MaskRay you can close the GCC bug, it looks like I can't do it myself.


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

https://reviews.llvm.org/D143745

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


[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-14 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Thanks Philip. I started looking at this too, and agree that something like 
this is a good next step. I've been looking more closely at the GCC behaviour 
and noticed a couple of things that might be of interest:

- `-march=rv64gc` results 
in`rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0`, but 
`-march=rv64imafdc` results in `rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0`
- `-march=rv64i2p0_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0` results in 
`rv64i2p0_m2p0_a2p1_f2p2_d2p2_c2p0` (i.e. the zicsr and zifencei are silently 
dropped)

The strategy proposed in this patch seems sensible to me, unless someone can 
see a good reason I'm missing to try to go more down the route gcc took and to 
rewrite the -march string?

I'm looking at the case now of LLD erroring out when linking a .o specifying 
I2.1, which I think was unintentional and a regression from 15.0.x to 16.0.x. 
Similar with llvm-objdump refusing to try disassembling a file with I2.1, which 
is probably more user hostile than we'd like.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143953

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


[PATCH] D144011: [clang]Fix warning for signed conversion

2023-02-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rsmith, MaskRay, rtrieu.
Herald added a project: All.
yaxunl requested review of this revision.

Currently clang emits warning with -Wconversion for the following code:

  long foo(long x) {
return 1LLisInteger() && TargetBT &&
+TargetBT->isInteger()) {
+  return;
+}
+
 // Fall through for non-constants to give a sign conversion warning.
   }
 


Index: clang/test/Sema/sign-conversion.c
===
--- clang/test/Sema/sign-conversion.c
+++ clang/test/Sema/sign-conversion.c
@@ -5,4 +5,8 @@
 void test(int x) {
   unsigned t0 = x; // expected-warning {{implicit conversion changes signedness}}
   unsigned t1 = (t0 == 5 ? x : 0); // expected-warning {{operand of ? changes signedness}}
+
+  // Clang has special treatment for left shift of literal '1'.
+  // Make sure there is no diagnostics.
+  long t2 = 1LL << x;
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14281,6 +14281,11 @@
   }
 }
 
+if (SourceBT && SourceBT->isInteger() && TargetBT &&
+TargetBT->isInteger()) {
+  return;
+}
+
 // Fall through for non-constants to give a sign conversion warning.
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143849: [Clang][OpenCL] Allow pointers in structs as kernel arguments from 2.0

2023-02-14 Thread Ayal Zaks via Phabricator via cfe-commits
Ayal updated this revision to Diff 497317.
Ayal added a comment.

Use `-verify=expected,ocl12` instead of #ifdef'ing the test to check 
diagnostics emitted for 1.2 but not emitted for 2.0.


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

https://reviews.llvm.org/D143849

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCL/invalid-kernel-parameters.cl


Index: clang/test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,ocl12 %s -triple 
spir-unknown-unknown
 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown 
-cl-std=CL2.0
 
 kernel void half_arg(half x) { } // expected-error{{declaring function 
parameter of type '__private half' is not allowed; did you forget * ?}}
@@ -87,15 +87,16 @@
 
 
 
-typedef struct FooImage2D // expected-note{{within field of type 'FooImage2D' 
declared here}}
+typedef struct FooImage2D // ocl12-note{{within field of type 'FooImage2D' 
declared here}}
 {
   // TODO: Clean up needed - we don't really need to check for image, event, 
etc
   // as a note here any longer.
   // They are diagnosed as an error for all struct fields (OpenCL v1.2 
s6.9b,r).
-  image2d_t imageField; // expected-note{{field of illegal type '__read_only 
image2d_t' declared here}} expected-error{{the '__read_only image2d_t' type 
cannot be used to declare a structure or union field}}
+  image2d_t imageField; // ocl12-note{{field of illegal type '__read_only 
image2d_t' declared here}}
+// expected-error@-1{{the '__read_only image2d_t' type 
cannot be used to declare a structure or union field}}
 } FooImage2D;
 
-kernel void image_in_struct_arg(FooImage2D arg) { } // expected-error{{struct 
kernel parameters may not contain pointers}}
+kernel void image_in_struct_arg(FooImage2D arg) { } // ocl12-error{{struct 
kernel parameters may not contain pointers}}
 
 typedef struct Foo // expected-note{{within field of type 'Foo' declared here}}
 {
@@ -104,6 +105,13 @@
 
 kernel void pointer_in_struct_arg(Foo arg) { } // expected-error{{struct 
kernel parameters may not contain pointers}}
 
+typedef struct FooGlobal // ocl12-note{{within field of type 'FooGlobal' 
declared here}}
+{
+  global int* ptrField; // ocl12-note{{field of illegal pointer type '__global 
int *' declared here}}
+} FooGlobal;
+
+kernel void global_pointer_in_struct_arg(FooGlobal arg) { } // 
ocl12-error{{struct kernel parameters may not contain pointers}}
+
 typedef union FooUnion // expected-note{{within field of type 'FooUnion' 
declared here}}
 {
   int* ptrField; // expected-note-re{{field of illegal pointer type 
'__{{private|generic}} int *' declared here}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9489,13 +9489,18 @@
   // OpenCL v1.2 s6.9.p:
   // Arguments to kernel functions that are declared to be a struct or 
union
   // do not allow OpenCL objects to be passed as elements of the struct or
-  // union.
-  if (ParamType == PtrKernelParam || ParamType == PtrPtrKernelParam ||
-  ParamType == InvalidAddrSpacePtrKernelParam) {
+  // union. This restriction was lifted in OpenCL v2.0 with the 
introduction
+  // of SVM.
+  if (ParamType == InvalidAddrSpacePtrKernelParam ||
+  ((ParamType == PtrKernelParam || ParamType == PtrPtrKernelParam) &&
+   S.getLangOpts().getOpenCLCompatibleVersion() <= 120)) {
 S.Diag(Param->getLocation(),
diag::err_record_with_pointers_kernel_param)
   << PT->isUnionType()
   << PT;
+  } else if (ParamType == PtrKernelParam || ParamType == 
PtrPtrKernelParam) {
+// and OpenCL version is at-least 2.0, so these types are allowed.
+continue;
   } else {
 S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
   }


Index: clang/test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,ocl12 %s -triple spir-unknown-unknown
 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown -cl-std=CL2.0
 
 kernel void half_arg(half x) { } // expected-error{{declaring function parameter of type '__private half' is not allowed; did you forget * ?}}
@@ -87,15 +87,16 @@
 
 
 
-typedef struct FooImage2D // expected-note{{within field of type 'FooImage2D' declared here}}
+

[PATCH] D143849: [Clang][OpenCL] Allow pointers in structs as kernel arguments from 2.0

2023-02-14 Thread Ayal Zaks via Phabricator via cfe-commits
Ayal added inline comments.



Comment at: clang/test/SemaOpenCL/invalid-kernel-parameters.cl:90
 
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2
 typedef struct FooImage2D // expected-note{{within field of type 'FooImage2D' 
declared here}}

yaxunl wrote:
> Ayal wrote:
> > yaxunl wrote:
> > > we should not limit the tests to CL1.2. We should test them with 2.0 to 
> > > make sure there is no diagnostics.
> > > 
> > > To differentiate between 1.2 and 2.0 you can use -verify=ocl12 and 
> > > -verify=ocl20.
> > > 
> > > same as below
> > Using -verify=ocl12 and -verify=ocl20 should probably be done separately as 
> > an NFC patch as it involves many changes IIUC.
> > 
> > The expect's were placed under #ifdef instead (and only them), following 
> > e.g. existing lines 8-12.
> you can use -verify=expected,ocl12 for OCL1.2 and -verify for OCL2.0 then the 
> common diagnostics are kept as 'expected-*' and unchanged. you only need to 
> change the ocl1.2 specific diagnostics to 'ocl12-*'.
> 
> For example, 
> https://github.com/llvm/llvm-project/blob/main/clang/test/SemaOpenCL/atomic-ops.cl
Ah, ok, done, thanks!

(Note that atomic-ops.cl uses only `expected`'s, some of which are placed under 
#if, as done elsewhere in this test file.)


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

https://reviews.llvm.org/D143849

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


[PATCH] D143533: [clang] Allow gnu::aligned attribute to work with templated type alias declarations

2023-02-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:2154
+  if (uint64_t Result = SubstTypeVisitor(Ctx, SubType->getReplacementType())
+.TryEval(Attr->getAlignmentExpr())) {
+TI.Align = Result;

aaron.ballman wrote:
> rsmith wrote:
> > I don't think this approach is going to work out well. There are many cases 
> > this gets wrong, fixing them would require reinventing template 
> > substitution here, and generally we shouldn't be doing this substitution as 
> > part of alignment computation at all -- we should have `TreeTransform` 
> > produce the right alignment value during template instantiation and just 
> > pull it back out of the `Type` here. We can't really use the same approach 
> > as we do for `TypedefDecl`s, though, because we don't instantiate a 
> > `TypeAliasDecl` for each use of a `TypeAliasTemplateDecl`, so there's 
> > nowhere to hang an instantiated attribute. But the handling for 
> > `TypedefType`s is also fairly painful, so I think we should be considering 
> > an approach that makes both of them more elegant. Here's what I suggest:
> > 
> > - We add a new sugar-only `Type` subclass that represents an alignment 
> > attribute. Maybe we can model this as an `AttributedType` for the 
> > `AlignedAttr`, or maybe we create a new kind of type node.
> > - We translate `AlignedAttr`s on typedef and type alias declarations into 
> > this new kind of `Type` wrapping the declared type.
> > - We make `getTypeInfoImpl` special-case that type sugar node instead of 
> > special-casing `TypedefType` sugar.
> > - We make sure that `TreeTransform` properly instantiates the new node, in 
> > particular performing substitution within the argument.
> I think this approach makes sense to me, but it's worth noting: the alignment 
> attributes (vendor specific or standard) are declaration attributes and not 
> type attributes. I think this is a design mistake; alignment is a fundamental 
> property of a type (see http://eel.is/c++draft/basic.align#1), so I'm in 
> favor of modeling this as a type attribute, but the standard `alignas` 
> attribute does not have type semantics: http://eel.is/c++draft/dcl.align#1. 
> Should we approach the standards committees about this or are we not 
> concerned about `alignas` behavior?
> 
> (If we expect `alignas` to be a declaration attribute and `[[gnu::aligned]]` 
> to be a type attribute, another question is whether we should split them in 
> Attr.td.)
IMO, the idea of doing this via this visitor is incorrect, we should just make 
sure the instantiated decl of the type alias to get the attribute, we do 
similar things for function decls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143533

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


[PATCH] D143996: [clang-tidy][doc] Remove unused variable

2023-02-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko requested changes to this revision.
Eugene.Zelenko added inline comments.
This revision now requires changes to proceed.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst:35
 
-Variables: ``a``, ``c``, ``c_ptr1``, ``c_ptr2``, ``c_const_ptr`` and
+Variables: ``a``, ``c``, ``c_ptr1``, ``c_const_ptr`` and
 ``c_reference``, will all generate warnings since they are either:

Please fill as much of 80 symbols as possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143996

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


[PATCH] D143921: [debug-info][codegen] Prevent creation of self-referential SP node

2023-02-14 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve updated this revision to Diff 497321.
fdeazeve added a comment.

Added verifier test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143921

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  llvm/docs/LangRef.rst
  llvm/lib/IR/Verifier.cpp
  llvm/test/Verifier/disubprogram_declaration.ll


Index: llvm/test/Verifier/disubprogram_declaration.ll
===
--- /dev/null
+++ llvm/test/Verifier/disubprogram_declaration.ll
@@ -0,0 +1,17 @@
+; RUN: llvm-as -disable-output <%s 2>&1| FileCheck %s
+
+declare !dbg !12 i32 @declared_only()
+
+!llvm.module.flags = !{!2}
+!llvm.dbg.cu = !{!5}
+
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !6, 
producer: "clang", emissionKind: FullDebug)
+!6 = !DIFile(filename: "a.cpp", directory: "/")
+!7 = !{}
+!11 = !DISubroutineType(types: !7)
+
+!12 = !DISubprogram(name: "declared_only", scope: !6, file: !6, line: 2, type: 
!11, spFlags: DISPFlagOptimized, retainedNodes: !7, declaration: !13)
+!13 = !DISubprogram(name: "declared_only", scope: !6, file: !6, line: 2, type: 
!11, spFlags: DISPFlagOptimized, retainedNodes: !7)
+; CHECK: subprogram declaration must not have a declaration field
+; CHECK: warning: ignoring invalid debug info
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1400,6 +1400,8 @@
   } else {
 // Subprogram declarations (part of the type hierarchy).
 CheckDI(!Unit, "subprogram declarations must not have a compile unit", &N);
+CheckDI(!N.getRawDeclaration(),
+"subprogram declaration must not have a declaration field");
   }
 
   if (auto *RawThrownTypes = N.getRawThrownTypes()) {
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -5772,11 +5772,12 @@
 
 .. _DISubprogramDeclaration:
 
-When ``isDefinition: false``, subprograms describe a declaration in the type
-tree as opposed to a definition of a function.  If the scope is a composite
-type with an ODR ``identifier:`` and that does not set ``flags: DIFwdDecl``,
-then the subprogram declaration is uniqued based only on its ``linkageName:``
-and ``scope:``.
+When ``spFlags: DISPFlagDefinition`` is not present, subprograms describe a
+declaration in the type tree as opposed to a definition of a function. In this
+case, the ``declaration`` field must be empty. If the scope is a composite type
+with an ODR ``identifier:`` and that does not set ``flags: DIFwdDecl``, then
+the subprogram declaration is uniqued based only on its ``linkageName:`` and
+``scope:``.
 
 .. code-block:: text
 
@@ -5785,9 +5786,9 @@
 }
 
 !0 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,
-file: !2, line: 7, type: !3, isLocal: true,
-isDefinition: true, scopeLine: 8,
-containingType: !4,
+file: !2, line: 7, type: !3,
+spFlags: DISPFlagDefinition | 
DISPFlagLocalToUnit,
+scopeLine: 8, containingType: !4,
 virtuality: DW_VIRTUALITY_pure_virtual,
 virtualIndex: 10, flags: DIFlagPrototyped,
 isOptimized: true, unit: !5, templateParams: 
!6,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4217,7 +4217,7 @@
   llvm::DISubprogram *SP =
   DBuilder.createFunction(FDContext, Name, LinkageName, Unit, LineNo, STy,
   ScopeLine, Flags, SPFlags, TParamsArray.get(),
-  getFunctionDeclaration(D), nullptr, Annotations);
+  nullptr, nullptr, Annotations);
 
   // Preserve btf_decl_tag attributes for parameters of extern functions
   // for BPF target. The parameters created in this loop are attached as


Index: llvm/test/Verifier/disubprogram_declaration.ll
===
--- /dev/null
+++ llvm/test/Verifier/disubprogram_declaration.ll
@@ -0,0 +1,17 @@
+; RUN: llvm-as -disable-output <%s 2>&1| FileCheck %s
+
+declare !dbg !12 i32 @declared_only()
+
+!llvm.module.flags = !{!2}
+!llvm.dbg.cu = !{!5}
+
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !6, producer: "clang", emissionKind: FullDebug)
+!6 = !DIFile(filename: "a.cpp", directory: "/")
+!7 = !{}
+!11 = !DISubroutineType(types: !7)
+
+!12 = !DISubprogram(name: "declared_only", scope: !6, file: !6, line: 

[PATCH] D143921: [debug-info][codegen] Prevent creation of self-referential SP node

2023-02-14 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve added a comment.

In D143921#4124533 , @aprantl wrote:

> In D143921#4123218 , @fdeazeve 
> wrote:
>
>> Any testing suggestions here? I can use what we have on GH (cpp -> codegen 
>> test), but I'm not sure if there's a finer grained test we could use.
>
> I was thinking of a very small IR test similar to 
> `llvm/test/Verifier/disubprogram-name-match-only.ll`.

Yup, good idea, this should be enough! Added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143921

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


[PATCH] D143430: [C2x] Implement the `unreachable` macro for WG14 N2826

2023-02-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Headers/stddef.h:108
+__STDC_VERSION__ >= 202000L
+#define unreachable() __builtin_unreachable()
+#endif /* defined(__need_STDDEF_H_misc) && >= C23 */

Is this REALLY required to be a macro by standard?  Is it so they don't have to 
steal the word/can do #undef?  This is going to result in a worse diagnostic 
here any time we diagnose on this line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143430

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


[PATCH] D143495: [AMDGPU ASAN] Remove reference to asan bitcode library

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

In D143495#4123119 , @pvellien wrote:

> @yaxunl Could you please commit this change on my behalf? I don't have a 
> write access to the trunk.
> Thank you

sure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143495

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


[PATCH] D135341: [clang] adds `__reference_constructs_from_temporary`

2023-02-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

On the fence about the diagnostic at all, but definitely should not be doing 
string magic to make it quoted.  Otherwise this is a LGTM.




Comment at: clang/lib/Sema/SemaExprCXX.cpp:5620
+std::string Spelling = "'" + std::string(getTraitSpelling(BTT)) + "'";
+return Self.Diag(KeyLoc, diag::err_reserved_identifier_for_future_use) << 
Spelling;
+  }

This is my only problem with this... we shouldn't have to do this magic to get 
this to work.  The diagnostic should have the quote in it, OR we should just 
pass an identifier (which, IIRC, ensures we wrap it in quotes anyway).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135341

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


[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-02-14 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 2 inline comments as done.
pmatos added a comment.

@aaron.ballman I have finished addressing all the concerns on this patch. Do 
you have any further comments?




Comment at: clang/lib/Sema/SemaType.cpp:7289-7290
+  QualType Pointee = Type->getPointeeType();
+  Pointee = S.Context.getAddrSpaceQualType(
+  S.Context.removeAddrSpaceQualType(Pointee), ASIdx);
+  Type = State.getAttributedType(A, Type, S.Context.getPointerType(Pointee));

aaron.ballman wrote:
> aaron.ballman wrote:
> > What happens when the user's function already has an explicitly specified 
> > address space?
> Still wondering about this as well.
We'll just be overriding the address space in this case. Although, I am not 
sure something like this can happen in Wasm given there's only one linear 
memory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[PATCH] D143194: [clang][analyzer] Make messages of StdCLibraryFunctionsChecker user-friendly

2023-02-14 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:95
+QualType ArgT, BasicValueFactory &BVF,
+DescString &Out);
+  /// Append textual description of a numeric range out of [RMin,RMax] to the

balazske wrote:
> Szelethus wrote:
> > Using a `raw_ostream` as a parameter sounds more elegant than a 
> > `SmallString` with a precise stack buffer length. Not to mention that you 
> > could call this function with `llvm::errs()` for easy debugging.
> I want to improve this in a later patch. The change does involve not new code 
> too (`getArgDesc` should be changed too and other places where the messages 
> are generated).
Fair enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143194

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


[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-14 Thread Philip Reames via Phabricator via cfe-commits
reames updated this revision to Diff 497328.
reames edited the summary of this revision.
reames added a comment.

Add docs, and rework description.


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

https://reviews.llvm.org/D143953

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

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -193,3 +193,9 @@
 
 .attribute arch, "rv32iztso0p1"
 # CHECK: attribute  5, "rv32i2p0_ztso0p1"
+
+.attribute arch, "rv32izicsr2p0"
+# CHECK: attribute  5, "rv32i2p0_zicsr2p0"
+
+.attribute arch, "rv32izifencei2p0"
+# CHECK: attribute  5, "rv32i2p0_zifencei2p0"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -45,6 +45,8 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCB %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCD %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcf %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCF %s
+; RUN: llc -mtriple=riscv32 -mattr=+zicsr %s -o - | FileCheck --check-prefixes=CHECK,RV32ZICSR %s
+; RUN: llc -mtriple=riscv32 -mattr=+zifencei %s -o - | FileCheck --check-prefixes=CHECK,RV32ZIFENCEI %s
 
 ; RUN: llc -mtriple=riscv64 %s -o - | FileCheck %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefixes=CHECK,RV64M %s
@@ -97,6 +99,9 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zca %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCA %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCB %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCD %s
+; RUN: llc -mtriple=riscv64 -mattr=+zicsr %s -o - | FileCheck --check-prefixes=CHECK,RV64ZICSR %s
+; RUN: llc -mtriple=riscv64 -mattr=+zifencei %s -o - | FileCheck --check-prefixes=CHECK,RV64ZIFENCEI %s
+
 
 ; CHECK: .attribute 4, 16
 
@@ -144,6 +149,9 @@
 ; RV32ZCB: .attribute 5, "rv32i2p0_zca1p0_zcb1p0"
 ; RV32ZCD: .attribute 5, "rv32i2p0_zcd1p0"
 ; RV32ZCF: .attribute 5, "rv32i2p0_zcf1p0"
+; RV32ZICSR: .attribute 5, "rv32i2p0_zicsr2p0"
+; RV32ZIFENCEI: .attribute 5, "rv32i2p0_zifencei2p0"
+
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64ZMMUL: .attribute 5, "rv64i2p0_zmmul1p0"
@@ -195,6 +203,8 @@
 ; RV64ZCA: .attribute 5, "rv64i2p0_zca1p0"
 ; RV64ZCB: .attribute 5, "rv64i2p0_zca1p0_zcb1p0"
 ; RV64ZCD: .attribute 5, "rv64i2p0_zcd1p0"
+; RV64ZICSR: .attribute 5, "rv64i2p0_zicsr2p0"
+; RV64ZIFENCEI: .attribute 5, "rv64i2p0_zifencei2p0"
 
 define i32 @addi(i32 %a) {
   %1 = add i32 %a, 1
Index: llvm/lib/Target/RISCV/RISCVFeatures.td
===
--- llvm/lib/Target/RISCV/RISCVFeatures.td
+++ llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -71,6 +71,20 @@
 AssemblerPredicate<(all_of FeatureStdExtZihintntl),
 "'Zihintntl' (Non-Temporal Locality Hints)">;
 
+def FeatureStdExtZicsr
+: SubtargetFeature<"zicsr", "HasStdExtZicsr", "true",
+   "'zicsr' (CSRs)">;
+def HasStdExtZicsr : Predicate<"Subtarget->hasStdExtZicsr()">,
+AssemblerPredicate<(all_of FeatureStdExtZicsr),
+"'Zicsr' (CSRs)">;
+
+def FeatureStdExtZifencei
+: SubtargetFeature<"zifencei", "HasStdExtZifencei", "true",
+   "'zifencei' (ifence)">;
+def HasStdExtZifencei : Predicate<"Subtarget->hasStdExtZifencei()">,
+   AssemblerPredicate<(all_of FeatureStdExtZifencei),
+   "'Zifencei' (ifence)">;
+
 def FeatureStdExtZfhmin
 : SubtargetFeature<"zfhmin", "HasStdExtZfhmin", "true",
"'Zfhmin' (Half-Precision Floating-Point Minimal)",
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -103,6 +103,8 @@
 {"zicbom", RISCVExtensionVersion{1, 0}},
 {"zicboz", RISCVExtensionVersion{1, 0}},
 {"zicbop", RISCVExtensionVersion{1, 0}},
+{"zicsr", RISCVExtensionVersion{2, 0}},
+{"zifencei", RISCVExtensionVersion{2, 0}},
 
 {"svnapot", RISCVExtensionVersion{1, 0}},
 {"svpbmt", RISCVExtensionVersion{1, 0}},
Index: llvm/docs/RISCVUsage.rst
===
--- llvm/docs/RISCVUsage.rst
+++ llvm/

[PATCH] D144015: [OpenMP]Fix PR55970: Miscompile of collapse(3) with non-rectangular loop nest.

2023-02-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: mikerice.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
ABataev requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
Herald added projects: clang, OpenMP.

Need to assign the calculated lower bound back to temp variable,
otherwise incorrect value (upper bound instead of lower bound) might be
used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144015

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_codegen.cpp
  clang/test/OpenMP/tile_codegen.cpp
  openmp/runtime/test/worksharing/for/omp_for_collapse_non_rectangular.c

Index: openmp/runtime/test/worksharing/for/omp_for_collapse_non_rectangular.c
===
--- /dev/null
+++ openmp/runtime/test/worksharing/for/omp_for_collapse_non_rectangular.c
@@ -0,0 +1,22 @@
+// RUN: %libomp-compile-and-run
+
+#include 
+
+#define N 3
+
+int arr[N][N][N];
+int main() {
+#pragma omp for collapse(3)
+  for (unsigned int i = 0; i < N; ++i)
+for (unsigned int j = i; j < N; ++j)
+  for (unsigned int k = j; k < N; ++k)
+arr[i][j][k] = 1;
+  int num_failed = 0;
+  for (unsigned int i = 0; i < N; ++i)
+for (unsigned int j = 0; j < N; ++j)
+  for (unsigned int k = 0; k < N; ++k)
+if (arr[i][j][k] == (j >= i && k >= j) ? 0 : 1)
+  ++num_failed;
+
+  return num_failed;
+}
Index: clang/test/OpenMP/tile_codegen.cpp
===
--- clang/test/OpenMP/tile_codegen.cpp
+++ clang/test/OpenMP/tile_codegen.cpp
@@ -179,8 +179,8 @@
 // CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTCAPTURE_EXPR_:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTCAPTURE_EXPR_1:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTNEW_STEP:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTCAPTURE_EXPR_2:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[DOTCAPTURE_EXPR_3:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTFLOOR_0_IV_I:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTTILE_0_IV_I:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store i32 [[START]], ptr [[START_ADDR]], align 4
@@ -191,56 +191,56 @@
 // CHECK1-NEXT:[[TMP1:%.*]] = load i32, ptr [[END_ADDR]], align 4
 // CHECK1-NEXT:store i32 [[TMP1]], ptr [[DOTCAPTURE_EXPR_1]], align 4
 // CHECK1-NEXT:[[TMP2:%.*]] = load i32, ptr [[STEP_ADDR]], align 4
-// CHECK1-NEXT:store i32 [[TMP2]], ptr [[DOTCAPTURE_EXPR_2]], align 4
+// CHECK1-NEXT:store i32 [[TMP2]], ptr [[DOTNEW_STEP]], align 4
 // CHECK1-NEXT:[[TMP3:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
 // CHECK1-NEXT:[[TMP4:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]], align 4
 // CHECK1-NEXT:[[SUB:%.*]] = sub i32 [[TMP3]], [[TMP4]]
-// CHECK1-NEXT:[[SUB4:%.*]] = sub i32 [[SUB]], 1
-// CHECK1-NEXT:[[TMP5:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_2]], align 4
-// CHECK1-NEXT:[[ADD:%.*]] = add i32 [[SUB4]], [[TMP5]]
-// CHECK1-NEXT:[[TMP6:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_2]], align 4
+// CHECK1-NEXT:[[SUB3:%.*]] = sub i32 [[SUB]], 1
+// CHECK1-NEXT:[[TMP5:%.*]] = load i32, ptr [[DOTNEW_STEP]], align 4
+// CHECK1-NEXT:[[ADD:%.*]] = add i32 [[SUB3]], [[TMP5]]
+// CHECK1-NEXT:[[TMP6:%.*]] = load i32, ptr [[DOTNEW_STEP]], align 4
 // CHECK1-NEXT:[[DIV:%.*]] = udiv i32 [[ADD]], [[TMP6]]
-// CHECK1-NEXT:[[SUB5:%.*]] = sub i32 [[DIV]], 1
-// CHECK1-NEXT:store i32 [[SUB5]], ptr [[DOTCAPTURE_EXPR_3]], align 4
+// CHECK1-NEXT:[[SUB4:%.*]] = sub i32 [[DIV]], 1
+// CHECK1-NEXT:store i32 [[SUB4]], ptr [[DOTCAPTURE_EXPR_2]], align 4
 // CHECK1-NEXT:store i32 0, ptr [[DOTFLOOR_0_IV_I]], align 4
 // CHECK1-NEXT:br label [[FOR_COND:%.*]]
 // CHECK1:   for.cond:
 // CHECK1-NEXT:[[TMP7:%.*]] = load i32, ptr [[DOTFLOOR_0_IV_I]], align 4
-// CHECK1-NEXT:[[TMP8:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_3]], align 4
-// CHECK1-NEXT:[[ADD6:%.*]] = add i32 [[TMP8]], 1
-// CHECK1-NEXT:[[CMP:%.*]] = icmp ult i32 [[TMP7]], [[ADD6]]
-// CHECK1-NEXT:br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END18:%.*]]
+// CHECK1-NEXT:[[TMP8:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_2]], align 4
+// CHECK1-NEXT:[[ADD5:%.*]] = add i32 [[TMP8]], 1
+// CHECK1-NEXT:[[CMP:%.*]] = icmp ult i32 [[TMP7]], [[ADD5]]
+// CHECK1-NEXT:br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END17:%.*]]
 // CHECK1:   for.body:
 // CHECK1-NEXT:[[TMP9:%.*]] = load i32, ptr [[DOTFLOOR_0_IV_I]], align 4
 // CHECK1-NEXT:store i32 [[TMP9]], ptr [[DOTTILE_0_IV_I]], align 4
-// CHECK1-NEXT:br label [[FOR_COND7:%.*]]
-// CHECK1:   for.cond7:
+// CHECK1-NEXT:br label [[FOR_COND6:%.*]]
+// CHECK1:   for.cond6:
 // CHECK1-NEXT:[[TMP10:%.*]] = load i32, ptr [[DOTTILE_0_IV_I]], align 4
-// CHECK1-NEXT:[[TMP11:%.*]] = load i32, ptr

[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-14 Thread Philip Reames via Phabricator via cfe-commits
reames updated this revision to Diff 497336.
reames added a comment.

Address @jrtc27's comments.


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

https://reviews.llvm.org/D143953

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

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -193,3 +193,9 @@
 
 .attribute arch, "rv32iztso0p1"
 # CHECK: attribute  5, "rv32i2p0_ztso0p1"
+
+.attribute arch, "rv32izicsr2p0"
+# CHECK: attribute  5, "rv32i2p0_zicsr2p0"
+
+.attribute arch, "rv32izifencei2p0"
+# CHECK: attribute  5, "rv32i2p0_zifencei2p0"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -45,6 +45,8 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCB %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCD %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcf %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCF %s
+; RUN: llc -mtriple=riscv32 -mattr=+zicsr %s -o - | FileCheck --check-prefixes=CHECK,RV32ZICSR %s
+; RUN: llc -mtriple=riscv32 -mattr=+zifencei %s -o - | FileCheck --check-prefixes=CHECK,RV32ZIFENCEI %s
 
 ; RUN: llc -mtriple=riscv64 %s -o - | FileCheck %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefixes=CHECK,RV64M %s
@@ -97,6 +99,8 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zca %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCA %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCB %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCD %s
+; RUN: llc -mtriple=riscv64 -mattr=+zicsr %s -o - | FileCheck --check-prefixes=CHECK,RV64ZICSR %s
+; RUN: llc -mtriple=riscv64 -mattr=+zifencei %s -o - | FileCheck --check-prefixes=CHECK,RV64ZIFENCEI %s
 
 ; CHECK: .attribute 4, 16
 
@@ -144,6 +148,8 @@
 ; RV32ZCB: .attribute 5, "rv32i2p0_zca1p0_zcb1p0"
 ; RV32ZCD: .attribute 5, "rv32i2p0_zcd1p0"
 ; RV32ZCF: .attribute 5, "rv32i2p0_zcf1p0"
+; RV32ZICSR: .attribute 5, "rv32i2p0_zicsr2p0"
+; RV32ZIFENCEI: .attribute 5, "rv32i2p0_zifencei2p0"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64ZMMUL: .attribute 5, "rv64i2p0_zmmul1p0"
@@ -195,6 +201,8 @@
 ; RV64ZCA: .attribute 5, "rv64i2p0_zca1p0"
 ; RV64ZCB: .attribute 5, "rv64i2p0_zca1p0_zcb1p0"
 ; RV64ZCD: .attribute 5, "rv64i2p0_zcd1p0"
+; RV64ZICSR: .attribute 5, "rv64i2p0_zicsr2p0"
+; RV64ZIFENCEI: .attribute 5, "rv64i2p0_zifencei2p0"
 
 define i32 @addi(i32 %a) {
   %1 = add i32 %a, 1
Index: llvm/lib/Target/RISCV/RISCVFeatures.td
===
--- llvm/lib/Target/RISCV/RISCVFeatures.td
+++ llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -71,6 +71,20 @@
 AssemblerPredicate<(all_of FeatureStdExtZihintntl),
 "'Zihintntl' (Non-Temporal Locality Hints)">;
 
+def FeatureStdExtZicsr
+: SubtargetFeature<"zicsr", "HasStdExtZicsr", "true",
+   "'zicsr' (CSRs)">;
+def HasStdExtZicsr : Predicate<"Subtarget->hasStdExtZicsr()">,
+AssemblerPredicate<(all_of FeatureStdExtZicsr),
+"'Zicsr' (CSRs)">;
+
+def FeatureStdExtZifencei
+: SubtargetFeature<"zifencei", "HasStdExtZifencei", "true",
+   "'zifencei' (fence.i)">;
+def HasStdExtZifencei : Predicate<"Subtarget->hasStdExtZifencei()">,
+   AssemblerPredicate<(all_of FeatureStdExtZifencei),
+   "'Zifencei' (fence.i)">;
+
 def FeatureStdExtZfhmin
 : SubtargetFeature<"zfhmin", "HasStdExtZfhmin", "true",
"'Zfhmin' (Half-Precision Floating-Point Minimal)",
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -103,6 +103,8 @@
 {"zicbom", RISCVExtensionVersion{1, 0}},
 {"zicboz", RISCVExtensionVersion{1, 0}},
 {"zicbop", RISCVExtensionVersion{1, 0}},
+{"zicsr", RISCVExtensionVersion{2, 0}},
+{"zifencei", RISCVExtensionVersion{2, 0}},
 
 {"svnapot", RISCVExtensionVersion{1, 0}},
 {"svpbmt", RISCVExtensionVersion{1, 0}},
Index: llvm/docs/RISCVUsage.rst
===
--- llvm/docs/RISCVUsage.rst
+++ llvm/docs/RISCVUsage.rst
@@ -130,7 +130,7 @@
 .. _riscv-i

[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-02-14 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

You still have clang-format issues in your patch. Can you update that.


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

https://reviews.llvm.org/D140795

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


[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-14 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

We seem to have rough consensus here, but I'm going to wait roughly 24 hours 
before landing to give others time to comment.


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

https://reviews.llvm.org/D143953

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


[PATCH] D144016: [Sema] Relax a failing assertion in TransformBlockExpr

2023-02-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: arphaman, fahad, aaron.ballman.
ahatanak added a project: clang.
Herald added a project: All.
ahatanak requested review of this revision.

The assertion fails when the expression causing the this pointer to be captured 
is part of a constexpr if statement's branch and the branch gets discarded when 
the enclosing method is instantiated.

Note that the test case is added to CodeGen instead of Sema since the 
translation unit has to be free of errors in order for the assertion to be 
checked.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144016

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp


Index: clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp
===
--- clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp
+++ clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s 
--implicit-check-not=should_not_be_used
+// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -fblocks -o - | FileCheck %s 
--implicit-check-not=should_not_be_used
 
 void should_be_used_1();
 void should_be_used_2();
@@ -32,3 +32,20 @@
 // CHECK: should_be_used_1
 // CHECK: should_be_used_2
 // CHECK: should_be_used_3
+
+namespace BlockThisCapture {
+  void foo();
+  struct S {
+template 
+void m() {
+  ^{ if constexpr(b) (void)this; else foo();  }();
+}
+  };
+
+  void test() {
+S().m();
+  }
+}
+
+// CHECK-LABEL: define internal void 
@___ZN16BlockThisCapture1S1mILb0EEEvv_block_invoke(
+// CHECK: call void @_ZN16BlockThisCapture3fooEv(
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -14598,7 +14598,8 @@
  oldCapture));
   assert(blockScope->CaptureMap.count(newCapture));
 }
-assert(oldBlock->capturesCXXThis() == blockScope->isCXXThisCaptured());
+assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
+   "this pointer isn't captured in the old block");
   }
 #endif
 


Index: clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp
===
--- clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp
+++ clang/test/CodeGenCXX/cxx1z-constexpr-if.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used
+// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -fblocks -o - | FileCheck %s --implicit-check-not=should_not_be_used
 
 void should_be_used_1();
 void should_be_used_2();
@@ -32,3 +32,20 @@
 // CHECK: should_be_used_1
 // CHECK: should_be_used_2
 // CHECK: should_be_used_3
+
+namespace BlockThisCapture {
+  void foo();
+  struct S {
+template 
+void m() {
+  ^{ if constexpr(b) (void)this; else foo();  }();
+}
+  };
+
+  void test() {
+S().m();
+  }
+}
+
+// CHECK-LABEL: define internal void @___ZN16BlockThisCapture1S1mILb0EEEvv_block_invoke(
+// CHECK: call void @_ZN16BlockThisCapture3fooEv(
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -14598,7 +14598,8 @@
  oldCapture));
   assert(blockScope->CaptureMap.count(newCapture));
 }
-assert(oldBlock->capturesCXXThis() == blockScope->isCXXThisCaptured());
+assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
+   "this pointer isn't captured in the old block");
   }
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143996: [clang-tidy][doc] Remove unused variable

2023-02-14 Thread Björn Svensson via Phabricator via cfe-commits
bjosv updated this revision to Diff 497344.
bjosv added a comment.

Updated to fill 80 char as proposed, and changed some wordings.


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

https://reviews.llvm.org/D143996

Files:
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst


Index: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
@@ -32,7 +32,7 @@
 char h = 0;
 };
 
-Variables: ``a``, ``c``, ``c_ptr1``, ``c_ptr2``, ``c_const_ptr`` and
-``c_reference``, will all generate warnings since they are either:
-a globally accessible variable and non-const, a pointer or reference providing
-global access to non-const data or both.
+The variables ``a``, ``c``, ``c_ptr1``, ``c_const_ptr`` and ``c_reference``
+will all generate warnings since they are either a non-const globally 
accessible
+variable, a pointer or a reference providing global access to non-const data
+or both.


Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-non-const-global-variables.rst
@@ -32,7 +32,7 @@
 char h = 0;
 };
 
-Variables: ``a``, ``c``, ``c_ptr1``, ``c_ptr2``, ``c_const_ptr`` and
-``c_reference``, will all generate warnings since they are either:
-a globally accessible variable and non-const, a pointer or reference providing
-global access to non-const data or both.
+The variables ``a``, ``c``, ``c_ptr1``, ``c_const_ptr`` and ``c_reference``
+will all generate warnings since they are either a non-const globally accessible
+variable, a pointer or a reference providing global access to non-const data
+or both.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143436: [clangd] Apply standard adaptors to CDBs pushed from LSP

2023-02-14 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

In D143436#4122594 , @kadircet wrote:

> That's actually because we model compile commands pushed via LSP as a "fixed 
> compilation database" rather than a json compilation database (you can check 
> the code in `parseFixed`, near `parseJson`).
> The reason behind the discrepancy between fixed and json compilation 
> databases mostly arises from the fact that the former is written by people 
> specifically to be used by clang-tooling, whereas the latter is usually 
> provided by build system and doesn't necessarily have the same concerns as 
> clang-tooling hence requires certain modifications.

Thank you for sharing the context that I didn't know. I think it makes some 
sense but it requires duplication of this logic in some other places and 
keeping them up-to-date with driver changes.

> That being said, the two particular transformations (response files & 
> target/mode inference) seem like outliers when it comes to such 
> transformations. These are handled by clang-driver binary, outside of the 
> driver library, in 
> https://github.com/llvm/llvm-project/blob/main/clang/tools/driver/driver.cpp#L426
>  and 
> https://github.com/llvm/llvm-project/blob/main/clang/tools/driver/driver.cpp#L534.
>  Therefore all the other tools that wants to make use of clang infra tries to 
> simulate this logic, at different layers with slight differences (at the bare 
> minimum, as the logic isn't shared and people mostly care about the driver, 
> logic in other places just gets out-of-date).

I think clangd should be able to make this transformations if they are required 
even for "fixed" flags and it shouldn't change anything if compilation flags 
don't require them.

> I believe the right thing to do here is putting all that arg preparation 
> logic into driver library itself, so that all code paths that tries to create 
> a compiler invocation can have the same behaviour. Unfortunately this is 
> likely too hard to pull at this stage, due to people relying on almost every 
> implementation detail of these interfaces.
> So a middle ground would probably involve, moving that logic inside driver 
> binary to a common library, so that future users can at least directly use it 
> rather than trying to come up with their own interpretation (or trying to 
> chose from existing N patterns) and we'll get rid of the issues that result 
> from logic in this place and its duplicates getting out-of-sync. This way we 
> don't need to migrate all the applications that want to create a compiler 
> invocation to a new API and can only migrate clangd (CommandMangler is I 
> believe the right layer for these purposes. as it handles all "string"-like 
> modifications on the compile flags today).
>
> Does that make sense? Is it something you'd like to propose a patch for? 
> Because as things stand I think we're just making the matter worse here by 
> introducing some new code paths that're trying to emulate the logic in driver 
> today and will get out of sync at some point.

I see your point and it does make sense to me. I'll try to move logic to 
CommandMangler instead so both codepaths will share it. As for keeping up with 
driver changes, it is real issue and I'm not sure that we can solve this 
problem without using driver code almost "as is" that is not possible without 
serious refactoring. I'll ping you when changes are ready for review.




Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1350
+->getCompileCommands(File)[0]);
 if (Old != New) {
   CDB->setCompileCommand(File, std::move(New));

kadircet wrote:
> it looks like this comparison is no longer valid.
> 
> `OverlayCDB::getCompileCommand` will apply more modifications to the stored 
> flags than just expanding response files and inferring targets. I believe the 
> intent of this interaction was to treat compile flags from the LSP client 
> as-is without any modifications (as I explained more in my main comment).
> 
> No action needed right now, just thinking out-loud. I think the proper thing 
> to do here is apply these "common driver transformations" here, and store/use 
> the flags as is going forward inside clangd, without extra mangling.
I think it won't hurt anything and it was not very useful even before my 
change. Now it just prevent small extra work when you set the same arguments 
more than one on arguments are very simple so no transformation actually 
happening.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D143418: [libclang] Add API to set preferred temp dir path

2023-02-14 Thread Igor Kushnir via Phabricator via cfe-commits
vedgy added a comment.

In D143418#4125756 , @aaron.ballman 
wrote:

> In D143418#4125098 , @vedgy wrote:
>
>>> `uint32_t Size; // = sizeof(struct CIndexOptions), used for option 
>>> versioning`
>>
>> 1. `uint32_t` was introduced in C99. Can/should it be used in //Index.h//? 
>> Only built-in `[unsigned] (int|long)` types are currently used in this file.
>
> That is a really good question. I couldn't spot anything existing in the 
> header file that requires C99 or later (no // comments, no C99 types like 
> _Bool or uint32_t, etc). I think the common pattern would be to use 
> `unsigned`, which is also variably-sized (as are all the integer types, 
> technically, thanks to CHAR_BIT), but we do have one existing use of `size_t` 
> in the file, which is probably the best type to use there given that we 
> expect people to assign the results of `sizeof` into it. WDYT about using 
> `size_t`?
>
> I don't have the historical context to know whether we expect this header to 
> be C89 compatible, so it's not clear to me how disruptive it would be to use 
> stdint.h. One alternative would be to use stdint.h if it's available (via 
> `__has_include`) and otherwise fallback on a C89 custom definition of 
> uint32_t, but that strikes me as being more likely to introduce problems on 
> systems we don't test on or for compilers we don't test with.

`size_t` indeed makes logical sense for this member as that's the return type 
of `sizeof`. `size_t` is two times larger than `unsigned` on x86_64, but I 
don't think the size of this struct has any chance of impacting performance. 
Though it wouldn't hurt to pack the size and the boolean options in a 
single-pointer-sized region on x86_64. After all, this struct's size will never 
reach `UINT_MAX`. I slightly prefer `unsigned` due to my efficiency 
inclinations :). What do you prefer? Is there any benefit in using a fixed-size 
integer type here?

>> 2. Should `int excludeDeclarationsFromPCH` and `int displayDiagnostics` 
>> currently passed to `clang_createIndex()` also be included in the struct? 
>> Then only a single argument will be passed to 
>> `clang_createIndexWithOptions()`: `CXIndexOptions`.
>
> I think that makes sense to me. It does raise the question of whether we want 
> to pack these boolean-like fields together, as in:
>
>   struct CXIndexOptions {
> size_t Size;
>   
> int ExcludeDeclsFromPCH : 1;
> int DisplayDiagnostics : 1;
> int Reserved : 30;
>   
> const char *PreambleStoragePath;
> ...
>   };
>
> This makes it a little less likely to need to grow the structure when adding 
> new options.

When we add new options, the struct's size must grow in order to distinguish 
different struct versions and prevent undefined behavior! If a member is added 
within the same LLVM release, it and other members added in that release can be 
reordered and packed to minimize the size. For example, I plan to add a `bool 
StorePreamblesInMemory` in LLVM 17. While adding it, I can reorder and pack 
anything I like as the whole struct is introduced in this version. But there is 
no need to reserve anything, I think. This is assuming we don't need to support 
compatibility at each intermediate commit of libclang.

>> 3. `clang_createIndex()` initializes global options based on environment 
>> variable values:
>>
>>   if (getenv("LIBCLANG_BGPRIO_INDEX"))
>>   CIdxr->setCXGlobalOptFlags(CIdxr->getCXGlobalOptFlags() |
>>  
>> CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
>> if (getenv("LIBCLANG_BGPRIO_EDIT"))
>>   CIdxr->setCXGlobalOptFlags(CIdxr->getCXGlobalOptFlags() |
>>  
>> CXGlobalOpt_ThreadBackgroundPriorityForEditing);
>>
>> The recommended in documentation usage of `clang_CXIndex_setGlobalOptions` 
>> is:
>>
>>   * \code
>>   * CXIndex idx = ...;
>>   * clang_CXIndex_setGlobalOptions(idx,
>>   * clang_CXIndex_getGlobalOptions(idx) |
>>   * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
>>   * \endcode
>>
>> So making these options part of `struct CXIndexOptions` and deprecating 
>> `clang_CXIndex_setGlobalOptions` requires introducing another global 
>> function that would read the environment variables:
>>
>>   CINDEX_LINKAGE unsigned clang_getDefaultGlobalOptions();
>>
>> Is this the right approach?
>
> Hmm, to make this patch easier, I think we might want to leave the 
> environment variable behavior alone and not shift these into the options 
> structure (yet?). Naively, I think it makes sense for these to eventually 
> live in the options structure, but we could expose them in a few different 
> ways (an option to prefer the env variable over a manual value as it is today 
> or an option to prefer the manual value over the env variable for folks who 
> want more hermetic behavior). WDYT? My opinion here isn't super strong, so if 
> you have a strong desire to depreca

[PATCH] D143496: [clangd] Add support for missing includes analysis.

2023-02-14 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 497349.
VitaNuo marked 9 inline comments as done.
VitaNuo added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143496

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/Preamble.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
  clang-tools-extra/include-cleaner/lib/Analysis.cpp

Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -49,8 +49,8 @@
   }
 }
 
-static std::string spellHeader(const Header &H, HeaderSearch &HS,
-   const FileEntry *Main) {
+std::string spellHeader(const Header &H, HeaderSearch &HS,
+const FileEntry *Main) {
   switch (H.kind()) {
   case Header::Physical: {
 bool IsSystem = false;
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
@@ -73,6 +73,8 @@
 std::string fixIncludes(const AnalysisResults &Results, llvm::StringRef Code,
 const format::FormatStyle &IncludeStyle);
 
+std::string spellHeader(const Header &H, HeaderSearch &HS,
+const FileEntry *Main);
 } // namespace include_cleaner
 } // namespace clang
 
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -342,7 +342,8 @@
   auto AST = TU.build();
   EXPECT_THAT(computeUnusedIncludes(AST),
   ElementsAre(Pointee(writtenInclusion("";
-  EXPECT_THAT(computeUnusedIncludesExperimental(AST),
+  IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
+  EXPECT_THAT(Findings.UnusedIncludes,
   ElementsAre(Pointee(writtenInclusion("";
 }
 
@@ -379,12 +380,58 @@
   computeUnusedIncludes(AST),
   UnorderedElementsAre(Pointee(writtenInclusion("\"unused.h\"")),
Pointee(writtenInclusion("\"dir/unused.h\"";
+
+  IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
   EXPECT_THAT(
-  computeUnusedIncludesExperimental(AST),
+  Findings.UnusedIncludes,
   UnorderedElementsAre(Pointee(writtenInclusion("\"unused.h\"")),
Pointee(writtenInclusion("\"dir/unused.h\"";
 }
 
+TEST(IncludeCleaner, GetMissingHeaders) {
+  llvm::StringLiteral MainFile = R"cpp(
+#include "a.h"
+#include "dir/c.h"
+#include 
+
+void foo() {
+  b();
+  d();
+  f();
+})cpp";
+  // Build expected ast with symbols coming from headers.
+  TestTU TU;
+  TU.Filename = "foo.cpp";
+  TU.AdditionalFiles["foo.h"] = guard("void foo();");
+  TU.AdditionalFiles["a.h"] = guard("#include \"b.h\"");
+  TU.AdditionalFiles["b.h"] = guard("void b();");
+
+  TU.AdditionalFiles["dir/c.h"] = guard("#include \"d.h\"");
+  TU.AdditionalFiles["dir/d.h"] = guard("void d();");
+
+  TU.AdditionalFiles["system/e.h"] = guard("#include ");
+  TU.AdditionalFiles["system/f.h"] = guard("void f();");
+  TU.ExtraArgs.push_back("-isystem" + testPath("system"));
+
+  TU.Code = MainFile.str();
+  ParsedAST AST = TU.build();
+
+  IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
+  std::vector Names;
+  std::vector> TokenTexts;
+  for (const auto &MissingInclude : Findings.MissingIncludes) {
+std::vector TokenText;
+for (const auto &Token : MissingInclude.getValue())
+  TokenText.push_back(std::string{Token.text(AST.getSourceManager())});
+Names.push_back(MissingInclude.getKey());
+TokenTexts.push_back(TokenText);
+  }
+  EXPECT_THAT(Names, UnorderedElementsAre("\"b.h\"", "\"dir/d.h\"", ""));
+  EXPECT_THAT(TokenTexts, UnorderedElementsAre(UnorderedElementsAre("b"),
+   UnorderedElementsAre("d"),
+   UnorderedElementsAre("f")));
+}
+
 TEST(IncludeCleaner, VirtualBuffers) {
   TestTU TU;
   TU.Code = R"cpp(
@@ -554,7 +601,8 @

[PATCH] D143921: [debug-info][codegen] Prevent creation of self-referential SP node

2023-02-14 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.

Test looks good!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143921

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


[PATCH] D143496: [clangd] Add support for missing includes analysis.

2023-02-14 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

Thank you for the comments! I've addressed (almost) all of them. In some 
places, I'm not so happy about how the code has become very nested, but I don't 
have ideas on how to make it better atm.




Comment at: clang-tools-extra/clangd/Config.h:91
 
+  enum class MissingIncludesPolicy {
+/// Diagnose missing includes.

kadircet wrote:
> rather than duplicating, what about renaming `UnusedIncludesPolicy` to 
> `IncludesPolicy` and use it for both `UnusedIncludes` and `MissingIncludes` 
> options below?
Sure.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:516
+
+  std::vector Macros =
+  collectMacroReferences(AST);

kadircet wrote:
> 
Why would you use `auto` here? The return type is not obvious from the function 
call.

The style guide says: "types that you and your reviewer experience as 
unnecessary clutter will very often provide useful information to others. For 
example, you can assume that the return type of `make_unique()` is 
obvious, but the return type of `MyWidgetFactory()` probably isn't." 
(http://go/cstyle#Type_deduction)



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:547
+convertIncludes(const SourceManager &SM,
+std::vector MainFileIncludes) {
+  include_cleaner::Includes Includes;

kadircet wrote:
> you can just pass an `llvm::ArrayRef` to prevent a copy
By preventing a copy, do you mean that the construction of 
`llvm::ArrayRef` will only copy a pointer to the data rather than 
the whole vector? AFAIU `const std::vector&` should be even better 
then, no copies involved. CMIIW.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:550
+  for (const Inclusion &Inc : MainFileIncludes) {
+llvm::ErrorOr ResolvedOrError =
+SM.getFileManager().getFile(Inc.Resolved);

kadircet wrote:
> you can re-write this as:
> ```
> include_cleaner::Include TransformedInc;
> TransformedInc.Spelled = Inc.Written.trim("\"<>");
> TransformedInc.HashLocation = SM.getComposedLoc(SM.getMainFileID(), 
> Inc.HashOffset); // we should actually convert this from a SourceLocation to 
> offset in include_cleaner::Include as well
> TransformedInc.Line = Inc.HashLine;
> TransformedInc.Angled = WrittenRef.starts_with("<");
> if(auto FE = SM.getFileManager().getFile(Inc.Resolved))
>   TransformedInc.Resolved = *FE;
> Includes.add(std::move(TransformedInc));
> ```
Thanks.
It seems like `std::string` does not have a `trim` or a `starts_with` method, 
so AFAIU I still need to call the `llvm::StringRef` constructor.





Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:570
+computeMissingIncludes(ParsedAST &AST) {
+  std::vector Macros =
+  collectMacroReferences(AST);

kadircet wrote:
> nit: `auto Macros = ..`
Same as above. I am not sure about the benefit of `auto` here..



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:577
+  convertIncludes(AST.getSourceManager(), MainFileIncludes);
+  std::string FileName =
+  AST.getSourceManager()

kadircet wrote:
> you can use `AST.tuPath()`
Thanks, but this actually seems unused. It was some debugging artefact too.. :(



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:582
+  .str();
+  if (FileName.find("foo") != std::string::npos) {
+vlog("Include cleaner includes: {0}", IncludeCleanerIncludes.all().size());

kadircet wrote:
> looks like debugging artifact?
sorry.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:593
+  llvm::ArrayRef Providers) {
+bool Satisfied = false;
+for (const include_cleaner::Header &H : Providers) {

kadircet wrote:
> nit: you can check whether `Ref.RT` is `Explicit` at the top, and bail out 
> early.
This seems obsolete after merging the missing and unused includes analyses 
together. There is no obvious place to insert the check.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:597
+  H.physical() == MainFile) {
+Satisfied = true;
+  }

kadircet wrote:
> nit: you can just `break` after satisfying the include (same below)
Not if the unused and missing include analyses are merged together.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:605
+Ref.RT == include_cleaner::RefType::Explicit) {
+  std::string SpelledHeader = include_cleaner::spellHeader(
+  Providers.front(), AST.getPreprocessor().getHeaderSearchInfo(),

kadircet wrote:
> clangd has some header spelling customizations. so we should actually be 
> doing this through 
> `URI::includeSpelling(URI::create(getCanonicalPath(Providers.front().physical(),
>  SM)))` first, and fall back to `spellHeader` if it fails for physical header 
> pr

[clang] f4d8b87 - [AMDGPU ASAN] Remove reference to asan bitcode library

2023-02-14 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-02-14T11:52:41-05:00
New Revision: f4d8b8781de9b0efbaf79621ff66c16964bb1df2

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

LOG: [AMDGPU ASAN] Remove reference to asan bitcode library

The asan functions are now attributed as used
in the device library, no need to keep the
declaration of asan device preserve function.

Patch by: Praveen Velliengiri

Reviewed by: Yaxun Liu

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 
clang/test/CodeGenCUDA/amdgpu-asan.cu



diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 71a2f61ea955f..90c9df4ea4423 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -580,20 +580,6 @@ void CodeGenModule::Release() {
 EmitMainVoidAlias();
 
   if (getTriple().isAMDGPU()) {
-// Emit reference of __amdgpu_device_library_preserve_asan_functions to
-// preserve ASAN functions in bitcode libraries.
-if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
-  auto *FT = llvm::FunctionType::get(VoidTy, {});
-  auto *F = llvm::Function::Create(
-  FT, llvm::GlobalValue::ExternalLinkage,
-  "__amdgpu_device_library_preserve_asan_functions", &getModule());
-  auto *Var = new llvm::GlobalVariable(
-  getModule(), FT->getPointerTo(),
-  /*isConstant=*/true, llvm::GlobalValue::WeakAnyLinkage, F,
-  "__amdgpu_device_library_preserve_asan_functions_ptr", nullptr,
-  llvm::GlobalVariable::NotThreadLocal);
-  addCompilerUsedGlobal(Var);
-}
 // Emit amdgpu_code_object_version module flag, which is code object 
version
 // times 100.
 if (getTarget().getTargetOpts().CodeObjectVersion !=

diff  --git a/clang/test/CodeGenCUDA/amdgpu-asan.cu 
b/clang/test/CodeGenCUDA/amdgpu-asan.cu
deleted file mode 100644
index 9c505fe2346ba..0
--- a/clang/test/CodeGenCUDA/amdgpu-asan.cu
+++ /dev/null
@@ -1,31 +0,0 @@
-// Create a sample address sanitizer bitcode library.
-
-// RUN: %clang_cc1 -x ir -fcuda-is-device -triple amdgcn-amd-amdhsa 
-emit-llvm-bc \
-// RUN:   -disable-llvm-passes -o %t.asanrtl.bc %S/Inputs/amdgpu-asanrtl.ll
-
-// Check sanitizer runtime library functions survive
-// optimizations without being removed or parameters altered.
-
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
-// RUN:   -mlink-bitcode-file %t.asanrtl.bc -x hip \
-// RUN:   | FileCheck -check-prefixes=ASAN %s
-
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
-// RUN:   -O3 -mlink-bitcode-file %t.asanrtl.bc -x hip \
-// RUN:   | FileCheck -check-prefixes=ASAN %s
-
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device -target-cpu gfx906 -x hip \
-// RUN:   | FileCheck %s
-
-// REQUIRES: amdgpu-registered-target
-
-// ASAN-DAG: define weak void 
@__amdgpu_device_library_preserve_asan_functions()
-// ASAN-DAG: @__amdgpu_device_library_preserve_asan_functions_ptr = weak 
addrspace(1) constant ptr @__amdgpu_device_library_preserve_asan_functions
-// ASAN-DAG: @llvm.compiler.used = 
{{.*}}@__amdgpu_device_library_preserve_asan_functions_ptr
-// ASAN-DAG: define weak void @__asan_report_load1(i64 %{{.*}})
-
-// CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions
-// CHECK-NOT: @__asan_report_load1



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


[PATCH] D143495: [AMDGPU ASAN] Remove reference to asan bitcode library

2023-02-14 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4d8b8781de9: [AMDGPU ASAN] Remove reference to asan bitcode 
library (authored by yaxunl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143495

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/amdgpu-asan.cu


Index: clang/test/CodeGenCUDA/amdgpu-asan.cu
===
--- clang/test/CodeGenCUDA/amdgpu-asan.cu
+++ /dev/null
@@ -1,31 +0,0 @@
-// Create a sample address sanitizer bitcode library.
-
-// RUN: %clang_cc1 -x ir -fcuda-is-device -triple amdgcn-amd-amdhsa 
-emit-llvm-bc \
-// RUN:   -disable-llvm-passes -o %t.asanrtl.bc %S/Inputs/amdgpu-asanrtl.ll
-
-// Check sanitizer runtime library functions survive
-// optimizations without being removed or parameters altered.
-
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
-// RUN:   -mlink-bitcode-file %t.asanrtl.bc -x hip \
-// RUN:   | FileCheck -check-prefixes=ASAN %s
-
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
-// RUN:   -O3 -mlink-bitcode-file %t.asanrtl.bc -x hip \
-// RUN:   | FileCheck -check-prefixes=ASAN %s
-
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device -target-cpu gfx906 -x hip \
-// RUN:   | FileCheck %s
-
-// REQUIRES: amdgpu-registered-target
-
-// ASAN-DAG: define weak void 
@__amdgpu_device_library_preserve_asan_functions()
-// ASAN-DAG: @__amdgpu_device_library_preserve_asan_functions_ptr = weak 
addrspace(1) constant ptr @__amdgpu_device_library_preserve_asan_functions
-// ASAN-DAG: @llvm.compiler.used = 
{{.*}}@__amdgpu_device_library_preserve_asan_functions_ptr
-// ASAN-DAG: define weak void @__asan_report_load1(i64 %{{.*}})
-
-// CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions
-// CHECK-NOT: @__asan_report_load1
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -580,20 +580,6 @@
 EmitMainVoidAlias();
 
   if (getTriple().isAMDGPU()) {
-// Emit reference of __amdgpu_device_library_preserve_asan_functions to
-// preserve ASAN functions in bitcode libraries.
-if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
-  auto *FT = llvm::FunctionType::get(VoidTy, {});
-  auto *F = llvm::Function::Create(
-  FT, llvm::GlobalValue::ExternalLinkage,
-  "__amdgpu_device_library_preserve_asan_functions", &getModule());
-  auto *Var = new llvm::GlobalVariable(
-  getModule(), FT->getPointerTo(),
-  /*isConstant=*/true, llvm::GlobalValue::WeakAnyLinkage, F,
-  "__amdgpu_device_library_preserve_asan_functions_ptr", nullptr,
-  llvm::GlobalVariable::NotThreadLocal);
-  addCompilerUsedGlobal(Var);
-}
 // Emit amdgpu_code_object_version module flag, which is code object 
version
 // times 100.
 if (getTarget().getTargetOpts().CodeObjectVersion !=


Index: clang/test/CodeGenCUDA/amdgpu-asan.cu
===
--- clang/test/CodeGenCUDA/amdgpu-asan.cu
+++ /dev/null
@@ -1,31 +0,0 @@
-// Create a sample address sanitizer bitcode library.
-
-// RUN: %clang_cc1 -x ir -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm-bc \
-// RUN:   -disable-llvm-passes -o %t.asanrtl.bc %S/Inputs/amdgpu-asanrtl.ll
-
-// Check sanitizer runtime library functions survive
-// optimizations without being removed or parameters altered.
-
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
-// RUN:   -mlink-bitcode-file %t.asanrtl.bc -x hip \
-// RUN:   | FileCheck -check-prefixes=ASAN %s
-
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
-// RUN:   -O3 -mlink-bitcode-file %t.asanrtl.bc -x hip \
-// RUN:   | FileCheck -check-prefixes=ASAN %s
-
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
-// RUN:   -fcuda-is-device -target-cpu gfx906 -x hip \
-// RUN:   | FileCheck %s
-
-// REQUIRES: amdgpu-registered-target
-
-// ASAN-DAG: define weak void @__amdgpu_device_library_preserve_asan_functions()
-// ASAN-DAG: @__amdgpu_device_library_preserve_asan_functions_ptr = weak addrspace(1) constant ptr @__amdgpu_device_library_preserve_asan_functions
-// ASAN-DAG: @llvm.compiler.used = {{.*}}@__amdgpu_device_library_preserve_asan_functions_ptr
-// ASAN-DAG: define weak void @__asan_report_load1(i64 %{{.*}})
-
-// CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions
-// CHECK-NOT: @__asan_report_load1
Index: clang/lib/CodeGen/C

[PATCH] D142578: [Clang][Doc] Edit the Clang release notes

2023-02-14 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson closed this revision.
royjacobson added a comment.

Landed in 
https://github.com/llvm/llvm-project/commit/be701ab08f12daf9437c2db6d08a1731cf1df34c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142578

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


[clang] 574d0c2 - [clang][test][RISCV] Fix precision of CHECK-NOT lines in riscv-target-features.c

2023-02-14 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-02-14T16:55:03Z
New Revision: 574d0c2ec107cd3bfb753424150624276fe43813

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

LOG: [clang][test][RISCV] Fix precision of CHECK-NOT lines in 
riscv-target-features.c

`CHECK-NOT: __riscv_f 200{{$}}` was overly precise, in that it
wouldn't test what we want it to if the version of the F extension was
bumped. Meanwhile, lines like `CHECK-NOT: __riscv_d` were too imprecise,
as they would match any define with that prefix (e.g.
`__riscv_dsomethingelse`).

This patch just updates these lines to check for `__riscv_foo {{.*$}}`.

Added: 


Modified: 
clang/test/Preprocessor/riscv-target-features.c

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 9f3ab6ff03ec5..3f643a2fb5871 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -3,52 +3,52 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64i -x c -E -dM %s \
 // RUN: -o - | FileCheck %s
 
-// CHECK-NOT: __riscv_div
-// CHECK-NOT: __riscv_m
-// CHECK-NOT: __riscv_mul
-// CHECK-NOT: __riscv_muldiv
-// CHECK-NOT: __riscv_a 200{{$}}
+// CHECK-NOT: __riscv_div {{.*$}}
+// CHECK-NOT: __riscv_m {{.*$}}
+// CHECK-NOT: __riscv_mul {{.*$}}
+// CHECK-NOT: __riscv_muldiv {{.*$}}
+// CHECK-NOT: __riscv_a {{.*$}}
 // CHECK-NOT: __riscv_atomic
-// CHECK-NOT: __riscv_f 200{{$}}
-// CHECK-NOT: __riscv_d
-// CHECK-NOT: __riscv_flen
-// CHECK-NOT: __riscv_fdiv
-// CHECK-NOT: __riscv_fsqrt
-// CHECK-NOT: __riscv_c 200{{$}}
-// CHECK-NOT: __riscv_compressed
-// CHECK-NOT: __riscv_b
-// CHECK-NOT: __riscv_bitmanip
-// CHECK-NOT: __riscv_zihintntl
-// CHECK-NOT: __riscv_zba
-// CHECK-NOT: __riscv_zbb
-// CHECK-NOT: __riscv_zbc
-// CHECK-NOT: __riscv_zbs
-// CHECK-NOT: __riscv_zfh
-// CHECK-NOT: __riscv_v
-// CHECK-NOT: __riscv_vector
-// CHECK-NOT: __riscv_v_intrinsic
-// CHECK-NOT: __riscv_zbkc
-// CHECK-NOT: __riscv_zbkx
-// CHECK-NOT: __riscv_zbkb
-// CHECK-NOT: __riscv_zkne
-// CHECK-NOT: __riscv_zknd
-// CHECK-NOT: __riscv_zknh
-// CHECK-NOT: __riscv_zksh
-// CHECK-NOT: __riscv_zksed
-// CHECK-NOT: __riscv_zkr
-// CHECK-NOT: __riscv_zkt
-// CHECK-NOT: __riscv_zk
-// CHECK-NOT: __riscv_zicbom
-// CHECK-NOT: __riscv_zicboz
-// CHECK-NOT: __riscv_svnapot
-// CHECK-NOT: __riscv_svpbmt
-// CHECK-NOT: __riscv_svinval
-// CHECK-NOT: __riscv_xventanacondops
-// CHECK-NOT: __riscv_zca
-// CHECK-NOT: __riscv_zcb
-// CHECK-NOT: __riscv_zcd
-// CHECK-NOT: __riscv_zcf
-// CHECK-NOT: __riscv_h
+// CHECK-NOT: __riscv_f {{.*$}}
+// CHECK-NOT: __riscv_d {{.*$}}
+// CHECK-NOT: __riscv_flen {{.*$}}
+// CHECK-NOT: __riscv_fdiv {{.*$}}
+// CHECK-NOT: __riscv_fsqrt {{.*$}}
+// CHECK-NOT: __riscv_c {{.*$}}
+// CHECK-NOT: __riscv_compressed {{.*$}}
+// CHECK-NOT: __riscv_b {{.*$}}
+// CHECK-NOT: __riscv_bitmanip {{.*$}}
+// CHECK-NOT: __riscv_zihintntl {{.*$}}
+// CHECK-NOT: __riscv_zba {{.*$}}
+// CHECK-NOT: __riscv_zbb {{.*$}}
+// CHECK-NOT: __riscv_zbc {{.*$}}
+// CHECK-NOT: __riscv_zbs {{.*$}}
+// CHECK-NOT: __riscv_zfh {{.*$}}
+// CHECK-NOT: __riscv_v {{.*$}}
+// CHECK-NOT: __riscv_vector {{.*$}}
+// CHECK-NOT: __riscv_v_intrinsic {{.*$}}
+// CHECK-NOT: __riscv_zbkc {{.*$}}
+// CHECK-NOT: __riscv_zbkx {{.*$}}
+// CHECK-NOT: __riscv_zbkb {{.*$}}
+// CHECK-NOT: __riscv_zkne {{.*$}}
+// CHECK-NOT: __riscv_zknd {{.*$}}
+// CHECK-NOT: __riscv_zknh {{.*$}}
+// CHECK-NOT: __riscv_zksh {{.*$}}
+// CHECK-NOT: __riscv_zksed {{.*$}}
+// CHECK-NOT: __riscv_zkr {{.*$}}
+// CHECK-NOT: __riscv_zkt {{.*$}}
+// CHECK-NOT: __riscv_zk {{.*$}}
+// CHECK-NOT: __riscv_zicbom {{.*$}}
+// CHECK-NOT: __riscv_zicboz {{.*$}}
+// CHECK-NOT: __riscv_svnapot {{.*$}}
+// CHECK-NOT: __riscv_svpbmt {{.*$}}
+// CHECK-NOT: __riscv_svinval {{.*$}}
+// CHECK-NOT: __riscv_xventanacondops {{.*$}}
+// CHECK-NOT: __riscv_zca {{.*$}}
+// CHECK-NOT: __riscv_zcb {{.*$}}
+// CHECK-NOT: __riscv_zcd {{.*$}}
+// CHECK-NOT: __riscv_zcf {{.*$}}
+// CHECK-NOT: __riscv_h {{.*$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s



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


[clang] d05e1e9 - [clang][test][RISCV] Check for __riscv_i in riscv-target-features.c

2023-02-14 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-02-14T17:02:32Z
New Revision: d05e1e99b1d62cf1f8ab37f83dd2f377328dd9c5

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

LOG: [clang][test][RISCV] Check for __riscv_i in riscv-target-features.c

This was overlooked, even though we have comprehensive tests for all the
other __riscv_fooext defines.

Added: 


Modified: 
clang/test/Preprocessor/riscv-target-features.c

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 3f643a2fb587..139c84b08f16 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -49,6 +49,7 @@
 // CHECK-NOT: __riscv_zcd {{.*$}}
 // CHECK-NOT: __riscv_zcf {{.*$}}
 // CHECK-NOT: __riscv_h {{.*$}}
+// CHECK: __riscv_i 200{{$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s



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


[PATCH] D143522: [AMDGPU] Set a data layout entry for buffer descriptors (addrspace 7)

2023-02-14 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 added a reviewer: piotr.
krzysz00 added a comment.

Discussion related to this is also happening over at 
https://reviews.llvm.org/D143945 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143522

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


[PATCH] D143501: [clang][DebugInfo] lldb: Use preferred name's type when emitting DW_AT_names

2023-02-14 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

> Alternatively, I suppose, the DWARF emission could just look at the preferred 
> name and use that as the DW_AT_type in all cases anyway? Avoids needing a new 
> attribute, etc, though would be a bit quirky in its own way.

Am I understanding you correctly that you suggest we add a new preferred name 
attribute to DICompositeType and then swap out all uses of those types with 
references to a typedef using the preferred name and pointing to the unmodified 
type declaration in AsmPrinter?
Why wouldn't we just implement this directly in CGDebugInfo and emit a 
DIDerivedType(name: "preferred", type: ) and replace all uses of 
 there? Then we wouldn't have to modify the IR format at all?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143501

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


[PATCH] D142604: [Clang] Fix __VA_OPT__ implementation so that it treats the concatenation of a non-placemaker token and placemaker token as a non-placemaker token

2023-02-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Ping


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

https://reviews.llvm.org/D142604

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


[PATCH] D143851: [clang-tidy] Tweak 'rule of 3/5' checks to allow defaulting a destructor outside the class.

2023-02-14 Thread Piotr Zegar via Phabricator via cfe-commits
ClockMan added a comment.

Thing is that same issue may happen with all other members, what about 
copy/move constructors defaulted in .cpp (just to speed up compilation for 
classes with many members).
Best thing would simply to check if all definitions are available. In that case 
issues would be reported only for source file that corresponds to header file 
with defined class.
This would also reduce amount of generated warnings for a big project that 
include such header with class in many places.

Other good option would be to excluded classes defined in system headers, no 
point to check if some boost class or std::vector got proper constructors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143851

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


[PATCH] D142604: [Clang] Fix __VA_OPT__ implementation so that it treats the concatenation of a non-placemaker token and placemaker token as a non-placemaker token

2023-02-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added subscribers: cor3ntin, tahonermann.
erichkeane added a comment.

Pretty sure @cor3ntin and @tahonermann are our Lexer code owners?  Or at least 
were in the initial proposal.


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

https://reviews.llvm.org/D142604

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


[PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private

2023-02-14 Thread Vasileios Porpodas via Phabricator via cfe-commits
vporpo created this revision.
vporpo added a reviewer: aeubanks.
Herald added subscribers: mattd, gchakrabarti, asavonic, snehasish, ormris, 
hiraditya.
Herald added a project: All.
vporpo requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, jholewinski.
Herald added projects: clang, LLDB, LLVM.

This patch adds several missing GlobalList modifier functions, like
removeGlobalVariable(), eraseGlobalVariable() and insertGlobalVariable().
There is no longer need to access the list directly so it also makes
getGlobalList() private.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144027

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  llvm/docs/ProgrammersManual.rst
  llvm/include/llvm/IR/Module.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/IR/Globals.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/IPO/SCCP.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/CtorUtils.cpp
  llvm/unittests/IR/ModuleTest.cpp

Index: llvm/unittests/IR/ModuleTest.cpp
===
--- llvm/unittests/IR/ModuleTest.cpp
+++ llvm/unittests/IR/ModuleTest.cpp
@@ -46,8 +46,11 @@
 
 // Sort the globals by name.
 EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare));
-M.getGlobalList().sort(compare);
-EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare));
+// I removed this because it is testing whether ilist.sort() works, which is
+// not Module-specific. This requires access to the full GlobalList for no
+// real reason.
+// M.getGlobalList().sort(compare);
+// EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare));
   }
 }
 
@@ -273,4 +276,43 @@
   EXPECT_EQ(M->named_metadata_size(), 2u);
 }
 
+TEST(ModuleTest, GlobalList) {
+  // This tests all Module's functions that interact with Module::GlobalList.
+  LLVMContext C;
+  SMDiagnostic Err;
+  LLVMContext Context;
+  std::unique_ptr M = parseAssemblyString(R"(
+@GV = external global i32
+)",
+  Err, Context);
+  auto *GV = cast(M->getNamedValue("GV"));
+  EXPECT_EQ(M->global_size(), 1u);
+  GlobalVariable *NewGV = new GlobalVariable(
+  Type::getInt32Ty(C), /*isConstant=*/true, GlobalValue::InternalLinkage,
+  /*Initializer=*/nullptr, "NewGV");
+  EXPECT_EQ(M->global_size(), 1u);
+  // Insert before
+  M->insertGlobalVariable(M->globals().begin(), NewGV);
+  EXPECT_EQ(M->global_size(), 2u);
+  EXPECT_EQ(&*M->globals().begin(), NewGV);
+  // Insert at end()
+  M->removeGlobalVariable(NewGV);
+  EXPECT_EQ(M->global_size(), 1u);
+  M->insertGlobalVariable(NewGV);
+  EXPECT_EQ(M->global_size(), 2u);
+  EXPECT_EQ(&*std::prev(M->globals().end()), NewGV);
+  // Check globals()
+  auto Range = M->globals();
+  EXPECT_EQ(&*Range.begin(), GV);
+  EXPECT_EQ(&*std::next(Range.begin()), NewGV);
+  EXPECT_EQ(std::next(Range.begin(), 2), Range.end());
+  // Check remove
+  M->removeGlobalVariable(NewGV);
+  EXPECT_EQ(M->global_size(), 1u);
+  // Check erase
+  M->insertGlobalVariable(NewGV);
+  M->eraseGlobalVariable(NewGV);
+  EXPECT_EQ(M->global_size(), 1u);
+}
+
 } // end namespace
Index: llvm/lib/Transforms/Utils/CtorUtils.cpp
===
--- llvm/lib/Transforms/Utils/CtorUtils.cpp
+++ llvm/lib/Transforms/Utils/CtorUtils.cpp
@@ -48,7 +48,7 @@
   GlobalVariable *NGV =
   new GlobalVariable(CA->getType(), GCL->isConstant(), GCL->getLinkage(),
  CA, "", GCL->getThreadLocalMode());
-  GCL->getParent()->getGlobalList().insert(GCL->getIterator(), NGV);
+  GCL->getParent()->insertGlobalVariable(GCL->getIterator(), NGV);
   NGV->takeName(GCL);
 
   // Nuke the old list, replacing any uses with the new one.
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -958,7 +958,7 @@
 std::vector &Bits,
 DenseMap> &TypeIdMap) {
   DenseMap GVToBits;
-  Bits.reserve(M.getGlobalList().size());
+  Bits.reserve(M.global_size());
   SmallVector Types;
   for (GlobalVariable &GV : M.globals()) {
 Types.clear();
Index: llvm/lib/Transforms/IPO/SCCP.cpp
===
--- llvm/lib/Transforms/IPO/SCCP.cpp
+++ llvm/lib/Transforms/IPO/SCCP.cpp
@@ -370,7 +370,7 @@
   SI->eraseFromParent();
   MadeChanges = true;
 }
-M.getGlobalList().erase(GV);
+M.eraseGlobalVariable(GV);
 ++NumGlobalConst;
   }
 
@@ -476,4 +476,3 @@
 
 // createIPSCCPPass - This is the public interface to this 

[PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private

2023-02-14 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks accepted this revision.
aeubanks added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/unittests/IR/ModuleTest.cpp:49
 EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare));
-M.getGlobalList().sort(compare);
-EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare));
+// I removed this because it is testing whether ilist.sort() works, which 
is
+// not Module-specific. This requires access to the full GlobalList for no

can just delete the commented out lines and add the reasoning behind deleting 
this either as a phabricator comment or in the commit description


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144027

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


[PATCH] D144015: [OpenMP]Fix PR55970: Miscompile of collapse(3) with non-rectangular loop nest.

2023-02-14 Thread Mike Rice via Phabricator via cfe-commits
mikerice accepted this revision.
mikerice added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144015

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


[PATCH] D143851: [clang-tidy] Tweak 'rule of 3/5' checks to allow defaulting a destructor outside the class.

2023-02-14 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

In D143851#4126453 , @ClockMan wrote:

> Thing is that same issue may happen with all other members, what about 
> copy/move constructors defaulted in .cpp (just to speed up compilation for 
> classes with many members).
> Best thing would simply to check if all definitions are available. In that 
> case issues would be reported only for source file that corresponds to header 
> file with defined class.
> This would also reduce amount of generated warnings for a big project that 
> include such header with class in many places.
>
> Other good option would be to excluded classes defined in system headers, no 
> point to check if some boost class or std::vector got proper constructors.

Defaulting destructors is usually fine, but explicitly defaulting copy/move 
constructors implicitly deletes the other special member functions which this 
check should diagnose.
This is why this option was only available for destructors in the first place, 
I imagine.

About the second point - this sounds pretty general, doesn't clang-tidy already 
filter diagnostics in system headers? At least Clang does.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143851

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


[PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private

2023-02-14 Thread Vasileios Porpodas via Phabricator via cfe-commits
vporpo updated this revision to Diff 497367.
vporpo marked an inline comment as done.
vporpo added a comment.

Removed commented out lines from ModuleTest.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144027

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  llvm/docs/ProgrammersManual.rst
  llvm/include/llvm/IR/Module.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/IR/Globals.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/IPO/SCCP.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/CtorUtils.cpp
  llvm/unittests/IR/ModuleTest.cpp

Index: llvm/unittests/IR/ModuleTest.cpp
===
--- llvm/unittests/IR/ModuleTest.cpp
+++ llvm/unittests/IR/ModuleTest.cpp
@@ -46,8 +46,6 @@
 
 // Sort the globals by name.
 EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare));
-M.getGlobalList().sort(compare);
-EXPECT_TRUE(std::is_sorted(M.global_begin(), M.global_end(), compare));
   }
 }
 
@@ -273,4 +271,43 @@
   EXPECT_EQ(M->named_metadata_size(), 2u);
 }
 
+TEST(ModuleTest, GlobalList) {
+  // This tests all Module's functions that interact with Module::GlobalList.
+  LLVMContext C;
+  SMDiagnostic Err;
+  LLVMContext Context;
+  std::unique_ptr M = parseAssemblyString(R"(
+@GV = external global i32
+)",
+  Err, Context);
+  auto *GV = cast(M->getNamedValue("GV"));
+  EXPECT_EQ(M->global_size(), 1u);
+  GlobalVariable *NewGV = new GlobalVariable(
+  Type::getInt32Ty(C), /*isConstant=*/true, GlobalValue::InternalLinkage,
+  /*Initializer=*/nullptr, "NewGV");
+  EXPECT_EQ(M->global_size(), 1u);
+  // Insert before
+  M->insertGlobalVariable(M->globals().begin(), NewGV);
+  EXPECT_EQ(M->global_size(), 2u);
+  EXPECT_EQ(&*M->globals().begin(), NewGV);
+  // Insert at end()
+  M->removeGlobalVariable(NewGV);
+  EXPECT_EQ(M->global_size(), 1u);
+  M->insertGlobalVariable(NewGV);
+  EXPECT_EQ(M->global_size(), 2u);
+  EXPECT_EQ(&*std::prev(M->globals().end()), NewGV);
+  // Check globals()
+  auto Range = M->globals();
+  EXPECT_EQ(&*Range.begin(), GV);
+  EXPECT_EQ(&*std::next(Range.begin()), NewGV);
+  EXPECT_EQ(std::next(Range.begin(), 2), Range.end());
+  // Check remove
+  M->removeGlobalVariable(NewGV);
+  EXPECT_EQ(M->global_size(), 1u);
+  // Check erase
+  M->insertGlobalVariable(NewGV);
+  M->eraseGlobalVariable(NewGV);
+  EXPECT_EQ(M->global_size(), 1u);
+}
+
 } // end namespace
Index: llvm/lib/Transforms/Utils/CtorUtils.cpp
===
--- llvm/lib/Transforms/Utils/CtorUtils.cpp
+++ llvm/lib/Transforms/Utils/CtorUtils.cpp
@@ -48,7 +48,7 @@
   GlobalVariable *NGV =
   new GlobalVariable(CA->getType(), GCL->isConstant(), GCL->getLinkage(),
  CA, "", GCL->getThreadLocalMode());
-  GCL->getParent()->getGlobalList().insert(GCL->getIterator(), NGV);
+  GCL->getParent()->insertGlobalVariable(GCL->getIterator(), NGV);
   NGV->takeName(GCL);
 
   // Nuke the old list, replacing any uses with the new one.
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -958,7 +958,7 @@
 std::vector &Bits,
 DenseMap> &TypeIdMap) {
   DenseMap GVToBits;
-  Bits.reserve(M.getGlobalList().size());
+  Bits.reserve(M.global_size());
   SmallVector Types;
   for (GlobalVariable &GV : M.globals()) {
 Types.clear();
Index: llvm/lib/Transforms/IPO/SCCP.cpp
===
--- llvm/lib/Transforms/IPO/SCCP.cpp
+++ llvm/lib/Transforms/IPO/SCCP.cpp
@@ -370,7 +370,7 @@
   SI->eraseFromParent();
   MadeChanges = true;
 }
-M.getGlobalList().erase(GV);
+M.eraseGlobalVariable(GV);
 ++NumGlobalConst;
   }
 
@@ -476,4 +476,3 @@
 
 // createIPSCCPPass - This is the public interface to this file.
 ModulePass *llvm::createIPSCCPPass() { return new IPSCCPLegacyPass(); }
-
Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
===
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -976,7 +976,7 @@
   cast(InitBool->user_back())->eraseFromParent();
 delete InitBool;
   } else
-GV->getParent()->getGlobalList().insert(GV->getIterator(), InitBool);
+GV->getParent()->insertGlobalVariable(GV->getIterator(), InitBool);
 
   // Now the GV is dead, nuke it and the allocation..
   GV->eraseFromParent();
@@ -1158,7 +1158,7 @@

[PATCH] D144027: [NFC][IR] Make Module::getGlobalList() private

2023-02-14 Thread Vasileios Porpodas via Phabricator via cfe-commits
vporpo added inline comments.



Comment at: llvm/unittests/IR/ModuleTest.cpp:47-49
 // Sort the globals by name.
 EXPECT_FALSE(std::is_sorted(M.global_begin(), M.global_end(), compare));
-M.getGlobalList().sort(compare);

I removed this because it is testing whether ilist.sort() works, which is not 
Module-specific. This requires access to the full GlobalList for no real reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144027

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


[PATCH] D144011: [clang]Fix warning for signed conversion

2023-02-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

If I look at the clang docs for Wconversion 
 I see it 
includes `-Wshorten-64-to-32` which I believe this is a case of. I think maybe 
the warning needs a better warning for this case?


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

https://reviews.llvm.org/D144011

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


[PATCH] D144011: [clang]Fix warning for signed conversion

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

In D144011#4126553 , @shafik wrote:

> If I look at the clang docs for Wconversion 
>  I see it 
> includes `-Wshorten-64-to-32` which I believe this is a case of. I think 
> maybe the warning needs a better warning for this case?

This is done for x86_64 on linux, where long long and long are both 64bit. 
https://godbolt.org/z/hd3qWW5jj


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

https://reviews.llvm.org/D144011

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


[PATCH] D142507: [AMDGPU] Split dot7 feature

2023-02-14 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added a comment.

In D142507#4125940 , @aaronmondal 
wrote:

> Would it be possible to backport this to Clang 16?
>
> If 
> https://github.com/RadeonOpenCompute/ROCm-Device-Libs/commit/8dc779e19cbf2ccfd3307b60f7db57cf4203a5be
>  makes it into ROCm 5.5 no distro would be able to build it with "vanilla" 
> Clang 16, potentially causing pain for users that try to build ROCm 5.5 with 
> a Clang from a package manager (a realistic scenario, considering that one 
> may want to invest 5 min to build ROCm but not 40 min to build Clang). ROCm 
> 5.5 will be the first release to officially support the 7900XT and 7900XTX, 
> so not having this potentially causes issues for users with recent AMD 
> hardware. (See https://github.com/RadeonOpenCompute/ROCm/issues/1880 for 
> extensive, related discussion).
>
> @jhuber6 This wouldn't exactly "solve" 
> https://github.com/llvm/llvm-project/issues/60660, but I think this could 
> also be a workaround (with potentially better user experience), as allowing 
> users build ROCm with regular Clang 16 prevents that deadlock where we can't 
> build ROCm anymore. This is entirely based on speculation that ROCm 5.5 won't 
> introduce other breakages before its release though, so I'd totally 
> understand if this is not a satisfactory solution.

It shall be complimented by the device-lib change in the corresponding release, 
so it is not that simple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142507

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


[PATCH] D143851: [clang-tidy] Tweak 'rule of 3/5' checks to allow defaulting a destructor outside the class.

2023-02-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

> This is why this option was only available for destructors in the first 
> place, I imagine.

The `cppcoreguidelines` are a bit tricky to work with. Some of the rules are 
too strict to reasonably apply them in practice. We have brought this up with 
the authors of the guidelines but they have rejected proposals for 
modification. That's why in clang-tidy we aim at having by default the strict 
behavior so the check follows the rules "as-is", while also adding options that 
allow users to slightly deviate from the rules, to be more pragmatic. Thus if 
we want some new behavior that deviates from the rule text as it's written we 
should preferably implement it as an option.

> About the second point - this sounds pretty general, doesn't clang-tidy 
> already filter diagnostics in system headers? At least Clang does.

Yes, clang-tidy will not issue warnings in system headers, so checks should not 
need to explicitly handle that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143851

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


[libclc] f6cd46e - libclc: add more generic implementations to clspv SOURCES

2023-02-14 Thread Kévin Petit via cfe-commits

Author: Kévin Petit
Date: 2023-02-14T18:11:01Z
New Revision: f6cd46e07fcca123620afff96675171f8fe96124

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

LOG: libclc: add more generic implementations to clspv SOURCES

https://reviews.llvm.org/D134887

Patch by: Aaron Greig 

Added: 


Modified: 
libclc/clspv/lib/SOURCES

Removed: 




diff  --git a/libclc/clspv/lib/SOURCES b/libclc/clspv/lib/SOURCES
index cae33c38472be..98bc71a869b2a 100644
--- a/libclc/clspv/lib/SOURCES
+++ b/libclc/clspv/lib/SOURCES
@@ -1,45 +1,82 @@
+math/fma.cl
+math/nextafter.cl
 subnormal_config.cl
 ../../generic/lib/geometric/distance.cl
 ../../generic/lib/geometric/length.cl
-math/fma.cl
-math/nextafter.cl
+../../generic/lib/math/acos.cl
 ../../generic/lib/math/acosh.cl
 ../../generic/lib/math/asinh.cl
+../../generic/lib/math/acospi.cl
+../../generic/lib/math/asin.cl
 ../../generic/lib/math/atan.cl
+../../generic/lib/math/asinh.cl
+../../generic/lib/math/asinpi.cl
 ../../generic/lib/math/atan2.cl
 ../../generic/lib/math/atan2pi.cl
 ../../generic/lib/math/atanh.cl
 ../../generic/lib/math/atanpi.cl
 ../../generic/lib/math/cbrt.cl
+../../generic/lib/math/clc_exp10.cl
 ../../generic/lib/math/clc_fmod.cl
 ../../generic/lib/math/clc_hypot.cl
 ../../generic/lib/math/clc_ldexp.cl
 ../../generic/lib/math/clc_nextafter.cl
+../../generic/lib/math/clc_pow.cl
+../../generic/lib/math/clc_pown.cl
+../../generic/lib/math/clc_powr.cl
 ../../generic/lib/math/clc_remainder.cl
 ../../generic/lib/math/clc_remquo.cl
 ../../generic/lib/math/clc_rootn.cl
 ../../generic/lib/math/clc_tan.cl
+../../generic/lib/math/clc_tanpi.cl
+../../generic/lib/math/cos.cl
+../../generic/lib/math/cosh.cl
+../../generic/lib/math/cospi.cl
 ../../generic/lib/math/erf.cl
 ../../generic/lib/math/erfc.cl
+../../generic/lib/math/exp.cl
+../../generic/lib/math/exp10.cl
+../../generic/lib/math/exp2.cl
+../../generic/lib/math/exp_helper.cl
+../../generic/lib/math/expm1.cl
+../../generic/lib/math/fdim.cl
 ../../generic/lib/math/fmod.cl
 ../../generic/lib/math/fract.cl
 ../../generic/lib/math/frexp.cl
+../../generic/lib/math/half_cos.cl
 ../../generic/lib/math/half_divide.cl
+../../generic/lib/math/half_powr.cl
 ../../generic/lib/math/half_recip.cl
+../../generic/lib/math/half_sin.cl
 ../../generic/lib/math/half_sqrt.cl
+../../generic/lib/math/half_tan.cl
 ../../generic/lib/math/hypot.cl
 ../../generic/lib/math/ilogb.cl
 ../../generic/lib/math/ldexp.cl
 ../../generic/lib/math/lgamma.cl
 ../../generic/lib/math/lgamma_r.cl
+../../generic/lib/math/log.cl
+../../generic/lib/math/log10.cl
+../../generic/lib/math/log1p.cl
+../../generic/lib/math/log2.cl
 ../../generic/lib/math/logb.cl
 ../../generic/lib/math/maxmag.cl
 ../../generic/lib/math/minmag.cl
 ../../generic/lib/math/modf.cl
 ../../generic/lib/math/nan.cl
+../../generic/lib/math/pow.cl
+../../generic/lib/math/pown.cl
+../../generic/lib/math/powr.cl
 ../../generic/lib/math/remainder.cl
 ../../generic/lib/math/remquo.cl
 ../../generic/lib/math/rootn.cl
+../../generic/lib/math/sin.cl
+../../generic/lib/math/sincos.cl
+../../generic/lib/math/sincos_helpers.cl
+../../generic/lib/math/sinh.cl
+../../generic/lib/math/sinpi.cl
 ../../generic/lib/math/tables.cl
+../../generic/lib/math/tan.cl
 ../../generic/lib/math/tanh.cl
+../../generic/lib/math/tanpi.cl
 ../../generic/lib/math/tgamma.cl



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


[PATCH] D143301: Emit warning for unsupported gfortran flags

2023-02-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Split this into two patches/reviews. I think the -W stuff can go in, it has 
tests and is reasonable. The other stuff needs tests too.




Comment at: flang/lib/Frontend/CompilerInvocation.cpp:607
   if (args.hasArg(clang::driver::options::OPT_W_Joined)) {
-if (args.getLastArgValue(clang::driver::options::OPT_W_Joined)
-.equals("error")) {
-  res.setWarnAsErr(true);
-} else {
-  const unsigned diagID =
-  diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
-"Only `-Werror` is supported currently.");
-  diags.Report(diagID);
+const auto wArgs =
+args.getAllArgValues(clang::driver::options::OPT_W_Joined);

Probably


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143301

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


[libclc] 290308a - libclc: add generated convert.cl to clspv/clspv64 targets

2023-02-14 Thread Kévin Petit via cfe-commits

Author: Kévin Petit
Date: 2023-02-14T18:23:35Z
New Revision: 290308a99e6b9e6f808a9824c8e5a58a65749585

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

LOG: libclc: add generated convert.cl to clspv/clspv64 targets

https://reviews.llvm.org/D136772

Patch by: Aaron Greig 

Added: 


Modified: 
libclc/CMakeLists.txt

Removed: 




diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index f712100689b0..89f08b889ea1 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -218,11 +218,11 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
# Add the generated convert.cl here to prevent adding
# the one listed in SOURCES
-   if( NOT ${ARCH} STREQUAL "spirv" AND NOT ${ARCH} STREQUAL "spirv64" AND
-   NOT ${ARCH} STREQUAL "clspv" AND NOT ${ARCH} STREQUAL 
"clspv64" )
+   if( NOT ${ARCH} STREQUAL "spirv" AND NOT ${ARCH} STREQUAL "spirv64" )
set( rel_files convert.cl )
set( objects convert.cl )
-   if( NOT ENABLE_RUNTIME_SUBNORMAL )
+   if( NOT ENABLE_RUNTIME_SUBNORMAL AND NOT ${ARCH} STREQUAL 
"clspv" AND
+   NOT ${ARCH} STREQUAL "clspv64" )
list( APPEND rel_files 
generic/lib/subnormal_use_default.ll )
endif()
else()



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


[libclc] 1da2085 - libclc: add clspv to targets exempt from alwaysinline

2023-02-14 Thread Kévin Petit via cfe-commits

Author: Kévin Petit
Date: 2023-02-14T18:26:42Z
New Revision: 1da2085a513341f0e8d7578415dcf77d614708e5

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

LOG: libclc: add clspv to targets exempt from alwaysinline

https://reviews.llvm.org/D132362

Patch by: Aaron Greig 

Added: 


Modified: 
libclc/generic/include/clc/clcfunc.h

Removed: 




diff  --git a/libclc/generic/include/clc/clcfunc.h 
b/libclc/generic/include/clc/clcfunc.h
index 55b775ea3935b..abb5484d6248e 100644
--- a/libclc/generic/include/clc/clcfunc.h
+++ b/libclc/generic/include/clc/clcfunc.h
@@ -2,8 +2,10 @@
 #define _CLC_DECL
 #define _CLC_INLINE __attribute__((always_inline)) inline
 
-/* avoid inlines for SPIR-V since we'll optimise later in the chain */
-#if defined(CLC_SPIRV) || defined(CLC_SPIRV64)
+// avoid inlines for SPIR-V related targets since we'll optimise later in the
+// chain
+#if defined(CLC_SPIRV) || defined(CLC_SPIRV64) || defined(CLC_CLSPV) || \
+defined(CLC_CLSPV64)
 #define _CLC_DEF
 #else
 #define _CLC_DEF __attribute__((always_inline))



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


[PATCH] D143301: Emit warning for unsupported gfortran flags

2023-02-14 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D143301#4126682 , @jdoerfert wrote:

> Split this into two patches/reviews.

+1

> I think the -W stuff can go in, it has tests and is reasonable.

I'd like for us to rely on a flag from Options.td for this instead. Something 
similar to clang_ignored_f_Group 
.
 I would probably call it `flang_ignored_w_Group` :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143301

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


[clang] ddde069 - [OpenMP]Fix PR55970: Miscompile of collapse(3) with non-rectangular loop nest.

2023-02-14 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2023-02-14T10:39:04-08:00
New Revision: ddde06906be11ea540870d5c0e1b3336a4460612

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

LOG: [OpenMP]Fix PR55970: Miscompile of collapse(3) with non-rectangular loop 
nest.

Need to assign the calculated lower bound back to temp variable,
otherwise incorrect value (upper bound instead of lower bound) might be
used.

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

Added: 
openmp/runtime/test/worksharing/for/omp_for_collapse_non_rectangular.c

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

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 368f5ecfa23d5..20e75fb710676 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4668,11 +4668,12 @@ static DeclRefExpr *buildCapture(Sema &S, ValueDecl *D, 
Expr *CaptureExpr,
   CaptureExpr->getExprLoc());
 }
 
-static ExprResult buildCapture(Sema &S, Expr *CaptureExpr, DeclRefExpr *&Ref) {
+static ExprResult buildCapture(Sema &S, Expr *CaptureExpr, DeclRefExpr *&Ref,
+   StringRef Name) {
   CaptureExpr = S.DefaultLvalueConversion(CaptureExpr).get();
   if (!Ref) {
 OMPCapturedExprDecl *CD = buildCaptureDecl(
-S, &S.getASTContext().Idents.get(".capture_expr."), CaptureExpr,
+S, &S.getASTContext().Idents.get(Name), CaptureExpr,
 /*WithInit=*/true, S.CurContext, /*AsExpression=*/true);
 Ref = buildDeclRefExpr(S, CD, CD->getType().getNonReferenceType(),
CaptureExpr->getExprLoc());
@@ -8441,7 +8442,8 @@ bool OpenMPIterationSpaceChecker::checkAndSetInc(Expr *S) 
{
 
 static ExprResult
 tryBuildCapture(Sema &SemaRef, Expr *Capture,
-llvm::MapVector &Captures) {
+llvm::MapVector &Captures,
+StringRef Name = ".capture_expr.") {
   if (SemaRef.CurContext->isDependentContext() || Capture->containsErrors())
 return Capture;
   if (Capture->isEvaluatable(SemaRef.Context, Expr::SE_AllowSideEffects))
@@ -8450,9 +8452,9 @@ tryBuildCapture(Sema &SemaRef, Expr *Capture,
 /*AllowExplicit=*/true);
   auto I = Captures.find(Capture);
   if (I != Captures.end())
-return buildCapture(SemaRef, Capture, I->second);
+return buildCapture(SemaRef, Capture, I->second, Name);
   DeclRefExpr *Ref = nullptr;
-  ExprResult Res = buildCapture(SemaRef, Capture, Ref);
+  ExprResult Res = buildCapture(SemaRef, Capture, Ref, Name);
   Captures[Capture] = Ref;
   return Res;
 }
@@ -8464,7 +8466,7 @@ calculateNumIters(Sema &SemaRef, Scope *S, SourceLocation 
DefaultLoc,
   Expr *Lower, Expr *Upper, Expr *Step, QualType LCTy,
   bool TestIsStrictOp, bool RoundToStep,
   llvm::MapVector &Captures) {
-  ExprResult NewStep = tryBuildCapture(SemaRef, Step, Captures);
+  ExprResult NewStep = tryBuildCapture(SemaRef, Step, Captures, ".new_step");
   if (!NewStep.isUsable())
 return nullptr;
   llvm::APSInt LRes, SRes;
@@ -8640,8 +8642,8 @@ Expr *OpenMPIterationSpaceChecker::buildNumIterations(
 return nullptr;
   Expr *LBVal = LB;
   Expr *UBVal = UB;
-  // LB = TestIsLessOp.getValue() ? min(LB(MinVal), LB(MaxVal)) :
-  // max(LB(MinVal), LB(MaxVal))
+  // OuterVar = (LB = TestIsLessOp.getValue() ? min(LB(MinVal), LB(MaxVal)) :
+  // max(LB(MinVal), LB(MaxVal)))
   if (InitDependOnLC) {
 const LoopIterationSpace &IS = ResultIterSpaces[*InitDependOnLC - 1];
 if (!IS.MinValue || !IS.MaxValue)
@@ -8686,8 +8688,10 @@ Expr *OpenMPIterationSpaceChecker::buildNumIterations(
 if (!LBMaxVal.isUsable())
   return nullptr;
 
-Expr *LBMin = tryBuildCapture(SemaRef, LBMinVal.get(), Captures).get();
-Expr *LBMax = tryBuildCapture(SemaRef, LBMaxVal.get(), Captures).get();
+Expr *LBMin =
+tryBuildCapture(SemaRef, LBMinVal.get(), Captures, ".lb_min").get();
+Expr *LBMax =
+tryBuildCapture(SemaRef, LBMaxVal.get(), Captures, ".lb_max").get();
 if (!LBMin || !LBMax)
   return nullptr;
 // LB(MinVal) < LB(MaxVal)
@@ -8696,7 +8700,8 @@ Expr *OpenMPIterationSpaceChecker::buildNumIterations(
 if (!MinLessMaxRes.isUsable())
   return nullptr;
 Expr *MinLessMax =
-tryBuildCapture(SemaRef, MinLessMaxRes.get(), Captures).get();
+tryBuildCapture(SemaRef, MinLessMaxRes.get(), Captures, 
".min_less_max")
+.get();
 if (!MinLessMax)
   return nullptr;
 if (*TestIsLessOp) {
@@ -8716,6 +8721,12 @@ Expr *OpenMPIterationSpaceChecker::buildNumIterations(
 return nullptr;
   LBVal = MaxLB.get();
 }
+// OuterVar = LB
+LBMinVal =
+   

[PATCH] D144015: [OpenMP]Fix PR55970: Miscompile of collapse(3) with non-rectangular loop nest.

2023-02-14 Thread Alexey Bataev 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 rGddde06906be1: [OpenMP]Fix PR55970: Miscompile of collapse(3) 
with non-rectangular loop nest. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144015

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_codegen.cpp
  clang/test/OpenMP/tile_codegen.cpp
  openmp/runtime/test/worksharing/for/omp_for_collapse_non_rectangular.c

Index: openmp/runtime/test/worksharing/for/omp_for_collapse_non_rectangular.c
===
--- /dev/null
+++ openmp/runtime/test/worksharing/for/omp_for_collapse_non_rectangular.c
@@ -0,0 +1,22 @@
+// RUN: %libomp-compile-and-run
+
+#include 
+
+#define N 3
+
+int arr[N][N][N];
+int main() {
+#pragma omp for collapse(3)
+  for (unsigned int i = 0; i < N; ++i)
+for (unsigned int j = i; j < N; ++j)
+  for (unsigned int k = j; k < N; ++k)
+arr[i][j][k] = 1;
+  int num_failed = 0;
+  for (unsigned int i = 0; i < N; ++i)
+for (unsigned int j = 0; j < N; ++j)
+  for (unsigned int k = 0; k < N; ++k)
+if (arr[i][j][k] == (j >= i && k >= j) ? 0 : 1)
+  ++num_failed;
+
+  return num_failed;
+}
Index: clang/test/OpenMP/tile_codegen.cpp
===
--- clang/test/OpenMP/tile_codegen.cpp
+++ clang/test/OpenMP/tile_codegen.cpp
@@ -179,8 +179,8 @@
 // CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTCAPTURE_EXPR_:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTCAPTURE_EXPR_1:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTNEW_STEP:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTCAPTURE_EXPR_2:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:[[DOTCAPTURE_EXPR_3:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTFLOOR_0_IV_I:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[DOTTILE_0_IV_I:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store i32 [[START]], ptr [[START_ADDR]], align 4
@@ -191,56 +191,56 @@
 // CHECK1-NEXT:[[TMP1:%.*]] = load i32, ptr [[END_ADDR]], align 4
 // CHECK1-NEXT:store i32 [[TMP1]], ptr [[DOTCAPTURE_EXPR_1]], align 4
 // CHECK1-NEXT:[[TMP2:%.*]] = load i32, ptr [[STEP_ADDR]], align 4
-// CHECK1-NEXT:store i32 [[TMP2]], ptr [[DOTCAPTURE_EXPR_2]], align 4
+// CHECK1-NEXT:store i32 [[TMP2]], ptr [[DOTNEW_STEP]], align 4
 // CHECK1-NEXT:[[TMP3:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
 // CHECK1-NEXT:[[TMP4:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]], align 4
 // CHECK1-NEXT:[[SUB:%.*]] = sub i32 [[TMP3]], [[TMP4]]
-// CHECK1-NEXT:[[SUB4:%.*]] = sub i32 [[SUB]], 1
-// CHECK1-NEXT:[[TMP5:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_2]], align 4
-// CHECK1-NEXT:[[ADD:%.*]] = add i32 [[SUB4]], [[TMP5]]
-// CHECK1-NEXT:[[TMP6:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_2]], align 4
+// CHECK1-NEXT:[[SUB3:%.*]] = sub i32 [[SUB]], 1
+// CHECK1-NEXT:[[TMP5:%.*]] = load i32, ptr [[DOTNEW_STEP]], align 4
+// CHECK1-NEXT:[[ADD:%.*]] = add i32 [[SUB3]], [[TMP5]]
+// CHECK1-NEXT:[[TMP6:%.*]] = load i32, ptr [[DOTNEW_STEP]], align 4
 // CHECK1-NEXT:[[DIV:%.*]] = udiv i32 [[ADD]], [[TMP6]]
-// CHECK1-NEXT:[[SUB5:%.*]] = sub i32 [[DIV]], 1
-// CHECK1-NEXT:store i32 [[SUB5]], ptr [[DOTCAPTURE_EXPR_3]], align 4
+// CHECK1-NEXT:[[SUB4:%.*]] = sub i32 [[DIV]], 1
+// CHECK1-NEXT:store i32 [[SUB4]], ptr [[DOTCAPTURE_EXPR_2]], align 4
 // CHECK1-NEXT:store i32 0, ptr [[DOTFLOOR_0_IV_I]], align 4
 // CHECK1-NEXT:br label [[FOR_COND:%.*]]
 // CHECK1:   for.cond:
 // CHECK1-NEXT:[[TMP7:%.*]] = load i32, ptr [[DOTFLOOR_0_IV_I]], align 4
-// CHECK1-NEXT:[[TMP8:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_3]], align 4
-// CHECK1-NEXT:[[ADD6:%.*]] = add i32 [[TMP8]], 1
-// CHECK1-NEXT:[[CMP:%.*]] = icmp ult i32 [[TMP7]], [[ADD6]]
-// CHECK1-NEXT:br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END18:%.*]]
+// CHECK1-NEXT:[[TMP8:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_2]], align 4
+// CHECK1-NEXT:[[ADD5:%.*]] = add i32 [[TMP8]], 1
+// CHECK1-NEXT:[[CMP:%.*]] = icmp ult i32 [[TMP7]], [[ADD5]]
+// CHECK1-NEXT:br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END17:%.*]]
 // CHECK1:   for.body:
 // CHECK1-NEXT:[[TMP9:%.*]] = load i32, ptr [[DOTFLOOR_0_IV_I]], align 4
 // CHECK1-NEXT:store i32 [[TMP9]], ptr [[DOTTILE_0_IV_I]], align 4
-// CHECK1-NEXT:br label [[FOR_COND7:%.*]]
-// CHECK1:   for.cond7:
+// CHECK1-NEXT:br label [[FOR_COND6:%.*]]
+// CHECK1:   for.cond6:
 // CHECK1-NEXT:[[TMP10:%.*]] = load i32, ptr [[DOTTILE_0_IV_I]], align 4
-// CHECK1-NEXT:[[TMP11:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_3]], align 4
-// CHECK1-NEXT:[[ADD8:%.*]] = add i32 [[TMP11]], 1
+// CHECK1-NEXT:[[TMP11:%.*]]

[PATCH] D143996: [clang-tidy][doc] Remove unused variable

2023-02-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp accepted this revision.
carlosgalvezp added a comment.

LGTM, thanks for the fix!


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

https://reviews.llvm.org/D143996

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


[PATCH] D143851: [clang-tidy] Tweak 'rule of 3/5' checks to allow defaulting a destructor outside the class.

2023-02-14 Thread Piotr Zegar via Phabricator via cfe-commits
ClockMan added a comment.

In D143851#4126615 , @carlosgalvezp 
wrote:

> Yes, clang-tidy will not issue warnings in system headers, so checks should 
> not need to explicitly handle that.

That's not so simple. At work we use clang-tidy for few big projects. I had to 
explicitly add to some checks `unless(isExpansionInSystemHeader())` to gain 
some performance improvement of clang-tidy. This check is one of them.
Problem is that some matchers or `check` methods in checks are heavy, and when 
you got lot of system headers (boost, STL, generated interfaces, message 
structs, ...) you may end up easily with hundreds of hidden issues from single 
translation unit.
For some checks explicit exclude of system headers gives ~50% performance 
improvement, that result in faster CI feedback.

Best would be to have something more generic like: if --system-headers is not 
used, then exclude code as early as possible, before even constructing 
diagnostic information.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143851

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


[PATCH] D144035: [hwasan] Ensure hwasan aliases do not have ODR linkage

2023-02-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: pcc, eugenis, vitalybuka.
leonardchan added a project: Sanitizers.
Herald added subscribers: Enna1, jeroen.dobbelaere, hiraditya.
Herald added a project: All.
leonardchan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

If an existing global has linkonce_odr linkage, then the alias adopts the 
global's linkonce_odr linkage. The ODR linkages should only be used if its 
guaranteed by the frontend that all definitions of the symbol are "equivalent", 
hence they are effectively non-interposable. It's very unlikely however for two 
aliases to be the same across multiple TUs since they'll likely have different 
tags. This is a problem if a pass replaces a use of the alias with its local 
aliasee because if another definition with a separate tag wins at link time, 
then the local aliasee usage is incorrect.

Full context at https://github.com/llvm/llvm-project/issues/60668.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144035

Files:
  clang/test/CodeGenCXX/pr60668.cpp
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/Instrumentation/HWAddressSanitizer/odr.ll


Index: llvm/test/Instrumentation/HWAddressSanitizer/odr.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/HWAddressSanitizer/odr.ll
@@ -0,0 +1,7 @@
+; RUN: opt < %s -passes=hwasan -S | FileCheck %s
+
+; CHECK: @linkonce_odr_obj = linkonce hidden alias
+@linkonce_odr_obj = linkonce_odr hidden constant i32 1
+
+; CHECK: weak_odr_obj = weak hidden alias
+@weak_odr_obj = weak_odr hidden constant i32 1
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1568,8 +1568,24 @@
   ConstantExpr::getPtrToInt(NewGV, Int64Ty),
   ConstantInt::get(Int64Ty, uint64_t(Tag) << PointerTagShift)),
   GV->getType());
+
+  // Ensure the global doesn't have *ODRLinkage. Those linkages should only be
+  // used if all other definitions of the global are "equivalent" to this one.
+  // Since this alias could be defined in other TU's, it's very unlikely 
they'll
+  // all have the same tag.
+  //
+  // This fixes PR60668.
+  GlobalValue::LinkageTypes Linkage;
+  if (GV->hasLinkOnceODRLinkage()) {
+Linkage = GlobalValue::LinkOnceAnyLinkage;
+  } else if (GV->hasWeakODRLinkage()) {
+Linkage = GlobalValue::WeakAnyLinkage;
+  } else {
+Linkage = GV->getLinkage();
+  }
+
   auto *Alias = GlobalAlias::create(GV->getValueType(), GV->getAddressSpace(),
-GV->getLinkage(), "", Aliasee, &M);
+Linkage, "", Aliasee, &M);
   Alias->setVisibility(GV->getVisibility());
   Alias->takeName(GV);
   GV->replaceAllUsesWith(Alias);
Index: clang/test/CodeGenCXX/pr60668.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr60668.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang --target=aarch64-unknown-linux-gnu -O1 -fvisibility=hidden \
+// RUN:   -fsanitize=hwaddress -fsanitize=undefined -std=c++17 -fno-exceptions 
\
+// RUN:   -fno-rtti -c %s -S -o - | FileCheck %s
+
+struct AndroidSizeClassConfig {
+  static constexpr unsigned Classes[] = {
+  0x00020, 0x00030, 0x00040, 0x00050, 0x00060, 0x00070, 0x00090, 0x000b0,
+  0x000c0, 0x000e0, 0x00120, 0x00160, 0x001c0, 0x00250, 0x00320, 0x00450,
+  0x00670, 0x00830, 0x00a10, 0x00c30, 0x01010, 0x01210, 0x01bd0, 0x02210,
+  0x02d90, 0x03790, 0x04010, 0x04810, 0x05a10, 0x07310, 0x08210, 0x10010,
+  };
+};
+
+static const unsigned NumClasses =
+sizeof(AndroidSizeClassConfig::Classes) / 
sizeof(AndroidSizeClassConfig::Classes[0]);
+
+void func(unsigned);
+
+void printMap() {
+  for (unsigned I = 0; I < NumClasses; I++) {
+func(AndroidSizeClassConfig::Classes[I]);
+  }
+}
+
+// CHECK-LABEL: _Z8printMapv
+// CHECK:adrpx{{.*}}, 
:pg_hi21_nc:_ZN22AndroidSizeClassConfig7ClassesE
+// CHECK:movkx{{.*}}, 
#:prel_g3:_ZN22AndroidSizeClassConfig7ClassesE+4294967296
+// CHECK:add x{{.*}}, x19, 
:lo12:_ZN22AndroidSizeClassConfig7ClassesE


Index: llvm/test/Instrumentation/HWAddressSanitizer/odr.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/HWAddressSanitizer/odr.ll
@@ -0,0 +1,7 @@
+; RUN: opt < %s -passes=hwasan -S | FileCheck %s
+
+; CHECK: @linkonce_odr_obj = linkonce hidden alias
+@linkonce_odr_obj = linkonce_odr hidden constant i32 1
+
+; CHECK: weak_odr_obj = weak hidden alias
+@weak_odr_obj = weak_odr hidden constant i32 1
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- 

[PATCH] D144035: [hwasan] Ensure hwasan aliases do not have ODR linkage

2023-02-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Lemme know if the clang regression test isn't necessary or should be in its own 
commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144035

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


[PATCH] D142507: [AMDGPU] Split dot7 feature

2023-02-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsAMDGPU.def:239
 
-TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot7-insts")
+TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot10-insts")
 TARGET_BUILTIN(__builtin_amdgcn_fdot2_f16_f16, "hV2hV2hh", "nc", "dot9-insts")

rampitec wrote:
> arsenm wrote:
> > rampitec wrote:
> > > arsenm wrote:
> > > > I have even less idea what these numbers mean now than I did before. 
> > > > This is also a bitcode compatibility break
> > > They actually never meant anything just because there is no system in the 
> > > support matrix. I know this one will need simultaneous update of the 
> > > device lib downstream.
> > why not name these as just the exact instruction name?
> This is legacy thing. When it first appeared it was a single instruction set. 
> Changing it now completely will break a lot of stuff.
Then why bother renaming this? We really need to stop breaking feature names 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142507

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


[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-02-14 Thread Mark Danial via Phabricator via cfe-commits
madanial updated this revision to Diff 497392.
madanial added a comment.

clang-format issue in

  ExternalNameConversion.cpp




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

https://reviews.llvm.org/D140795

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Optimizer/Transforms/Passes.h
  flang/include/flang/Optimizer/Transforms/Passes.td
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/underscoring.f90
  flang/test/Fir/external-mangling.fir

Index: flang/test/Fir/external-mangling.fir
===
--- flang/test/Fir/external-mangling.fir
+++ flang/test/Fir/external-mangling.fir
@@ -1,6 +1,9 @@
-// RUN: fir-opt --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR
+// RUN: fir-opt --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: fir-opt --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-NOUNDER
 
 func.func @_QPfoo() {
   %c0 = arith.constant 0 : index
@@ -21,24 +24,43 @@
 func.func private @_QPbar(!fir.ref)
 func.func private @_QPbar2(!fir.ref)
 
-// CHECK: func @foo_
-// CHECK: %{{.*}} = fir.address_of(@a_) : !fir.ref>
-// CHECK: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
-// CHECK: fir.call @bar_
-// CHECK: fir.call @bar2_
-// CHECK: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: func private @bar_(!fir.ref)
-
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
-// LLVMIR: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
-// LLVMIR: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
-
-// LLVMIR: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
-// LLVMIR: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
-// LLVMIR: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
-// LLVMIR: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+// CHECK-UNDER: func @foo_
+// CHECK-UNDER: %{{.*}} = fir.address_of(@a_) : !fir.ref>
+// CHECK-UNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-UNDER: fir.call @bar_
+// CHECK-UNDER: fir.call @bar2_
+// CHECK-UNDER: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: func private @bar_(!fir.ref)
+
+// CHECK-NOUNDER: func @foo(
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@a) : !fir.ref>
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-NOUNDER: fir.call @bar(
+// CHECK-NOUNDER: fir.call @bar2(
+// CHECK-NOUNDER: fir.global common @a(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: func private @bar(!fir.ref)
+
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-UNDER: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-UNDER: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
+
+// LLVMIR-UNDER: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
+// LLVMIR-UNDER: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @a : !llvm.ptr>
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-NOUNDER: llvm.call @bar(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-NOUNDER: llvm.call @bar2(%{{.*}}) : (!llvm.ptr) -> ()
+
+// LLVMIR-NOUNDER: llvm.mlir.global common @a(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
+// LLVMI

[PATCH] D144011: [clang]Fix warning for signed conversion

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

I think it makes sense for `-Wsign-conversion` to not warn for this case. I do 
not know whether we need another diagnostic like `-Wshorten-64-to-32` for this 
case, but am inclined to no.

`-m32` doesn't emit a warning. I wonder whether the newly added condition can 
be merged with the following condition:

  if ((!isa(Target) || !isa(Source)) &&
  ((TargetRange.NonNegative && !LikelySourceRange.NonNegative) ||
   (!TargetRange.NonNegative && LikelySourceRange.NonNegative &&
LikelySourceRange.Width == TargetRange.Width))) {
if (S.SourceMgr.isInSystemMacro(CC))


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

https://reviews.llvm.org/D144011

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


  1   2   >