[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread via cfe-commits


@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
   verifyFormat("return sizeof \"5\";");
 }
 
+TEST_F(FormatTest, BinPackBinaryOperations) {
+  auto Style = getLLVMStyle();
+  Style.BinPackBinaryOperations = false;

mydeveloperday wrote:

can you test the default case

https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread via cfe-commits


@@ -1203,6 +1214,10 @@ unsigned 
ContinuationIndenter::addTokenOnNewLine(LineState &State,
 }
   }
 
+  if (!Style.BinPackBinaryOperations && Previous.is(TT_BinaryOperator) &&
+  (Previous.getPrecedence() > prec::Conditional)) {
+CurrentState.BreakBeforeParameter = true;

mydeveloperday wrote:

which test is for this condition

https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread via cfe-commits


@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
   verifyFormat("return sizeof \"5\";");
 }
 
+TEST_F(FormatTest, BinPackBinaryOperations) {
+  auto Style = getLLVMStyle();
+  Style.BinPackBinaryOperations = false;
+
+  // Logical operations
+  verifyFormat("if (condition1 && condition2) {\n"
+   "}",
+   Style);
+  verifyFormat("if (condition1 && // comment\n"
+   "condition2 &&\n"
+   "(condition3 || condition4) && // comment\n"
+   "condition5 &&\n"
+   "condition6) {\n"
+   "}",
+   Style);
+  verifyFormat("if (loongcondition1 &&\n"
+   "loongcondition2) {\n"
+   "}",
+   Style);
+
+  // Arithmetic
+  verifyFormat("const int result = lhs + rhs;\n", Style);
+  verifyFormat("const int result = loongop1 +\n"
+   "   loongop2 +\n"
+   "   loongop3;\n",
+   Style);
+
+  // clang-format off
+  verifyFormat("const int result =\n"
+   "operand1 + operand2 - (operand3 + operand4) - operand5 * 
operand6;\n",
+   Style);
+  // clang-format on
+
+  verifyFormat("const int result = longOperand1 +\n"
+   "   longOperand2 -\n"
+   "   (longOperand3 + longOperand4) -\n"
+   "   longOperand5 * longOperand6;\n",
+   Style);
+
+  Style.BinPackBinaryOperations = true;
+
+  // Logical operations
+  verifyFormat("if (condition1 && condition2) {\n"
+   "}",
+   Style);
+
+  // clang-format off
+  verifyFormat("if (condition1 && condition2 && (condition3 || condition4) && 
condition5 &&\n"
+   "condition6) {\n"
+   "}",
+   Style);
+  // clang-format on
+
+  verifyFormat("if (loongcondition1 &&\n"
+   "loongcondition2) {\n"
+   "}",
+   Style);
+
+  // Arithmetic
+  verifyFormat("const int result = lhs + rhs;\n", Style);
+
+  // clang-format off

mydeveloperday wrote:

why do you need these here?

https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ObjC][CodeGen] Assume a for-in loop is in bounds and cannot overflow (PR #94885)

2024-06-10 Thread David Chisnall via cfe-commits

https://github.com/davidchisnall approved this pull request.


https://github.com/llvm/llvm-project/pull/94885
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)

2024-06-10 Thread Mike Hommey via cfe-commits

glandium wrote:

This broke building wasi-libc, with a crash:
```
Stack dump:
0.  Program arguments: /builds/worker/fetches/clang/bin/clang-19 -cc1 
-triple wasm32-unknown-wasi -emit-obj -disable-free -clear-ast-before-backend 
-disable-llvm-verifier -discard-value-names -main-file-name ctanh.c 
-mrelocation-model static -mthread-model single -mframe-pointer=none 
-ffp-contract=on -fno-rounding-math -ffp-exception-behavior=ignore 
-mconstructor-aliases -target-cpu generic -fvisibility=hidden 
-debugger-tuning=gdb 
-fdebug-compilation-dir=/builds/worker/fetches/wasi-sdk/src/wasi-libc 
-fcoverage-compilation-dir=/builds/worker/fetches/wasi-sdk/src/wasi-libc 
-sys-header-deps -D NDEBUG -O2 -Wall -Wextra -Wno-null-pointer-arithmetic 
-Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable 
-Wno-unused-function -Wno-ignored-attributes -Wno-missing-braces 
-Wno-ignored-pragmas -Wno-unused-but-set-variable -Wno-unknown-warning-option 
-Wno-parentheses -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses 
-Wno-logical-op-parentheses -Wno-string-plus-int -Wno-dangling-else 
-Wno-unknown-pragmas -ferror-limit 19 -fgnuc-version=4.2.1 
-fskip-odr-check-in-gmf -vectorize-loops -vectorize-slp -x c ctanh-46a6c8.c
1.   parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module 'ctanh-46a6c8.c'.
4.  Running pass 'WebAssembly Assembly Printer' on function '@ctanh'
 #0 0x7f2205ba35cd llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/tmp/llvm/llvm/lib/Support/Unix/Signals.inc:723:11
 #1 0x7f2205ba3abb PrintStackTraceSignalHandler(void*) 
/tmp/llvm/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x7f2205ba1b26 llvm::sys::RunSignalHandlers() 
/tmp/llvm/llvm/lib/Support/Signals.cpp:105:5
 #3 0x7f2205ba4275 SignalHandler(int) 
/tmp/llvm/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x7f2203ff4f90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
 #5 0x7f2204043ccc (/lib/x86_64-linux-gnu/libc.so.6+0x8accc)
 #6 0x7f2203ff4ef2 raise (/lib/x86_64-linux-gnu/libc.so.6+0x3bef2)
 #7 0x7f2203fdf472 abort (/lib/x86_64-linux-gnu/libc.so.6+0x26472)
 #8 0x7f2205a7f300 llvm::install_out_of_memory_new_handler() 
/tmp/llvm/llvm/lib/Support/ErrorHandling.cpp:194:0
 #9 0x7f220ba5052d 
llvm::WebAssembly::getLibcallSignature(llvm::WebAssemblySubtarget const&, 
llvm::StringRef, llvm::SmallVectorImpl&, 
llvm::SmallVectorImpl&) 
/tmp/llvm/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp:907:30
#10 0x7f220b9c4e0f 
llvm::WebAssemblyAsmPrinter::getOrCreateWasmSymbol(llvm::StringRef) 
/tmp/llvm/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:0:5
#11 0x7f220b9c4f46 llvm::WebAssemblyAsmPrinter::emitDecls(llvm::Module 
const&) /tmp/llvm/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:310:40
#12 0x7f220b9c7179 llvm::WebAssemblyAsmPrinter::emitConstantPool() 
/tmp/llvm/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:604:3
#13 0x7f2206ee9526 llvm::AsmPrinter::emitFunctionHeader() 
/tmp/llvm/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:966:3
```
This file contains the script and preprocessed source that reproduce the 
problem: 
[ctanh.zip](https://github.com/user-attachments/files/15783347/ctanh.zip)


https://github.com/llvm/llvm-project/pull/94559
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2024-06-10 Thread Chuanqi Xu via cfe-commits


@@ -1830,6 +1830,9 @@ void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables 
&CGVT,
   if (VTable->hasInitializer())
 return;
 
+  if (RD->shouldEmitInExternalSource())
+return;

ChuanqiXu9 wrote:

Yes and agreed. I just don't have an idea for how do that.

https://github.com/llvm/llvm-project/pull/75912
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2024-06-10 Thread Chuanqi Xu via cfe-commits


@@ -6853,6 +6853,13 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
 if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
   DI->completeUnusedClass(*CRD);
 }
+// If we're emitting a dynamic class from the importable module we're
+// emitting, we always need to emit the virtual table according to the ABI
+// requirement.
+if (CRD->getDefinition() && CRD->isDynamicClass() &&
+CRD->isInCurrentModuleUnit())
+  EmitVTable(CRD);

ChuanqiXu9 wrote:

`Sema::DefineUsedVTables` is executed in all cases. However, in two phase 
compilation, the consumer in the first phase is not the CodeGenConsumer but the 
ASTWriter, so when the code get executed: 
https://github.com/llvm/llvm-project/blob/876c6204f12fa2738ff8ca886e664b826847d6d4/clang/lib/Sema/SemaDeclCXX.cpp#L18758-L18759

the corresponding `HandleVTable` in CodeGen Consumer won't get executed.

In the second phase, the CodeGen consumer will be the consumer, and the AST 
Reader will pass the interesting decls to the consumer: 
https://github.com/llvm/llvm-project/blob/e9a362362e03c6aea7a64473e8b8bb9140fd3855/clang/lib/Serialization/ASTReader.cpp#L8052-L8057

https://github.com/llvm/llvm-project/pull/75912
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][nullability] Don't return null fields from `getReferencedDecls()`. (PR #94983)

2024-06-10 Thread via cfe-commits

https://github.com/martinboehme closed 
https://github.com/llvm/llvm-project/pull/94983
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 275196d - [clang][nullability] Don't return null fields from `getReferencedDecls()`. (#94983)

2024-06-10 Thread via cfe-commits

Author: martinboehme
Date: 2024-06-11T08:40:02+02:00
New Revision: 275196d866c86d95fc46b3324876ccbea09da79b

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

LOG: [clang][nullability] Don't return null fields from `getReferencedDecls()`. 
(#94983)

The patch includes a repro for a case where we were returning a null
`FieldDecl`
when calling `getReferencedDecls()` on the `InitListExpr` for a union.

Also, I noticed while working on this that `RecordInitListHelper` has a
bug
where it doesn't work correctly for empty unions. This patch also
includes a
repro and fix for this bug.

Added: 
clang/unittests/Analysis/FlowSensitive/ASTOpsTest.cpp

Modified: 
clang/docs/tools/clang-formatted-files.txt
clang/lib/Analysis/FlowSensitive/ASTOps.cpp
clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn

Removed: 




diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index dee51e402b687..4866bd4aee634 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -622,6 +622,7 @@ clang/tools/libclang/CXCursor.h
 clang/tools/scan-build-py/tests/functional/src/include/clean-one.h
 clang/unittests/Analysis/CFGBuildResult.h
 clang/unittests/Analysis/MacroExpansionContextTest.cpp
+clang/unittests/Analysis/FlowSensitive/ASTOpsTest.cpp
 clang/unittests/Analysis/FlowSensitive/CNFFormula.cpp
 clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
 clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp

diff  --git a/clang/lib/Analysis/FlowSensitive/ASTOps.cpp 
b/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
index 38b5f51b7b2f0..27d42a7b50856 100644
--- a/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
+++ b/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
@@ -100,7 +100,8 @@ getFieldsForInitListExpr(const InitListT *InitList) {
   std::vector Fields;
 
   if (InitList->getType()->isUnionType()) {
-Fields.push_back(InitList->getInitializedFieldInUnion());
+if (const FieldDecl *Field = InitList->getInitializedFieldInUnion())
+  Fields.push_back(Field);
 return Fields;
   }
 
@@ -137,9 +138,11 @@ RecordInitListHelper::RecordInitListHelper(
   // it doesn't do this -- so we create an `ImplicitValueInitExpr` ourselves.
   SmallVector InitsForUnion;
   if (Ty->isUnionType() && Inits.empty()) {
-assert(Fields.size() == 1);
-ImplicitValueInitForUnion.emplace(Fields.front()->getType());
-InitsForUnion.push_back(&*ImplicitValueInitForUnion);
+assert(Fields.size() <= 1);
+if (!Fields.empty()) {
+  ImplicitValueInitForUnion.emplace(Fields.front()->getType());
+  InitsForUnion.push_back(&*ImplicitValueInitForUnion);
+}
 Inits = InitsForUnion;
   }
 

diff  --git a/clang/unittests/Analysis/FlowSensitive/ASTOpsTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/ASTOpsTest.cpp
new file mode 100644
index 0..cd1c076ab09e6
--- /dev/null
+++ b/clang/unittests/Analysis/FlowSensitive/ASTOpsTest.cpp
@@ -0,0 +1,88 @@
+//===- unittests/Analysis/FlowSensitive/ASTOpsTest.cpp 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Analysis/FlowSensitive/ASTOps.h"
+#include "TestingSupport.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace {
+
+using namespace clang;
+using namespace dataflow;
+
+using ast_matchers::cxxRecordDecl;
+using ast_matchers::hasName;
+using ast_matchers::hasType;
+using ast_matchers::initListExpr;
+using ast_matchers::match;
+using ast_matchers::selectFirst;
+using test::findValueDecl;
+using testing::IsEmpty;
+using testing::UnorderedElementsAre;
+
+TEST(ASTOpsTest, RecordInitListHelperOnEmptyUnionInitList) {
+  // This is a regression test: The `RecordInitListHelper` used to assert-fail
+  // when called for the `InitListExpr` of an empty union.
+  std::string Code = R"cc(
+struct S {
+  S() : UField{} {};
+
+  union U {} UField;
+};
+  )cc";
+  std::unique_ptr Unit =
+  tooling::buildASTFromCodeWithArgs(Code, {"-fsyntax-only", "-std=c++17"});
+  auto &ASTCtx = Unit->getASTContext();
+
+  ASSERT_EQ(ASTCtx.getDiagnostics().getClient()->getNumErrors(), 0U);
+
+  auto *InitList = selectFirst(
+  "init",
+  match(initListExpr(hasType(cxxRecordDecl(hasName("U".bind("init"),
+ASTCtx));
+  ASSERT_NE(InitList, nullptr);
+
+  RecordInitListHelper Helper(InitList);
+  EXPECT_THAT(Helper.base_inits(), IsEm

[clang] [llvm] [clang][nullability] Don't return null fields from `getReferencedDecls()`. (PR #94983)

2024-06-10 Thread via cfe-commits

martinboehme wrote:

> Thanks! I'm once again struck by how much this project would benefit from 
> Nullability annotations/checking.

Indeed -- that was my thought too.

https://github.com/llvm/llvm-project/pull/94983
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Handle `AtomicExpr` in `ResultObjectVisitor`. (PR #94963)

2024-06-10 Thread via cfe-commits

https://github.com/martinboehme closed 
https://github.com/llvm/llvm-project/pull/94963
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2825342 - [clang][dataflow] Handle `AtomicExpr` in `ResultObjectVisitor`. (#94963)

2024-06-10 Thread via cfe-commits

Author: martinboehme
Date: 2024-06-11T08:38:03+02:00
New Revision: 282534268e3be0949fcac1589b1004bc5672b434

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

LOG: [clang][dataflow] Handle `AtomicExpr` in `ResultObjectVisitor`. (#94963)

This is one of the node kinds that should be considered an "original
initializer". The patch adds a test that was causing an assertion
failure in
`assert(Children.size() == 1)` without the fix.

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 0d7967c8b9344..7c88917faf9c6 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -415,7 +415,7 @@ class ResultObjectVisitor : public 
AnalysisASTVisitor {
 // below them can initialize the same object (or part of it).
 if (isa(E) || isa(E) || isa(E) ||
 isa(E) || isa(E) ||
-isa(E) ||
+isa(E) || isa(E) ||
 // We treat `BuiltinBitCastExpr` as an "original initializer" too as
 // it may not even be casting from a record type -- and even if it is,
 // the two objects are in general of unrelated type.

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index f7e6b0c22e8db..2a74d7fa63fd7 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3345,6 +3345,32 @@ TEST(TransferTest, 
ResultObjectLocationForBuiltinBitCastExpr) {
   });
 }
 
+TEST(TransferTest, ResultObjectLocationForAtomicExpr) {
+  std::string Code = R"(
+struct S {};
+void target(_Atomic(S) *ptr) {
+  S s = __c11_atomic_load(ptr, __ATOMIC_SEQ_CST);
+  // [[p]]
+}
+  )";
+  using ast_matchers::atomicExpr;
+  using ast_matchers::match;
+  using ast_matchers::selectFirst;
+  using ast_matchers::traverse;
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+auto *Atomic = selectFirst(
+"atomic", match(atomicExpr().bind("atomic"), ASTCtx));
+
+EXPECT_EQ(&Env.getResultObjectLocation(*Atomic),
+  &getLocForDecl(ASTCtx, Env, "s"));
+  });
+}
+
 TEST(TransferTest, ResultObjectLocationPropagatesThroughConditionalOperator) {
   std::string Code = R"(
 struct A {



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


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2024-06-10 Thread Chuanqi Xu via cfe-commits


@@ -3219,7 +3219,8 @@ void CodeGenModule::EmitVTablesOpportunistically() {
   for (const CXXRecordDecl *RD : OpportunisticVTables) {
 assert(getVTables().isVTableExternal(RD) &&
"This queue should only contain external vtables");
-if (getCXXABI().canSpeculativelyEmitVTable(RD))
+if (getCXXABI().canSpeculativelyEmitVTable(RD) &&
+!RD->shouldEmitInExternalSource())

ChuanqiXu9 wrote:

Done

https://github.com/llvm/llvm-project/pull/75912
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2024-06-10 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/75912

>From cf8be3c418dde67b74d4a5a4ea98a33f0e2fbd72 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Tue, 19 Dec 2023 17:00:59 +0800
Subject: [PATCH 1/4] [C++20] [Modules] [Itanium ABI] Generate the vtable in
 the module unit of dynamic classes

Close https://github.com/llvm/llvm-project/issues/70585 and reflect
https://github.com/itanium-cxx-abi/cxx-abi/issues/170.

The significant change of the patch is: for dynamic classes attached to
module units, we generate the vtable to the attached module units
directly and the key functions for such classes is meaningless.
---
 clang/include/clang/AST/DeclBase.h|  3 ++
 clang/lib/AST/DeclBase.cpp|  9 +
 clang/lib/CodeGen/CGVTables.cpp   | 28 ++
 clang/lib/CodeGen/CodeGenModule.cpp   |  7 
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  3 ++
 clang/lib/Sema/SemaDecl.cpp   |  9 +
 clang/lib/Sema/SemaDeclCXX.cpp| 12 --
 clang/lib/Serialization/ASTReaderDecl.cpp |  6 +++
 clang/lib/Serialization/ASTWriterDecl.cpp |  6 +++
 clang/test/CodeGenCXX/modules-vtable.cppm | 31 +--
 clang/test/CodeGenCXX/pr70585.cppm| 47 +++
 11 files changed, 138 insertions(+), 23 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/pr70585.cppm

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 600ce73c7f019..f38386381853b 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -670,6 +670,9 @@ class alignas(8) Decl {
   /// Whether this declaration comes from another module unit.
   bool isInAnotherModuleUnit() const;
 
+  /// Whether this declaration comes from the same module unit being compiled.
+  bool isInCurrentModuleUnit() const;
+
   /// Whether the definition of the declaration should be emitted in external
   /// sources.
   bool shouldEmitInExternalSource() const;
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 1e9c879e371bc..153dc3351dae5 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1106,6 +1106,15 @@ bool Decl::isInAnotherModuleUnit() const {
   return M != getASTContext().getCurrentNamedModule();
 }
 
+bool Decl::isInCurrentModuleUnit() const {
+  auto *M = getOwningModule();
+
+  if (!M || !M->isNamedModule())
+return false;
+
+  return M == getASTContext().getCurrentNamedModule();
+}
+
 bool Decl::shouldEmitInExternalSource() const {
   ExternalASTSource *Source = getASTContext().getExternalSource();
   if (!Source)
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 001633453f242..55c3032dc9332 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -1051,6 +1051,11 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) 
{
   if (!RD->isExternallyVisible())
 return llvm::GlobalVariable::InternalLinkage;
 
+  // V-tables for non-template classes with an owning module are always
+  // uniquely emitted in that module.
+  if (RD->isInNamedModule())
+return llvm::GlobalVariable::ExternalLinkage;
+
   // We're at the end of the translation unit, so the current key
   // function is fully correct.
   const CXXMethodDecl *keyFunction = Context.getCurrentKeyFunction(RD);
@@ -1185,6 +1190,21 @@ bool CodeGenVTables::isVTableExternal(const 
CXXRecordDecl *RD) {
   TSK == TSK_ExplicitInstantiationDefinition)
 return false;
 
+  // Itanium C++ ABI [5.2.3]:
+  // Virtual tables for dynamic classes are emitted as follows:
+  //
+  // - If the class is templated, the tables are emitted in every object that
+  // references any of them.
+  // - Otherwise, if the class is attached to a module, the tables are uniquely
+  // emitted in the object for the module unit in which it is defined.
+  // - Otherwise, if the class has a key function (see below), the tables are
+  // emitted in the object for the translation unit containing the definition 
of
+  // the key function. This is unique if the key function is not inline.
+  // - Otherwise, the tables are emitted in every object that references any of
+  // them.
+  if (RD->isInNamedModule())
+return RD->shouldEmitInExternalSource();
+
   // Otherwise, if the class doesn't have a key function (possibly
   // anymore), the vtable must be defined here.
   const CXXMethodDecl *keyFunction = 
CGM.getContext().getCurrentKeyFunction(RD);
@@ -1194,13 +1214,7 @@ bool CodeGenVTables::isVTableExternal(const 
CXXRecordDecl *RD) {
   const FunctionDecl *Def;
   // Otherwise, if we don't have a definition of the key function, the
   // vtable must be defined somewhere else.
-  if (!keyFunction->hasBody(Def))
-return true;
-
-  assert(Def && "The body of the key function is not assigned to Def?");
-  // If the non-inline key function comes from another module unit, the vtable
-  // must be defined there.
-  return Def->sho

[clang] [clang-tools-extra] [llvm] [RISCV][MC] Warn if SEW/LMUL may not be compatible (PR #94313)

2024-06-10 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp closed 
https://github.com/llvm/llvm-project/pull/94313
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] [RISCV][MC] Warn if SEW/LMUL may not be compatible (PR #94313)

2024-06-10 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp edited 
https://github.com/llvm/llvm-project/pull/94313
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() (PR #90043)

2024-06-10 Thread Carlos Galvez via cfe-commits

carlosgalvezp wrote:

To be clear and reiterate my previous comment: this check should NOT require 
users to use at(). That behavior should be opt-in. It should only warn about 
using operator[]. It's up to the users to figure out what the best replacement 
is.

https://github.com/llvm/llvm-project/pull/90043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Use clang_target_link_libraries() for clang libs (PR #94937)

2024-06-10 Thread Nikita Popov via cfe-commits

https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/94937
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 34033dc - [clangd] Use clang_target_link_libraries() for clang libs (#94937)

2024-06-10 Thread via cfe-commits

Author: Nikita Popov
Date: 2024-06-11T08:08:03+02:00
New Revision: 34033dc1610982570328b39a38596a9968e3c7b2

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

LOG: [clangd] Use clang_target_link_libraries() for clang libs (#94937)

Use clang_target_link_libraries() instead of LINK_LIBS when linking
clang libraries. This ensures that in CLANG_LINK_CLANG_DYLIB mode we
link against libclang-cpp.so (instead of linking against both it and the
static libraries).

Most places were already doing this correctly, there were just a handful
of leftovers.

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/CMakeLists.txt
clang-tools-extra/pseudo/lib/CMakeLists.txt
clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
index ed6269d2ccaa9..106bbeff84ccf 100644
--- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -26,7 +26,6 @@ if (CLANGD_ENABLE_REMOTE)
 clangdRemoteIndexProto
 clangdRemoteIndexServiceProto
 clangdRemoteMarshalling
-clangBasic
 clangDaemon
 clangdSupport
 
@@ -35,6 +34,11 @@ if (CLANGD_ENABLE_REMOTE)
 clangdRemoteIndexServiceProto
 )
 
+  clang_target_link_libraries(clangdRemoteIndex
+PRIVATE
+clangBasic
+)
+
   add_subdirectory(marshalling)
   add_subdirectory(server)
   add_subdirectory(monitor)

diff  --git a/clang-tools-extra/pseudo/lib/CMakeLists.txt 
b/clang-tools-extra/pseudo/lib/CMakeLists.txt
index f92f79be12150..a13b5d20cf7c3 100644
--- a/clang-tools-extra/pseudo/lib/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/lib/CMakeLists.txt
@@ -14,8 +14,6 @@ add_clang_library(clangPseudo
   Token.cpp
 
   LINK_LIBS
-  clangBasic
-  clangLex
   clangPseudoGrammar
 
   DEPENDS
@@ -25,3 +23,9 @@ add_clang_library(clangPseudo
   target_include_directories(clangPseudo INTERFACE
   $
   )
+
+clang_target_link_libraries(clangPseudo
+  PRIVATE
+  clangBasic
+  clangLex
+  )

diff  --git a/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt 
b/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
index d56d16c893c3d..2fecdce6a10f9 100644
--- a/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt
@@ -9,7 +9,11 @@ add_clang_library(clangPseudoCXX
   cxx_gen
 
   LINK_LIBS
-  clangBasic
   clangPseudo
   clangPseudoGrammar
   )
+
+clang_target_link_libraries(clangPseudoCXX
+  PRIVATE
+  clangBasic
+  )



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


[clang] [llvm] [RISCV] Add B extension (PR #76893)

2024-06-10 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp closed 
https://github.com/llvm/llvm-project/pull/76893
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)

2024-06-10 Thread Mark Zhuang via cfe-commits


@@ -381,3 +381,21 @@ def XIANGSHAN_NANHU : 
RISCVProcessorModel<"xiangshan-nanhu",
 TuneZExtHFusion,
 TuneZExtWFusion,
 TuneShiftedZExtWFusion]>;
+
+def SPACEMIT_X60 : RISCVProcessorModel<"spacemit-x60",
+   NoSchedModel,
+   !listconcat(RVA22S64Features,
+   [FeatureStdExtV,
+FeatureStdExtSscofpmf,
+FeatureStdExtSstc,
+FeatureStdExtSvnapot,
+FeatureStdExtZbc,
+FeatureStdExtZbkc,
+FeatureStdExtZfh,
+FeatureStdExtZicond,
+FeatureStdExtZmmul,
+FeatureStdExtZvfh,
+FeatureStdExtZvfhmin,
+FeatureStdExtZvkt,
+FeatureStdExtZvl256b]),
+   [TuneDLenFactor2]>;

zqb-all wrote:

Since no specific information is publicly available, I think this patch can 
ignore macro-fusion for now

https://github.com/llvm/llvm-project/pull/94564
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1bebb99 - [RISCV] Add B extension (#76893)

2024-06-10 Thread via cfe-commits

Author: Pengcheng Wang
Date: 2024-06-11T14:06:23+08:00
New Revision: 1bebb99324a1cd85e18e1907c7afdde5d2bc4593

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

LOG: [RISCV] Add B extension (#76893)

It seems that we have `B` extension again:
https://github.com/riscv/riscv-b

According to the spec, `B` extension represents the collection of
the `Zba`, `Zbb`, `Zbs` extensions.

Though it hasn't been ratified, I set its version to `1.0`.

Added: 


Modified: 
clang/test/Driver/riscv-arch.c
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/docs/ReleaseNotes.rst
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/test/CodeGen/RISCV/attributes.ll
llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Removed: 




diff  --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index ddf617bbb6237..ffd92e1f398c4 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -231,11 +231,6 @@
 // RV32-STD: error: invalid arch name 'rv32imqc',
 // RV32-STD: unsupported standard user-level extension 'q'
 
-// RUN: not %clang --target=riscv32-unknown-elf -march=rv32ib -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-B %s
-// RV32-B: error: invalid arch name 'rv32ib',
-// RV32-B: unsupported standard user-level extension 'b'
-
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32xabc -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32X %s
 // RV32X: error: invalid arch name 'rv32xabc',

diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 09b9ad0a160bb..91307141e0406 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -7,6 +7,7 @@
 // CHECK-NOT: __riscv_64e {{.*$}}
 // CHECK-NOT: __riscv_a {{.*$}}
 // CHECK-NOT: __riscv_atomic
+// CHECK-NOT: __riscv_b {{.*$}}
 // CHECK-NOT: __riscv_c {{.*$}}
 // CHECK-NOT: __riscv_compressed {{.*$}}
 // CHECK-NOT: __riscv_d {{.*$}}
@@ -194,6 +195,17 @@
 // CHECK-A-EXT: __riscv_a 2001000{{$}}
 // CHECK-A-EXT: __riscv_atomic 1
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32ib -x c -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64ib -x c -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// CHECK-B-EXT: __riscv_b 100{{$}}
+// CHECK-B-EXT: __riscv_zba 100{{$}}
+// CHECK-B-EXT: __riscv_zbb 100{{$}}
+// CHECK-B-EXT: __riscv_zbs 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32ic -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-C-EXT %s

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 35115e67ecf92..ef06f80c747f9 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -85,6 +85,7 @@ on support follow.
  Extension Status
    
=
  ``A`` Supported
+ ``B`` Supported
  ``C`` Supported
  ``D`` Supported
  ``F`` Supported

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 8cdb9db087c77..b46994bbcd66d 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -152,6 +152,7 @@ Changes to the RISC-V Backend
 * Zaamo and Zalrsc are no longer experimental.
 * Processors that enable post reg-alloc scheduling (PostMachineScheduler) by 
default should use the `UsePostRAScheduler` subtarget feature. Setting 
`PostRAScheduler = 1` in the scheduler model will have no effect on the 
enabling of the PostMachineScheduler.
 * Zabha is no longer experimental.
+* B (the collection of the Zba, Zbb, Zbs extensions) is supported.
 
 Changes to the WebAssembly Backend
 --

diff  --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 9bf06850483d8..011edca019fd6 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -477,6 +477,14 @@ def HasStdExtZbs : Predicate<"Subtarget->hasStdExtZbs()">,
 
 // Bitmanip Extensions for Cryptography Extensions
 
+def FeatureStdExtB
+: RISCVExtension<"b", 1, 0,
+ "'B' (the collection of the Zba, Zbb, Zbs extensions)",
+ [FeatureStdExtZba, FeatureStdExtZbb, FeatureStdExtZbs]>;
+def HasStdExtB : Predicate<"Subtarget->hasStdExtB()">,
+   AssemblerPredicate<(all_of FeatureStdExtB),
+   "'B' (the collection of the Zba, Zbb, Zbs 
extensions)">;
+
 def F

[clang] 607afa0 - Revert "[llvm][IR] Extend BranchWeightMetadata to track provenance of weights" (#95060)

2024-06-10 Thread via cfe-commits

Author: Paul Kirth
Date: 2024-06-11T08:06:06+02:00
New Revision: 607afa0b6375e4837fef298a798f5534e783d777

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

LOG: Revert "[llvm][IR] Extend BranchWeightMetadata to track provenance of 
weights" (#95060)

Reverts llvm/llvm-project#86609

This change causes compile-time regressions for stage2 builds
(https://llvm-compile-time-tracker.com/compare.php?from=3254f31a66263ea9647c9547f1531c3123444fcd&to=c5978f1eb5eeca8610b9dfce1fcbf1f473911cd8&stat=instructions:u).
It also introduced unintended changes to `.text` which should be
addressed before relanding.

Added: 


Modified: 
clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
llvm/docs/BranchWeightMetadata.rst
llvm/include/llvm/IR/MDBuilder.h
llvm/include/llvm/IR/ProfDataUtils.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/IR/Instruction.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/MDBuilder.cpp
llvm/lib/IR/Metadata.cpp
llvm/lib/IR/ProfDataUtils.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/lib/Transforms/Scalar/JumpThreading.cpp
llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/lib/Transforms/Utils/LoopPeel.cpp
llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll
llvm/test/Transforms/LowerExpectIntrinsic/expect_nonboolean.ll
llvm/test/Transforms/LowerExpectIntrinsic/phi_merge.ll
llvm/test/Transforms/LowerExpectIntrinsic/phi_or.ll
llvm/test/Transforms/LowerExpectIntrinsic/phi_tern.ll
llvm/test/Transforms/LowerExpectIntrinsic/phi_unexpect.ll
llvm/test/Transforms/PhaseOrdering/AArch64/hoist-runtime-checks.ll

Removed: 




diff  --git a/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp 
b/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
index 81d9334356520..fb236aeb982e0 100644
--- a/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
+++ b/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
@@ -221,5 +221,5 @@ void tu2(int &i) {
   }
 }
 
-// CHECK: [[BW_LIKELY]] = !{!"branch_weights", !"expected", i32 2000, i32 1}
-// CHECK: [[BW_UNLIKELY]] = !{!"branch_weights", !"expected", i32 1, i32 2000}
+// CHECK: [[BW_LIKELY]] = !{!"branch_weights", i32 2000, i32 1}
+// CHECK: [[BW_UNLIKELY]] = !{!"branch_weights", i32 1, i32 2000}

diff  --git a/llvm/docs/BranchWeightMetadata.rst 
b/llvm/docs/BranchWeightMetadata.rst
index 62204753e29b0..522f37cdad4fc 100644
--- a/llvm/docs/BranchWeightMetadata.rst
+++ b/llvm/docs/BranchWeightMetadata.rst
@@ -28,14 +28,11 @@ Supported Instructions
 
 Metadata is only assigned to the conditional branches. There are two extra
 operands for the true and the false branch.
-We optionally track if the metadata was added by ``__builtin_expect`` or
-``__builtin_expect_with_probability`` with an optional field ``!"expected"``.
 
 .. code-block:: none
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 ,
 i32 
   }
@@ -50,7 +47,6 @@ is always case #0).
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ... ]
   }
@@ -64,7 +60,6 @@ Branch weights are assigned to every destination.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ... ]
   }
@@ -80,7 +75,6 @@ block and entry counts which may not be accurate with 
sampling.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
   }
 
@@ -101,7 +95,6 @@ is used.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ]
   }

diff  --git a/llvm/include/llvm/IR/MDBuilder.h 
b/llvm/include/llvm/IR/MDBuilder.h
index e02ec8f5a3d8b..3265589b7c8df 100644
--- a/llvm/include/llvm/IR/MDBuilder.h
+++ b/llvm/include/llvm/IR/MDBuilder.h
@@ -59,11 +59,7 @@ class MDBuilder {
   //===--===//
 
   /// Return metadata containing two branch weights.
-  /// @param TrueWeight the weight of the true branch
-  /// @param FalseWeight the weight of the false branch
-  /// @param Do these weights come from __builtin_expect*
-  MDNode *createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight,
-  bool IsExpected = false);
+  MDNode *createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight);
 
   /// Ret

[clang] [llvm] Revert "[llvm][IR] Extend BranchWeightMetadata to track provenance of weights" (PR #95060)

2024-06-10 Thread Nikita Popov via cfe-commits

https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/95060
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add B extension (PR #76893)

2024-06-10 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/76893

>From 9ab05b9f68def57e9abb9d5ac65293b84aacc95a Mon Sep 17 00:00:00 2001
From: wangpc 
Date: Thu, 4 Jan 2024 13:05:53 +0800
Subject: [PATCH] [RISCV] Add B extension

It seems that we have `B` extension again: https://github.com/riscv/riscv-b

According to the spec, `B` extension represents the collection of
the `Zba`, `Zbb`, `Zbs` extensions.
---
 clang/test/Driver/riscv-arch.c   |  5 -
 clang/test/Preprocessor/riscv-target-features.c  | 12 
 llvm/docs/RISCVUsage.rst |  1 +
 llvm/docs/ReleaseNotes.rst   |  1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td   |  8 
 llvm/test/CodeGen/RISCV/attributes.ll|  4 
 llvm/unittests/TargetParser/RISCVISAInfoTest.cpp |  9 ++---
 7 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index ddf617bbb6237..ffd92e1f398c4 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -231,11 +231,6 @@
 // RV32-STD: error: invalid arch name 'rv32imqc',
 // RV32-STD: unsupported standard user-level extension 'q'
 
-// RUN: not %clang --target=riscv32-unknown-elf -march=rv32ib -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-B %s
-// RV32-B: error: invalid arch name 'rv32ib',
-// RV32-B: unsupported standard user-level extension 'b'
-
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32xabc -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32X %s
 // RV32X: error: invalid arch name 'rv32xabc',
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 09b9ad0a160bb..91307141e0406 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -7,6 +7,7 @@
 // CHECK-NOT: __riscv_64e {{.*$}}
 // CHECK-NOT: __riscv_a {{.*$}}
 // CHECK-NOT: __riscv_atomic
+// CHECK-NOT: __riscv_b {{.*$}}
 // CHECK-NOT: __riscv_c {{.*$}}
 // CHECK-NOT: __riscv_compressed {{.*$}}
 // CHECK-NOT: __riscv_d {{.*$}}
@@ -194,6 +195,17 @@
 // CHECK-A-EXT: __riscv_a 2001000{{$}}
 // CHECK-A-EXT: __riscv_atomic 1
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32ib -x c -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64ib -x c -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// CHECK-B-EXT: __riscv_b 100{{$}}
+// CHECK-B-EXT: __riscv_zba 100{{$}}
+// CHECK-B-EXT: __riscv_zbb 100{{$}}
+// CHECK-B-EXT: __riscv_zbs 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32ic -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-C-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 35115e67ecf92..ef06f80c747f9 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -85,6 +85,7 @@ on support follow.
  Extension Status
    
=
  ``A`` Supported
+ ``B`` Supported
  ``C`` Supported
  ``D`` Supported
  ``F`` Supported
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 8cdb9db087c77..b46994bbcd66d 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -152,6 +152,7 @@ Changes to the RISC-V Backend
 * Zaamo and Zalrsc are no longer experimental.
 * Processors that enable post reg-alloc scheduling (PostMachineScheduler) by 
default should use the `UsePostRAScheduler` subtarget feature. Setting 
`PostRAScheduler = 1` in the scheduler model will have no effect on the 
enabling of the PostMachineScheduler.
 * Zabha is no longer experimental.
+* B (the collection of the Zba, Zbb, Zbs extensions) is supported.
 
 Changes to the WebAssembly Backend
 --
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 9bf06850483d8..011edca019fd6 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -477,6 +477,14 @@ def HasStdExtZbs : Predicate<"Subtarget->hasStdExtZbs()">,
 
 // Bitmanip Extensions for Cryptography Extensions
 
+def FeatureStdExtB
+: RISCVExtension<"b", 1, 0,
+ "'B' (the collection of the Zba, Zbb, Zbs extensions)",
+ [FeatureStdExtZba, FeatureStdExtZbb, FeatureStdExtZbs]>;
+def HasStdExtB : Predicate<"Subtarget->hasStdExtB()">,
+   AssemblerPredicate<(all_of FeatureStdExtB),
+   "'B' (the collection of the Zba, Zbb, Zbs 
extensions)">;
+
 def FeatureStdExtZbkb
 : RISCVExtension<"zbkb", 1, 0,
  "'Z

[clang] [llvm] Revert "[llvm][IR] Extend BranchWeightMetadata to track provenance of weights" (PR #95060)

2024-06-10 Thread Nikita Popov via cfe-commits

https://github.com/nikic approved this pull request.


https://github.com/llvm/llvm-project/pull/95060
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)

2024-06-10 Thread Shao-Ce SUN via cfe-commits


@@ -381,3 +381,21 @@ def XIANGSHAN_NANHU : 
RISCVProcessorModel<"xiangshan-nanhu",
 TuneZExtHFusion,
 TuneZExtWFusion,
 TuneShiftedZExtWFusion]>;
+
+def SPACEMIT_X60 : RISCVProcessorModel<"spacemit-x60",
+   NoSchedModel,
+   !listconcat(RVA22S64Features,
+   [FeatureStdExtV,
+FeatureStdExtSscofpmf,
+FeatureStdExtSstc,
+FeatureStdExtSvnapot,
+FeatureStdExtZbc,
+FeatureStdExtZbkc,
+FeatureStdExtZfh,
+FeatureStdExtZicond,
+FeatureStdExtZmmul,
+FeatureStdExtZvfh,
+FeatureStdExtZvfhmin,

sunshaoce wrote:

Addressed. Thanks!

https://github.com/llvm/llvm-project/pull/94564
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)

2024-06-10 Thread Shao-Ce SUN via cfe-commits

https://github.com/sunshaoce updated 
https://github.com/llvm/llvm-project/pull/94564

>From 363e29385277c049bc91a86e76ff6f6ae70ceaa9 Mon Sep 17 00:00:00 2001
From: Shao-Ce SUN 
Date: Thu, 6 Jun 2024 12:05:33 +0800
Subject: [PATCH 1/7] [RISCV] Add processor definition for Spacemit-K1

---
 clang/test/Driver/riscv-cpus.c| 12 ++
 clang/test/Misc/target-invalid-cpu-note.c |  4 ++--
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 29 +++
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index ff2bd6f7c8ba3..32d7910ab4daa 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -31,6 +31,18 @@
 // MCPU-XIANGSHAN-NANHU-SAME: "-target-feature" "+zks" "-target-feature" 
"+zksed" "-target-feature" "+zksh" "-target-feature" "+svinval"
 // MCPU-XIANGSHAN-NANHU-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=spacemit-k1 | FileCheck 
-check-prefix=MCPU-SPACEMIT-K1 %s
+// MCPU-SPACEMIT-K1: "-nostdsysteminc" "-target-cpu" "spacemit-k1"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+c" "-target-feature" "+v" 
"-target-feature" "+zicond" "-target-feature" "+zicsr"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zifencei" "-target-feature" 
"+zmmul" "-target-feature" "+zfh"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zfhmin" "-target-feature" "+zba" 
"-target-feature" "+zbb" "-target-feature" "+zbc"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zbkb" "-target-feature" "+zbkc" 
"-target-feature" "+zbs" "-target-feature" "+zve32f"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zve32x" "-target-feature" 
"+zve64d" "-target-feature" "+zve64f" "-target-feature" "+zve64x"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zvfh" "-target-feature" 
"+zvfhmin"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zvl128b" "-target-feature" 
"+zvl256b" "-target-feature" "+zvl32b" "-target-feature" "+zvl64b"
+// MCPU-SPACEMIT-K1-SAME: "-target-abi" "lp64d"
+
 // We cannot check much for -mcpu=native, but it should be replaced by a valid 
CPU string.
 // RUN: %clang --target=riscv64 -### -c %s -mcpu=native 2> %t.err || true
 // RUN: FileCheck --input-file=%t.err -check-prefix=MCPU-NATIVE %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 6558fd753d1d1..04e92360fe665 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, veyron-v1, xiangshan-nanhu{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, spacemit-k1, veyron-v1, 
xiangshan-nanhu{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
@@ -93,4 +93,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, 
sifive-s76, sifive-u54, sifive-u74, sifive-x280, veyron-v1, xiangshan-nanhu, 
generic, rocket, sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, 
sifive-s76, sifive-u54, sifive-u74, sifive-x280, spacemit-k1, veyron-v1, 
xiangshan-nanhu, generic, rocket, sifive-7-series{{$}}
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 6ebf9f1eb0452..08602e9d06cc9 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -381,3 +381,32 @@ def XIANGSHAN_NANHU : 
RISCVProcessorModel<"xiangshan-nanhu",
 TuneZExtHFusion,
 TuneZExtWFusion,
 TuneShiftedZExtWFusion]>;
+
+def SPACEMIT_K1 : RISCVProcessorModel<"spacemit-k1",
+   NoSchedModel,
+   [Feature64Bit,
+FeatureStdExtI,
+FeatureStdExtM,
+

[clang] [clang] Don't use -Wno-nested-anon-types on GCC (PR #95029)

2024-06-10 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo closed 
https://github.com/llvm/llvm-project/pull/95029
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 41c650e - [clang] Don't use -Wno-nested-anon-types on GCC (#95029)

2024-06-10 Thread via cfe-commits

Author: Martin Storsjö
Date: 2024-06-11T09:03:41+03:00
New Revision: 41c650e8208f7804eb5ecd8749d6b31b6e518bb7

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

LOG: [clang] Don't use -Wno-nested-anon-types on GCC (#95029)

GCC usually doesn't warn about unrecognized -Wno- options, if no
diagnostics are printed. However if some diagnostics are printed, it
also mentions that there were unrecognized -Wno- options.

Before 4feae05c6abda364a9295aecfa600d7d4e7dfeb6, we checked for whether
-Wnested-anon-types was supported, and added the -Wno- form if the
positive form of the option was supported.

As of GCC 14, -Wnested-anon-types isn't supported, thus limit the use of
the option to actual Clang (and still only while using the GCC
compatible driver).

This avoids unnecessary mentions about unrecognized -Wno- options
when building with GCC.

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f6d96258cd135..c6496167d3828 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -350,7 +350,9 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long")
   endif ()
 
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
+  if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
+  endif ()
 endif ()
 
 # Determine HOST_LINK_VERSION on Darwin.



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


[clang] [flang] [mlir] [flang] Add basic -mtune support (PR #95043)

2024-06-10 Thread Christian Ulmann via cfe-commits


@@ -58,6 +58,15 @@ def FramePointerKindAttr : LLVM_Attr<"FramePointerKind", 
"framePointerKind"> {
   let assemblyFormat = "`<` $framePointerKind `>`";
 }
 
+//===--===//
+// TuneCPUAttr
+//===--===//
+
+//def TuneCPUAttr : LLVM_Attr<"TuneCPU", "tuneCPU"> {
+  //let parameters = (ins "tuneCPU::tuneCPU":$tuneCPU);
+  //let assemblyFormat = "`<` $tuneCPU `>`";
+//}

Dinistro wrote:

Dead code?

https://github.com/llvm/llvm-project/pull/95043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] [flang] Add basic -mtune support (PR #95043)

2024-06-10 Thread Christian Ulmann via cfe-commits


@@ -411,6 +412,13 @@ void Flang::addTargetOptions(const ArgList &Args,
   }
 
   // TODO: Add target specific flags, ABI, mtune option etc.
+  if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) {
+CmdArgs.push_back("-tune-cpu");
+if (strcmp(A->getValue(), "native") == 0)

Dinistro wrote:

Nit: `strcmp` is a C function. I assume that `A->getValue()` returns a 
StringRef, or something else that supports normal `==` comparison. 

https://github.com/llvm/llvm-project/pull/95043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] [flang] Add basic -mtune support (PR #95043)

2024-06-10 Thread Christian Ulmann via cfe-commits

https://github.com/Dinistro edited 
https://github.com/llvm/llvm-project/pull/95043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [mlir] [flang] Add basic -mtune support (PR #95043)

2024-06-10 Thread Christian Ulmann via cfe-commits

https://github.com/Dinistro commented:

This is missing tests for the LLVM import and export. I suspect that this is 
currently still part of the function's passthrough dictionary, which should be 
changed.

https://github.com/llvm/llvm-project/pull/95043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add riscv_atomic.h and Zawrs/Zalrsc builtins (PR #94578)

2024-06-10 Thread Craig Topper via cfe-commits

topperc wrote:

> Compilers are free to insert whatever stack spills and reloads they want in 
> between your inline assembly blocks or intrinsic calls

Especially with -O0.

https://github.com/llvm/llvm-project/pull/94578
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clangd] Support parsing comments without ASTContext (PR #78491)

2024-06-10 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

> What's "ping PR"? Do you mean pinging the LLVM organization?

It just means posting a comment on the PR that says "ping", as a reminder for 
reviewers.

(But please only do that if you're the patch author, or, in the case of a patch 
author who's not active any more, if you're volunteering to take over the patch 
from the patch author and do the work of addressing any remaining review 
comments.)

>> What's preventing this PR from being merged right now? All checks seem to 
>> have passed.
> PRs need to be reviewed before they can be merged.

Yes, code reviewer bandwidth is the bottleneck for clangd patches at the moment.

I have some other patches in my review queue which I've been trying to get to 
(and unfortunately haven't had much time to spend on them), so I'm hoping Kadir 
can review this one, especially as he has reviewed earlier versions of this and 
related patches and has more familiarity with the affected code areas.

But if no one else gets to this, I would like to at some point.

https://github.com/llvm/llvm-project/pull/78491
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)

2024-06-10 Thread NAKAMURA Takumi via cfe-commits


@@ -484,10 +484,31 @@ MC/DC Instrumentation
 -
 
 When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the
-clang option ``-fcoverage-mcdc``, users are limited to at most **six** 
leaf-level
-conditions in a boolean expression.  A warning will be generated for boolean
-expressions that contain more than six, and they will not be instrumented for
-MC/DC.
+clang option ``-fcoverage-mcdc``, there are two hard limits.

chapuni wrote:

Do you suggest replacing "there are two hard limits" with the explanation of 
`max-conditions=32767`?

https://github.com/llvm/llvm-project/pull/82448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)

2024-06-10 Thread NAKAMURA Takumi via cfe-commits


@@ -484,10 +484,31 @@ MC/DC Instrumentation
 -
 
 When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the
-clang option ``-fcoverage-mcdc``, users are limited to at most **six** 
leaf-level
-conditions in a boolean expression.  A warning will be generated for boolean
-expressions that contain more than six, and they will not be instrumented for
-MC/DC.
+clang option ``-fcoverage-mcdc``, there are two hard limits.
+
+The maximum number of terms is limited to 32767, which is practical for
+handwritten expressions. To be more restrictive in order to enforce coding 
rules,
+use ``-Xclang -fmcdc-max-conditions=n``. Expressions with exceeded condition
+counts ``n`` will generate warnings.
+
+The number of test vectors (the maximum number of possible combinations of
+expressions) is limited to 2,147,483,646. In this case, approximately
+256MiB (==2GiB/8) is used to record test vectors.
+
+To reduce memory usage, you can limit the maximum number of test vectors per

chapuni wrote:

Oh I didn't type "you" at first. Re-translation transformed the sentence.
Maybe "users" here, rather than transforming to passive sentence?

https://github.com/llvm/llvm-project/pull/82448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)

2024-06-10 Thread Jessica Paquette via cfe-commits


@@ -484,10 +484,31 @@ MC/DC Instrumentation
 -
 
 When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the
-clang option ``-fcoverage-mcdc``, users are limited to at most **six** 
leaf-level
-conditions in a boolean expression.  A warning will be generated for boolean
-expressions that contain more than six, and they will not be instrumented for
-MC/DC.
+clang option ``-fcoverage-mcdc``, there are two hard limits.
+
+The maximum number of terms is limited to 32767, which is practical for
+handwritten expressions. To be more restrictive in order to enforce coding 
rules,
+use ``-Xclang -fmcdc-max-conditions=n``. Expressions with exceeded condition
+counts ``n`` will generate warnings.
+
+The number of test vectors (the maximum number of possible combinations of
+expressions) is limited to 2,147,483,646. In this case, approximately
+256MiB (==2GiB/8) is used to record test vectors.
+
+To reduce memory usage, you can limit the maximum number of test vectors per

ornata wrote:

Suggest consistently using "user" or "you" throughout docs.

https://github.com/llvm/llvm-project/pull/82448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)

2024-06-10 Thread Jessica Paquette via cfe-commits

https://github.com/ornata commented:

Some nits on documentation wording. Code looks fine to me.

https://github.com/llvm/llvm-project/pull/82448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)

2024-06-10 Thread Jessica Paquette via cfe-commits

https://github.com/ornata edited https://github.com/llvm/llvm-project/pull/82448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)

2024-06-10 Thread Jessica Paquette via cfe-commits


@@ -484,10 +484,31 @@ MC/DC Instrumentation
 -
 
 When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the
-clang option ``-fcoverage-mcdc``, users are limited to at most **six** 
leaf-level
-conditions in a boolean expression.  A warning will be generated for boolean
-expressions that contain more than six, and they will not be instrumented for
-MC/DC.
+clang option ``-fcoverage-mcdc``, there are two hard limits.

ornata wrote:

Suggest simplifying the phrasing here.

> By default, Modified Condition/Decision Coverage (MC/DC) instrumentation is 
> limited to 32767 terms. Users may provide their own limit on the number of 
> terms, `n` by passing ``-Xclang -fmcdc-max-conditions=n``.

https://github.com/llvm/llvm-project/pull/82448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add riscv_atomic.h and Zawrs/Zalrsc builtins (PR #94578)

2024-06-10 Thread Jessica Clarke via cfe-commits

jrtc27 wrote:

> If we are talking about the necessariness of adding these intrinsics, please 
> refer to the ARM implementations in DPDK 
> (https://github.com/DPDK/dpdk/blob/76cef1af8bdaeaf67a5c4ca5df3f221df994dc46/lib/eal/arm/include/rte_pause_64.h).
> 
> We want to use Zawrs&Zalrsc instructions to implement these on RISCV.

Then write the loops in assembly. Really, it's not hard to do, and it's the 
only real way to guarantee it'll actually work the way you think it does. 
Compilers are free to insert whatever stack spills and reloads they want in 
between your inline assembly blocks or intrinsic calls, which can wreak havoc 
with load reservations if you're expecting them to be untouched in between. C 
is just not the right language to be modelling that kind of thing in, assembly 
is.

https://github.com/llvm/llvm-project/pull/94578
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sanitizers] Add numerical sanitizer (PR #93783)

2024-06-10 Thread Alexander Shaposhnikov via cfe-commits

https://github.com/alexander-shaposhnikov closed 
https://github.com/llvm/llvm-project/pull/93783
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 48f8130 - [Clang][Sanitizers] Add numerical sanitizer (#93783)

2024-06-10 Thread via cfe-commits

Author: Alexander Shaposhnikov
Date: 2024-06-10T22:14:26-07:00
New Revision: 48f8130a49aad715ff6d5136dad2447d41e9537b

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

LOG: [Clang][Sanitizers] Add numerical sanitizer (#93783)

Add plumbing for the numerical sanitizer on Clang's side.

Added: 
clang/test/CodeGen/sanitize-numerical-stability-attr.cpp
clang/test/Lexer/has_feature_numerical_stability_sanitizer.cpp

Modified: 
clang/include/clang/Basic/Features.def
clang/include/clang/Basic/Sanitizers.def
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index b762e44e755ec..53f410d3cb4bd 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -96,6 +96,7 @@ FEATURE(nullability, true)
 FEATURE(nullability_on_arrays, true)
 FEATURE(nullability_on_classes, true)
 FEATURE(nullability_nullable_result, true)
+FEATURE(numerical_stability_sanitizer, 
LangOpts.Sanitize.has(SanitizerKind::NumericalStability))
 FEATURE(memory_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Memory |
SanitizerKind::KernelMemory))

diff  --git a/clang/include/clang/Basic/Sanitizers.def 
b/clang/include/clang/Basic/Sanitizers.def
index b228ffd07ee74..bee35e9dca7c3 100644
--- a/clang/include/clang/Basic/Sanitizers.def
+++ b/clang/include/clang/Basic/Sanitizers.def
@@ -76,6 +76,9 @@ SANITIZER("fuzzer-no-link", FuzzerNoLink)
 // ThreadSanitizer
 SANITIZER("thread", Thread)
 
+// Numerical stability sanitizer.
+SANITIZER("numerical", NumericalStability)
+
 // LeakSanitizer
 SANITIZER("leak", Leak)
 

diff  --git a/clang/include/clang/Driver/SanitizerArgs.h 
b/clang/include/clang/Driver/SanitizerArgs.h
index 07070ec4fc065..47ef175302679 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -103,6 +103,9 @@ class SanitizerArgs {
   bool needsCfiDiagRt() const;
   bool needsStatsRt() const { return Stats; }
   bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
+  bool needsNsanRt() const {
+return Sanitizers.has(SanitizerKind::NumericalStability);
+  }
 
   bool hasMemTag() const {
 return hasMemtagHeap() || hasMemtagStack() || hasMemtagGlobals();

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index b047279912f6b..a88bb2af59fee 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -476,6 +476,10 @@ llvm::Function 
*CodeGenModule::CreateGlobalInitOrCleanUpFunction(
   !isInNoSanitizeList(SanitizerKind::Thread, Fn, Loc))
 Fn->addFnAttr(llvm::Attribute::SanitizeThread);
 
+  if (getLangOpts().Sanitize.has(SanitizerKind::NumericalStability) &&
+  !isInNoSanitizeList(SanitizerKind::NumericalStability, Fn, Loc))
+Fn->addFnAttr(llvm::Attribute::SanitizeNumericalStability);
+
   if (getLangOpts().Sanitize.has(SanitizerKind::Memory) &&
   !isInNoSanitizeList(SanitizerKind::Memory, Fn, Loc))
 Fn->addFnAttr(llvm::Attribute::SanitizeMemory);

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index f84b3b08220fd..cea0d84c64bc4 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -818,6 +818,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType 
RetTy,
   Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
 if (SanOpts.has(SanitizerKind::Thread))
   Fn->addFnAttr(llvm::Attribute::SanitizeThread);
+if (SanOpts.has(SanitizerKind::NumericalStability))
+  Fn->addFnAttr(llvm::Attribute::SanitizeNumericalStability);
 if (SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))
   Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
   }

diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 273f215ca94a8..86825a6ccf7a1 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -41,7 +41,8 @@ static const SanitizerMask NotAllowedWithExecuteOnly =
 SanitizerKind::Function | SanitizerKind::KCFI;
 static const SanitizerMask NeedsUnwindTables =
 SanitizerKind::Address | SanitizerKind::HWAddress | SanitizerKind::Thread |
-SanitizerKind::Memory | SanitizerKind::DataFlow;
+SanitizerKind::Memory | SanitizerKind::DataFlow |
+SanitizerKind::NumericalStability;
 static const SanitizerMask SupportsCoverage =
 SanitizerK

[clang] [Clang][Sanitizers] Add numerical sanitizer (PR #93783)

2024-06-10 Thread Alexander Shaposhnikov via cfe-commits

https://github.com/alexander-shaposhnikov updated 
https://github.com/llvm/llvm-project/pull/93783

>From 8c5199181b94d1ae79f3ca7758ed8574774da551 Mon Sep 17 00:00:00 2001
From: Alexander Shaposhnikov 
Date: Thu, 30 May 2024 08:15:44 +
Subject: [PATCH] [Clang][Sanitizers] Add numerical sanitizer

---
 clang/include/clang/Basic/Features.def|  1 +
 clang/include/clang/Basic/Sanitizers.def  |  3 ++
 clang/include/clang/Driver/SanitizerArgs.h|  3 ++
 clang/lib/CodeGen/CGDeclCXX.cpp   |  4 +++
 clang/lib/CodeGen/CodeGenFunction.cpp |  2 ++
 clang/lib/Driver/SanitizerArgs.cpp|  7 ++--
 clang/lib/Driver/ToolChains/Darwin.cpp|  1 +
 clang/lib/Driver/ToolChains/Linux.cpp |  3 ++
 .../sanitize-numerical-stability-attr.cpp | 34 +++
 clang/test/Driver/fsanitize.c | 15 
 ..._feature_numerical_stability_sanitizer.cpp | 11 ++
 11 files changed, 82 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/sanitize-numerical-stability-attr.cpp
 create mode 100644 
clang/test/Lexer/has_feature_numerical_stability_sanitizer.cpp

diff --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index b762e44e755ec..53f410d3cb4bd 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -96,6 +96,7 @@ FEATURE(nullability, true)
 FEATURE(nullability_on_arrays, true)
 FEATURE(nullability_on_classes, true)
 FEATURE(nullability_nullable_result, true)
+FEATURE(numerical_stability_sanitizer, 
LangOpts.Sanitize.has(SanitizerKind::NumericalStability))
 FEATURE(memory_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Memory |
SanitizerKind::KernelMemory))
diff --git a/clang/include/clang/Basic/Sanitizers.def 
b/clang/include/clang/Basic/Sanitizers.def
index b228ffd07ee74..bee35e9dca7c3 100644
--- a/clang/include/clang/Basic/Sanitizers.def
+++ b/clang/include/clang/Basic/Sanitizers.def
@@ -76,6 +76,9 @@ SANITIZER("fuzzer-no-link", FuzzerNoLink)
 // ThreadSanitizer
 SANITIZER("thread", Thread)
 
+// Numerical stability sanitizer.
+SANITIZER("numerical", NumericalStability)
+
 // LeakSanitizer
 SANITIZER("leak", Leak)
 
diff --git a/clang/include/clang/Driver/SanitizerArgs.h 
b/clang/include/clang/Driver/SanitizerArgs.h
index 07070ec4fc065..47ef175302679 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -103,6 +103,9 @@ class SanitizerArgs {
   bool needsCfiDiagRt() const;
   bool needsStatsRt() const { return Stats; }
   bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
+  bool needsNsanRt() const {
+return Sanitizers.has(SanitizerKind::NumericalStability);
+  }
 
   bool hasMemTag() const {
 return hasMemtagHeap() || hasMemtagStack() || hasMemtagGlobals();
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index b047279912f6b..a88bb2af59fee 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -476,6 +476,10 @@ llvm::Function 
*CodeGenModule::CreateGlobalInitOrCleanUpFunction(
   !isInNoSanitizeList(SanitizerKind::Thread, Fn, Loc))
 Fn->addFnAttr(llvm::Attribute::SanitizeThread);
 
+  if (getLangOpts().Sanitize.has(SanitizerKind::NumericalStability) &&
+  !isInNoSanitizeList(SanitizerKind::NumericalStability, Fn, Loc))
+Fn->addFnAttr(llvm::Attribute::SanitizeNumericalStability);
+
   if (getLangOpts().Sanitize.has(SanitizerKind::Memory) &&
   !isInNoSanitizeList(SanitizerKind::Memory, Fn, Loc))
 Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index f84b3b08220fd..cea0d84c64bc4 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -818,6 +818,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType 
RetTy,
   Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
 if (SanOpts.has(SanitizerKind::Thread))
   Fn->addFnAttr(llvm::Attribute::SanitizeThread);
+if (SanOpts.has(SanitizerKind::NumericalStability))
+  Fn->addFnAttr(llvm::Attribute::SanitizeNumericalStability);
 if (SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))
   Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
   }
diff --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 273f215ca94a8..86825a6ccf7a1 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -41,7 +41,8 @@ static const SanitizerMask NotAllowedWithExecuteOnly =
 SanitizerKind::Function | SanitizerKind::KCFI;
 static const SanitizerMask NeedsUnwindTables =
 SanitizerKind::Address | SanitizerKind::HWAddress | SanitizerKind::Thread |
-SanitizerKind::Memory | SanitizerKind::DataFlow;
+SanitizerKind::Memory | SanitizerKind::DataFlow |
+   

[clang] [Driver] Add winsysroot alias to the GNU driver (PR #94731)

2024-06-10 Thread via cfe-commits

https://github.com/Andarwinux updated 
https://github.com/llvm/llvm-project/pull/94731

>From 3545f2690f5efdb0a5c2d54824287d779ec9be58 Mon Sep 17 00:00:00 2001
From: Andarwinux <144242044+andarwi...@users.noreply.github.com>
Date: Fri, 7 Jun 2024 07:07:40 +
Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver

fixes #91216
---
 clang/include/clang/Driver/Options.td | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d44faa55c456f..1cce7a5146dd8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8569,6 +8569,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">,
 Alias<_SLASH_winsdkdir>;
 def : Separate<["-"], "Xmicrosoft-windows-sdk-version">,
 Alias<_SLASH_winsdkversion>;
+def : Separate<["-"], "Xmicrosoft-windows-sys-root">,
+Alias<_SLASH_winsysroot>;
 
 // Ignored:
 

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


[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-10 Thread Yingwei Zheng via cfe-commits


@@ -86,8 +86,14 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   // and other features (ex. mirco architecture feature) from mcpu
   if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
 StringRef CPU = A->getValue();
-if (CPU == "native")
+if (CPU == "native") {
   CPU = llvm::sys::getHostCPUName();
+  llvm::StringMap HostFeatures;
+  if (llvm::sys::getHostCPUFeatures(HostFeatures))

dtcxzyw wrote:

I think hwprobe is more reliable than cpu name because some RV cpus are not 
recognized by LLVM (e.g., T-head's cores). However, cpu name is still useful 
even if `getHostCPUFeatures` returns true because it may provide scheduling 
model.


https://github.com/llvm/llvm-project/pull/94352
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-06-10 Thread Pengcheng Wang via cfe-commits


@@ -86,8 +86,14 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   // and other features (ex. mirco architecture feature) from mcpu
   if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
 StringRef CPU = A->getValue();
-if (CPU == "native")
+if (CPU == "native") {
   CPU = llvm::sys::getHostCPUName();
+  llvm::StringMap HostFeatures;
+  if (llvm::sys::getHostCPUFeatures(HostFeatures))

wangpc-pp wrote:

Open discussion here: `CPU` may fail and return `generic`. Should we failback 
to use `getHostCPUFeatures` if `getHostCPUName` fails? Or we should use 
`getHostCPUFeatures` all the time?

https://github.com/llvm/llvm-project/pull/94352
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-10 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/94981

>From 68791782b7a1a0eafa98950f6e03aa1585be5223 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 20 May 2024 01:15:03 -0300
Subject: [PATCH] [clang] Implement CWG2398 provisional TTP matching to class
 templates

This extends default argument deduction to cover class templates as
well, and also applies outside of partial ordering, adding to the
provisional wording introduced in 
https://github.com/llvm/llvm-project/pull/89807.

This solves some ambuguity introduced in P0522 regarding how
template template parameters are partially ordered, and should reduce
the negative impact of enabling `-frelaxed-template-template-args`
by default.

Given the following example:
```C++
template  struct A;
template  struct B;

template  class TT1, class T5> struct B>;   // #1
template   struct B>; // #2

template struct B>;
```
Prior to P0522, `#2` was picked. Afterwards, this became ambiguous.
This patch restores the pre-P0522 behavior, `#2` is picked again.

As the consequences are not restricted to partial ordering,
the following code becomes valid:
```C++
template struct A {};
A v;
template class TT> void f(TT);

// OK: TT picks 'float' as the default argument for the second parameter.
void g() { f(v); }
```

Also, since 'f' deduced from `A` is different from 'f'
deduced from `A`, this implements an additional mangling
rule.

---

Since this changes provisional implementation of CWG2398 which has
not been released yet, and already contains a changelog entry,
we don't provide a changelog entry here.
---
 clang-tools-extra/clangd/DumpAST.cpp  |   1 +
 .../clangd/SemanticHighlighting.cpp   |   1 +
 clang/include/clang/AST/ASTContext.h  |   8 +-
 clang/include/clang/AST/ASTImporter.h |   5 +
 clang/include/clang/AST/DependenceFlags.h |   5 +
 clang/include/clang/AST/PropertiesBase.td |  17 ++
 clang/include/clang/AST/TemplateName.h|  59 ++-
 clang/include/clang/Sema/Sema.h   |  10 +-
 clang/lib/AST/ASTContext.cpp  | 129 --
 clang/lib/AST/ASTDiagnostic.cpp   |  24 +--
 clang/lib/AST/ASTImporter.cpp |  92 +-
 clang/lib/AST/ASTStructuralEquivalence.cpp|   3 +
 clang/lib/AST/ItaniumMangle.cpp   |  11 ++
 clang/lib/AST/ODRHash.cpp |   1 +
 clang/lib/AST/TemplateName.cpp| 157 ++
 clang/lib/AST/TextNodeDumper.cpp  |  12 ++
 clang/lib/AST/Type.cpp|   3 +-
 clang/lib/Sema/SemaTemplate.cpp   |  63 +--
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 128 --
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  24 +--
 .../CXX/temp/temp.decls/temp.alias/p2.cpp |   5 +-
 clang/test/CodeGenCXX/mangle-cwg2398.cpp  |  11 ++
 clang/test/SemaTemplate/cwg2398.cpp   |  60 +--
 clang/tools/libclang/CIndex.cpp   |   3 +
 clang/unittests/AST/ASTImporterTest.cpp   |  17 ++
 25 files changed, 594 insertions(+), 255 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/mangle-cwg2398.cpp

diff --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 9a525efb938e8..e605f82e91fe4 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -187,6 +187,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   TEMPLATE_KIND(SubstTemplateTemplateParm);
   TEMPLATE_KIND(SubstTemplateTemplateParmPack);
   TEMPLATE_KIND(UsingTemplate);
+  TEMPLATE_KIND(DeducedTemplate);
 #undef TEMPLATE_KIND
 }
 llvm_unreachable("Unhandled NameKind enum");
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index a366f1331c2d3..e6d16af2495fe 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -1120,6 +1120,7 @@ class CollectExtraHighlightings
 case TemplateName::SubstTemplateTemplateParm:
 case TemplateName::SubstTemplateTemplateParmPack:
 case TemplateName::UsingTemplate:
+case TemplateName::DeducedTemplate:
   // Names that could be resolved to a TemplateDecl are handled elsewhere.
   break;
 }
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 8bce4812f0d48..8818314de9364 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -262,6 +262,8 @@ class ASTContext : public RefCountedBase {
   mutable llvm::ContextualFoldingSet
 SubstTemplateTemplateParmPacks;
+  mutable llvm::ContextualFoldingSet
+  DeducedTemplates;
 
   mutable llvm::ContextualFoldingSet
   ArrayParameterTypes;
@@ -2247,6 +2249,9 @@ class ASTContext : public RefCountedBase {
 unsigned Index,

[clang] [llvm] [RISCV] Add riscv_atomic.h and Zawrs/Zalrsc builtins (PR #94578)

2024-06-10 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

If we are talking about the necessariness of adding these intrinsics, please 
refer to the ARM implementations in DPDK 
(https://github.com/DPDK/dpdk/blob/76cef1af8bdaeaf67a5c4ca5df3f221df994dc46/lib/eal/arm/include/rte_pause_64.h).We
 want to use 

https://github.com/llvm/llvm-project/pull/94578
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)

2024-06-10 Thread NAKAMURA Takumi via cfe-commits


@@ -484,10 +484,31 @@ MC/DC Instrumentation
 -
 
 When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the
-clang option ``-fcoverage-mcdc``, users are limited to at most **six** 
leaf-level
-conditions in a boolean expression.  A warning will be generated for boolean
-expressions that contain more than six, and they will not be instrumented for
-MC/DC.
+clang option ``-fcoverage-mcdc``, there are two hard limits.
+
+The maximum number of terms is limited to 32767. It would be practical for
+handwritten expressions. To be more retrictive in order to enfoce conding 
rules,

chapuni wrote:

Done (and revised a little). Thanks!

https://github.com/llvm/llvm-project/pull/82448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)

2024-06-10 Thread Yingwei Zheng via cfe-commits


@@ -381,3 +381,21 @@ def XIANGSHAN_NANHU : 
RISCVProcessorModel<"xiangshan-nanhu",
 TuneZExtHFusion,
 TuneZExtWFusion,
 TuneShiftedZExtWFusion]>;
+
+def SPACEMIT_X60 : RISCVProcessorModel<"spacemit-x60",
+   NoSchedModel,
+   !listconcat(RVA22S64Features,
+   [FeatureStdExtV,
+FeatureStdExtSscofpmf,
+FeatureStdExtSstc,
+FeatureStdExtSvnapot,
+FeatureStdExtZbc,
+FeatureStdExtZbkc,
+FeatureStdExtZfh,
+FeatureStdExtZicond,
+FeatureStdExtZmmul,
+FeatureStdExtZvfh,
+FeatureStdExtZvfhmin,
+FeatureStdExtZvkt,
+FeatureStdExtZvl256b]),
+   [TuneDLenFactor2]>;

dtcxzyw wrote:

Does X60 support any macro-fusion?


https://github.com/llvm/llvm-project/pull/94564
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)

2024-06-10 Thread Yingwei Zheng via cfe-commits


@@ -381,3 +381,21 @@ def XIANGSHAN_NANHU : 
RISCVProcessorModel<"xiangshan-nanhu",
 TuneZExtHFusion,
 TuneZExtWFusion,
 TuneShiftedZExtWFusion]>;
+
+def SPACEMIT_X60 : RISCVProcessorModel<"spacemit-x60",
+   NoSchedModel,
+   !listconcat(RVA22S64Features,
+   [FeatureStdExtV,
+FeatureStdExtSscofpmf,
+FeatureStdExtSstc,
+FeatureStdExtSvnapot,
+FeatureStdExtZbc,
+FeatureStdExtZbkc,
+FeatureStdExtZfh,
+FeatureStdExtZicond,
+FeatureStdExtZmmul,
+FeatureStdExtZvfh,
+FeatureStdExtZvfhmin,

dtcxzyw wrote:

```suggestion
```
Implied by zvfh.


https://github.com/llvm/llvm-project/pull/94564
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] fix false positives for the functions with the same name as standard library functions in misc-include-cleaner (PR #94923)

2024-06-10 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/94923

>From e467b03cc120eedc580c185232f000e0d8aa0cc7 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Mon, 10 Jun 2024 09:04:27 +0800
Subject: [PATCH 1/2] [clang-tidy] fix false positives for the functions with
 the same name as standard library functions in misc-include-cleaner

Fixes: #93335
---
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 
 .../include-cleaner/lib/LocateSymbol.cpp  |  8 ++--
 .../include-cleaner/unittests/FindHeadersTest.cpp | 11 +++
 .../test/clang-tidy/checkers/misc/include-cleaner.cpp |  2 ++
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 3f0d25ec8c752..8c78d872b9a1a 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -286,6 +286,10 @@ Changes in existing checks
   Additionally, the option `UseHeaderFileExtensions` is removed, so that the
   check uses the `HeaderFileExtensions` option unconditionally.
 
+- Improved :doc:`misc-include-cleaner
+  ` check by avoiding false positives 
for
+  the functions with the same name as standard library functions.
+
 - Improved :doc:`misc-unused-using-decls
   ` check by replacing the local
   option `HeaderFileExtensions` by the global option of the same name.
diff --git a/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp 
b/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp
index 78e783a62eb27..9148d36a5038f 100644
--- a/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp
+++ b/clang-tools-extra/include-cleaner/lib/LocateSymbol.cpp
@@ -14,6 +14,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -40,8 +41,11 @@ Hints declHints(const Decl *D) {
 std::vector> locateDecl(const Decl &D) {
   std::vector> Result;
   // FIXME: Should we also provide physical locations?
-  if (auto SS = tooling::stdlib::Recognizer()(&D))
-return {{*SS, Hints::CompleteSymbol}};
+  if (auto SS = tooling::stdlib::Recognizer()(&D)) {
+Result.push_back({*SS, Hints::CompleteSymbol});
+if (!D.hasBody())
+  return Result;
+  }
   // FIXME: Signal foreign decls, e.g. a forward declaration not owned by a
   // library. Some useful signals could be derived by checking the DeclContext.
   // Most incidental forward decls look like:
diff --git a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
index 07302142a13e3..fdcbf25fd628c 100644
--- a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -628,6 +628,17 @@ TEST_F(HeadersForSymbolTest, StandardHeaders) {
tooling::stdlib::Header::named("")));
 }
 
+TEST_F(HeadersForSymbolTest, NonStandardHeaders) {
+  Inputs.Code = "void assert() {}";
+  buildAST();
+  EXPECT_THAT(
+  headersFor("assert"),
+  // Respect the ordering from the stdlib mapping.
+  UnorderedElementsAre(physicalHeader("input.mm"),
+   tooling::stdlib::Header::named(""),
+   tooling::stdlib::Header::named("")));
+}
+
 TEST_F(HeadersForSymbolTest, ExporterNoNameMatch) {
   Inputs.Code = R"cpp(
 #include "exporter/foo.h"
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
index e10ac3f46e2e9..b1e001834db5a 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
@@ -15,3 +15,5 @@ std::string HelloString;
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" 
is directly included [misc-include-cleaner]
 int FooBarResult = foobar();
 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is 
directly included [misc-include-cleaner]
+
+void log2() {}

>From d23acd26a21d850862189f35dca641cc76ae1df0 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Tue, 11 Jun 2024 11:24:40 +0800
Subject: [PATCH 2/2] Update
 clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp

---
 .../test/clang-tidy/checkers/misc/include-cleaner.cpp   | 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
index b1e001834db5a..7e77369b768bc 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
@@ -16,4 +16,6 @@ std::string HelloString;
 int FooBarResult = foobar();
 // CHECK-MESSAGES: :[[@LINE-1]]:20: 

[clang-tools-extra] [clang-tidy] fix false positives for the functions with the same name as standard library functions in misc-include-cleaner (PR #94923)

2024-06-10 Thread Congcong Cai via cfe-commits


@@ -15,3 +15,5 @@ std::string HelloString;
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" 
is directly included [misc-include-cleaner]
 int FooBarResult = foobar();
 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is 
directly included [misc-include-cleaner]
+
+void log2() {}

HerrCai0907 wrote:

```suggestion
namespace gh93335 {
void log2() {}
}
```

https://github.com/llvm/llvm-project/pull/94923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() (PR #90043)

2024-06-10 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 requested changes to this pull request.

`at` and `operator[]` in `std::map` have different meanings. `operator[]` will 
insert value if key does not exist but `at` won't. Please limit this check only 
for index containers instead of key-value containers.

https://github.com/llvm/llvm-project/pull/90043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add riscv_atomic.h and Zawrs/Zalrsc builtins (PR #94578)

2024-06-10 Thread Jessica Clarke via cfe-commits

jrtc27 wrote:

> > lr/sc builtins are extremely fragile: there's no reasonable way for the 
> > compiler to guarantee that the sc is placed in such a way that it will 
> > eventually succeed.
> 
> I think the user should have enough knowledges about lr/sc to make the logic 
> reasonable.

It's not about knowledge, it's that they are basically impossible for the 
compiler to actually guarantee they'll work at all.

> If we don't provide these intrinsics, the user who wants to implement custom 
> locks will use inline assemly instead.

Good, because other than using C11-style atomics (or Itanium-style __sync 
builtins), that's the right thing to do.

https://github.com/llvm/llvm-project/pull/94578
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add riscv_atomic.h and Zawrs/Zalrsc builtins (PR #94578)

2024-06-10 Thread Pengcheng Wang via cfe-commits

wangpc-pp wrote:

> lr/sc builtins are extremely fragile: there's no reasonable way for the 
> compiler to guarantee that the sc is placed in such a way that it will 
> eventually succeed.

I think the user should have enough knowledges about lr/sc to make the logic 
reasonable. If we don't provide these intrinsics, the user who wants to 
implement custom locks will use inline assemly instead.

>  (The equivalent intrinsics do exist on ARM, but ARM has significantly 
> stronger guarantees here. Even then, it's not completely reliable.)

I don't know much about there intrinsics on ARM, what are the `stronger 
guarantees`?

https://github.com/llvm/llvm-project/pull/94578
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Add option to remove leading blank lines (PR #91221)

2024-06-10 Thread via cfe-commits

https://github.com/sstwcw updated 
https://github.com/llvm/llvm-project/pull/91221

>From 72e15ffb87eff94d51af69c0f804084ab7abe474 Mon Sep 17 00:00:00 2001
From: sstwcw 
Date: Mon, 6 May 2024 14:34:08 +
Subject: [PATCH 1/5] [clang-format] Add option to remove leading blank lines

---
 clang/docs/ClangFormatStyleOptions.rst  | 5 +
 clang/include/clang/Format/Format.h | 5 +
 clang/lib/Format/ContinuationIndenter.cpp   | 3 +++
 clang/lib/Format/Format.cpp | 2 ++
 clang/lib/Format/UnwrappedLineFormatter.cpp | 4 +++-
 clang/unittests/Format/ConfigParseTest.cpp  | 1 +
 clang/unittests/Format/FormatTest.cpp   | 7 +++
 7 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ce9035a2770ee..c81de131f050c 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4406,6 +4406,11 @@ the configuration (without a prefix: ``Auto``).
 **KeepEmptyLinesAtEOF** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
   Keep empty lines (up to ``MaxEmptyLinesToKeep``) at end of file.
 
+.. _KeepEmptyLinesAtStart:
+
+**KeepEmptyLinesAtStart** (``Boolean``) :versionbadge:`clang-format 19` 
:ref:`¶ `
+  Keep empty lines (up to ``MaxEmptyLinesToKeep``) at start of file.
+
 .. _KeepEmptyLinesAtTheStartOfBlocks:
 
 **KeepEmptyLinesAtTheStartOfBlocks** (``Boolean``) :versionbadge:`clang-format 
3.7` :ref:`¶ `
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 8ebdc86b98329..9a7837b1bac2d 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3061,6 +3061,10 @@ struct FormatStyle {
   /// \version 17
   bool KeepEmptyLinesAtEOF;
 
+  /// Keep empty lines (up to ``MaxEmptyLinesToKeep``) at start of file.
+  /// \version 19
+  bool KeepEmptyLinesAtStart;
+
   /// If true, the empty line at the start of blocks is kept.
   /// \code
   ///true:  false:
@@ -4994,6 +4998,7 @@ struct FormatStyle {
JavaScriptQuotes == R.JavaScriptQuotes &&
JavaScriptWrapImports == R.JavaScriptWrapImports &&
KeepEmptyLinesAtEOF == R.KeepEmptyLinesAtEOF &&
+   KeepEmptyLinesAtStart == R.KeepEmptyLinesAtStart &&
KeepEmptyLinesAtTheStartOfBlocks ==
R.KeepEmptyLinesAtTheStartOfBlocks &&
Language == R.Language &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ad0e2c3c620c3..33dca7b08f998 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -208,6 +208,9 @@ RawStringFormatStyleManager::RawStringFormatStyleManager(
   LanguageStyle = PredefinedStyle;
 }
 LanguageStyle->ColumnLimit = CodeStyle.ColumnLimit;
+// This way the first line of the string does not have to follow the code
+// before the string.
+LanguageStyle->KeepEmptyLinesAtStart = true;
 for (StringRef Delimiter : RawStringFormat.Delimiters)
   DelimiterStyle.insert({Delimiter, *LanguageStyle});
 for (StringRef EnclosingFunction : RawStringFormat.EnclosingFunctions)
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index c8d8ec3afbd99..31ffbf46cdd08 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1003,6 +1003,7 @@ template <> struct MappingTraits {
 IO.mapOptional("KeepEmptyLinesAtTheStartOfBlocks",
Style.KeepEmptyLinesAtTheStartOfBlocks);
 IO.mapOptional("KeepEmptyLinesAtEOF", Style.KeepEmptyLinesAtEOF);
+IO.mapOptional("KeepEmptyLinesAtStart", Style.KeepEmptyLinesAtStart);
 IO.mapOptional("LambdaBodyIndentation", Style.LambdaBodyIndentation);
 IO.mapOptional("LineEnding", Style.LineEnding);
 IO.mapOptional("MacroBlockBegin", Style.MacroBlockBegin);
@@ -1513,6 +1514,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
   LLVMStyle.JavaScriptWrapImports = true;
   LLVMStyle.KeepEmptyLinesAtEOF = false;
+  LLVMStyle.KeepEmptyLinesAtStart = true;
   LLVMStyle.KeepEmptyLinesAtTheStartOfBlocks = true;
   LLVMStyle.LambdaBodyIndentation = FormatStyle::LBI_Signature;
   LLVMStyle.Language = Language;
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 4ae54e56331bd..b8485ae2b9197 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1473,8 +1473,10 @@ static auto computeNewlines(const AnnotatedLine &Line,
 Newlines = std::min(Newlines, 1u);
   if (Newlines == 0 && !RootToken.IsFirst)
 Newlines = 1;
-  if (RootToken.IsFirst && !RootToken.HasUnescapedNewline)
+  if (RootToken.IsFirst &&
+  (!Style.KeepEmptyLinesAtStart || !RootToken.HasUnescapedNewline)) {
 Newlines = 0;
+  }
 
   // Remove em

[clang] [clang-format] Add option to remove leading blank lines (PR #91221)

2024-06-10 Thread via cfe-commits

sstwcw wrote:

I was initially going to make removing leading blank lines the default.
Now the line is not needed anymore.  But I forgot to remove it.


https://github.com/llvm/llvm-project/pull/91221
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)

2024-06-10 Thread Shao-Ce SUN via cfe-commits

sunshaoce wrote:

Added:

- Sscofpmf
- Sstc
- Zvkt
- TuneDLenFactor2

Removed:

- Zvl32b
- Zvl64b
- Zvl128b

https://github.com/llvm/llvm-project/pull/94564
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)

2024-06-10 Thread Shao-Ce SUN via cfe-commits

https://github.com/sunshaoce updated 
https://github.com/llvm/llvm-project/pull/94564

>From 363e29385277c049bc91a86e76ff6f6ae70ceaa9 Mon Sep 17 00:00:00 2001
From: Shao-Ce SUN 
Date: Thu, 6 Jun 2024 12:05:33 +0800
Subject: [PATCH 1/6] [RISCV] Add processor definition for Spacemit-K1

---
 clang/test/Driver/riscv-cpus.c| 12 ++
 clang/test/Misc/target-invalid-cpu-note.c |  4 ++--
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 29 +++
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index ff2bd6f7c8ba3..32d7910ab4daa 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -31,6 +31,18 @@
 // MCPU-XIANGSHAN-NANHU-SAME: "-target-feature" "+zks" "-target-feature" 
"+zksed" "-target-feature" "+zksh" "-target-feature" "+svinval"
 // MCPU-XIANGSHAN-NANHU-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=spacemit-k1 | FileCheck 
-check-prefix=MCPU-SPACEMIT-K1 %s
+// MCPU-SPACEMIT-K1: "-nostdsysteminc" "-target-cpu" "spacemit-k1"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+c" "-target-feature" "+v" 
"-target-feature" "+zicond" "-target-feature" "+zicsr"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zifencei" "-target-feature" 
"+zmmul" "-target-feature" "+zfh"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zfhmin" "-target-feature" "+zba" 
"-target-feature" "+zbb" "-target-feature" "+zbc"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zbkb" "-target-feature" "+zbkc" 
"-target-feature" "+zbs" "-target-feature" "+zve32f"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zve32x" "-target-feature" 
"+zve64d" "-target-feature" "+zve64f" "-target-feature" "+zve64x"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zvfh" "-target-feature" 
"+zvfhmin"
+// MCPU-SPACEMIT-K1-SAME: "-target-feature" "+zvl128b" "-target-feature" 
"+zvl256b" "-target-feature" "+zvl32b" "-target-feature" "+zvl64b"
+// MCPU-SPACEMIT-K1-SAME: "-target-abi" "lp64d"
+
 // We cannot check much for -mcpu=native, but it should be replaced by a valid 
CPU string.
 // RUN: %clang --target=riscv64 -### -c %s -mcpu=native 2> %t.err || true
 // RUN: FileCheck --input-file=%t.err -check-prefix=MCPU-NATIVE %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 6558fd753d1d1..04e92360fe665 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, veyron-v1, xiangshan-nanhu{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, 
sifive-u54, sifive-u74, sifive-x280, spacemit-k1, veyron-v1, 
xiangshan-nanhu{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
@@ -93,4 +93,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, 
sifive-s76, sifive-u54, sifive-u74, sifive-x280, veyron-v1, xiangshan-nanhu, 
generic, rocket, sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, 
sifive-s76, sifive-u54, sifive-u74, sifive-x280, spacemit-k1, veyron-v1, 
xiangshan-nanhu, generic, rocket, sifive-7-series{{$}}
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 6ebf9f1eb0452..08602e9d06cc9 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -381,3 +381,32 @@ def XIANGSHAN_NANHU : 
RISCVProcessorModel<"xiangshan-nanhu",
 TuneZExtHFusion,
 TuneZExtWFusion,
 TuneShiftedZExtWFusion]>;
+
+def SPACEMIT_K1 : RISCVProcessorModel<"spacemit-k1",
+   NoSchedModel,
+   [Feature64Bit,
+FeatureStdExtI,
+FeatureStdExtM,
+

[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-10 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/94981

>From ea98dec85a9817eb4e35ce97389433e4a5b9676d Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 20 May 2024 01:15:03 -0300
Subject: [PATCH] [clang] Implement CWG2398 provisional TTP matching to class
 templates

This extends default argument deduction to cover class templates as
well, and also applies outside of partial ordering, adding to the
provisional wording introduced in 
https://github.com/llvm/llvm-project/pull/89807.

This solves some ambuguity introduced in P0522 regarding how
template template parameters are partially ordered, and should reduce
the negative impact of enabling `-frelaxed-template-template-args`
by default.

Given the following example:
```C++
template  struct A;
template  struct B;

template  class TT1, class T5> struct B>;   // #1
template   struct B>; // #2

template struct B>;
```
Prior to P0522, `#2` was picked. Afterwards, this became ambiguous.
This patch restores the pre-P0522 behavior, `#2` is picked again.

As the consequences are not restricted to partial ordering,
the following code becomes valid:
```C++
template struct A {};
A v;
template class TT> void f(TT);

// OK: TT picks 'float' as the default argument for the second parameter.
void g() { f(v); }
```

Also, since 'f' deduced from `A` is different from 'f'
deduced from `A`, this implements an additional mangling
rule.

---

Since this changes provisional implementation of CWG2398 which has
not been released yet, and already contains a changelog entry,
we don't provide a changelog entry here.
---
 clang-tools-extra/clangd/DumpAST.cpp  |   1 +
 .../clangd/SemanticHighlighting.cpp   |   1 +
 clang/include/clang/AST/ASTContext.h  |   8 +-
 clang/include/clang/AST/ASTImporter.h |   5 +
 clang/include/clang/AST/DependenceFlags.h |   5 +
 clang/include/clang/AST/PropertiesBase.td |  17 ++
 clang/include/clang/AST/TemplateName.h|  59 ++-
 clang/include/clang/Sema/Sema.h   |  10 +-
 clang/lib/AST/ASTContext.cpp  | 129 --
 clang/lib/AST/ASTDiagnostic.cpp   |  24 +--
 clang/lib/AST/ASTImporter.cpp |  92 +-
 clang/lib/AST/ASTStructuralEquivalence.cpp|   3 +
 clang/lib/AST/ItaniumMangle.cpp   |  11 ++
 clang/lib/AST/ODRHash.cpp |   1 +
 clang/lib/AST/TemplateName.cpp| 157 ++
 clang/lib/AST/TextNodeDumper.cpp  |  12 ++
 clang/lib/AST/Type.cpp|   3 +-
 clang/lib/Sema/SemaTemplate.cpp   |  63 +--
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 134 ---
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  24 +--
 .../CXX/temp/temp.decls/temp.alias/p2.cpp |   5 +-
 clang/test/CodeGenCXX/mangle-cwg2398.cpp  |  11 ++
 clang/test/SemaTemplate/cwg2398.cpp   |  60 +--
 clang/tools/libclang/CIndex.cpp   |   3 +
 clang/unittests/AST/ASTImporterTest.cpp   |  17 ++
 25 files changed, 600 insertions(+), 255 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/mangle-cwg2398.cpp

diff --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 9a525efb938e8..e605f82e91fe4 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -187,6 +187,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   TEMPLATE_KIND(SubstTemplateTemplateParm);
   TEMPLATE_KIND(SubstTemplateTemplateParmPack);
   TEMPLATE_KIND(UsingTemplate);
+  TEMPLATE_KIND(DeducedTemplate);
 #undef TEMPLATE_KIND
 }
 llvm_unreachable("Unhandled NameKind enum");
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index a366f1331c2d3..e6d16af2495fe 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -1120,6 +1120,7 @@ class CollectExtraHighlightings
 case TemplateName::SubstTemplateTemplateParm:
 case TemplateName::SubstTemplateTemplateParmPack:
 case TemplateName::UsingTemplate:
+case TemplateName::DeducedTemplate:
   // Names that could be resolved to a TemplateDecl are handled elsewhere.
   break;
 }
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 8bce4812f0d48..8818314de9364 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -262,6 +262,8 @@ class ASTContext : public RefCountedBase {
   mutable llvm::ContextualFoldingSet
 SubstTemplateTemplateParmPacks;
+  mutable llvm::ContextualFoldingSet
+  DeducedTemplates;
 
   mutable llvm::ContextualFoldingSet
   ArrayParameterTypes;
@@ -2247,6 +2249,9 @@ class ASTContext : public RefCountedBase {
 unsigned Index,
   

[clang] [clang] Remove a redundant check in Mangle. NFC (PR #95071)

2024-06-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Pavel Samolysov (samolisov)


Changes

This addresses a review comment for PR #94987 Because that PR is a big 
automatic change, this change was moved in a separate one.

---
Full diff: https://github.com/llvm/llvm-project/pull/95071.diff


1 Files Affected:

- (modified) clang/lib/AST/Mangle.cpp (+2-3) 


``diff
diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index 4af4d7c00c5cb..4fbf0e3b42dbc 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -301,9 +301,8 @@ void MangleContext::mangleBlock(const DeclContext *DC, 
const BlockDecl *BD,
   } else {
 assert((isa(DC) || isa(DC)) &&
"expected a NamedDecl or BlockDecl");
-if (isa(DC))
-  for (; isa_and_nonnull(DC); DC = DC->getParent())
-(void) getBlockId(cast(DC), true);
+for (; isa_and_nonnull(DC); DC = DC->getParent())
+  (void)getBlockId(cast(DC), true);
 assert((isa(DC) || isa(DC)) &&
"expected a TranslationUnitDecl or a NamedDecl");
 if (const auto *CD = dyn_cast(DC))

``




https://github.com/llvm/llvm-project/pull/95071
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Remove a redundant check in Mangle. NFC (PR #95071)

2024-06-10 Thread Pavel Samolysov via cfe-commits

https://github.com/samolisov created 
https://github.com/llvm/llvm-project/pull/95071

This addresses a review comment for PR #94987 Because that PR is a big 
automatic change, this change was moved in a separate one.

>From c0e810f0a8d17ce222ad0775874539e09a90eb33 Mon Sep 17 00:00:00 2001
From: Pavel Samolysov 
Date: Mon, 10 Jun 2024 20:29:16 +0300
Subject: [PATCH] [clang] Remove a redundant check in Mangle. NFC

This addresses a review comment for PR #94987 Because that PR is a big
automatic change, this change was moved in a separate one.
---
 clang/lib/AST/Mangle.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index 4af4d7c00c5cb..4fbf0e3b42dbc 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -301,9 +301,8 @@ void MangleContext::mangleBlock(const DeclContext *DC, 
const BlockDecl *BD,
   } else {
 assert((isa(DC) || isa(DC)) &&
"expected a NamedDecl or BlockDecl");
-if (isa(DC))
-  for (; isa_and_nonnull(DC); DC = DC->getParent())
-(void) getBlockId(cast(DC), true);
+for (; isa_and_nonnull(DC); DC = DC->getParent())
+  (void)getBlockId(cast(DC), true);
 assert((isa(DC) || isa(DC)) &&
"expected a TranslationUnitDecl or a NamedDecl");
 if (const auto *CD = dyn_cast(DC))

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


[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)

2024-06-10 Thread Shao-Ce SUN via cfe-commits


@@ -381,3 +381,20 @@ def XIANGSHAN_NANHU : 
RISCVProcessorModel<"xiangshan-nanhu",
 TuneZExtHFusion,
 TuneZExtWFusion,
 TuneShiftedZExtWFusion]>;
+
+def SPACEMIT_X60 : RISCVProcessorModel<"spacemit-x60",
+   NoSchedModel,
+   !listconcat(RVA22S64Features,
+   [FeatureStdExtV,
+FeatureStdExtSvnapot,
+FeatureStdExtZbc,
+FeatureStdExtZbkc,
+FeatureStdExtZfh,
+FeatureStdExtZicond,

sunshaoce wrote:

Updated the description.

https://github.com/llvm/llvm-project/pull/94564
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Make M imply Zmmul (PR #95070)

2024-06-10 Thread Craig Topper via cfe-commits

topperc wrote:

We intentionally didn't do this because it makes LLVM not work with binutils 
that doesn't know about Zmmul. Maybe enough time has  passed that it is no 
longer an issue?

https://github.com/llvm/llvm-project/pull/95070
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Replace X && isa(X) with isa_and_nonnull(X). NFC (PR #94987)

2024-06-10 Thread Pavel Samolysov via cfe-commits

https://github.com/samolisov closed 
https://github.com/llvm/llvm-project/pull/94987
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 69e9e77 - [clang] Replace X && isa(X) with isa_and_nonnull(X). NFC (#94987)

2024-06-10 Thread via cfe-commits

Author: Pavel Samolysov
Date: 2024-06-11T05:30:50+03:00
New Revision: 69e9e779b783bb34a3c1f73c93ca63ee6b89ab09

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

LOG: [clang] Replace X && isa(X) with isa_and_nonnull(X). NFC (#94987)

This addresses a clang-tidy suggestion.

Added: 


Modified: 
clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Sema/SemaObjC.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/Mangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/ParentMap.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Index/IndexBody.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplate.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h 
b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
index 7bdb9052e57e7..e99c5b2466334 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
@@ -330,9 +330,9 @@ class CapabilityExpr {
 
   bool shouldIgnore() const { return sexpr() == nullptr; }
 
-  bool isInvalid() const { return sexpr() && isa(sexpr()); }
+  bool isInvalid() const { return isa_and_nonnull(sexpr()); }
 
-  bool isUniversal() const { return sexpr() && isa(sexpr()); }
+  bool isUniversal() const { return isa_and_nonnull(sexpr()); }
 };
 
 // Translate clang::Expr to til::SExpr.

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index c0850a8fa9f7f..9b1628d2d86f9 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1360,7 +1360,7 @@ class Preprocessor {
 
 MacroState &S = CurSubmoduleState->Macros[II];
 auto *MD = S.getLatest();
-while (MD && isa(MD))
+while (isa_and_nonnull(MD))
   MD = MD->getPrevious();
 return MacroDefinition(dyn_cast_or_null(MD),
S.getActiveModuleMacros(*this, II),

diff  --git a/clang/include/clang/Sema/SemaObjC.h 
b/clang/include/clang/Sema/SemaObjC.h
index 91430797e5ed8..bb8887691ce5d 100644
--- a/clang/include/clang/Sema/SemaObjC.h
+++ b/clang/include/clang/Sema/SemaObjC.h
@@ -383,7 +383,7 @@ class SemaObjC : public SemaBase {
   void AddAnyMethodToGlobalPool(Decl *D);
 
   void ActOnStartOfObjCMethodDef(Scope *S, Decl *D);
-  bool isObjCMethodDecl(Decl *D) { return D && isa(D); }
+  bool isObjCMethodDecl(Decl *D) { return isa_and_nonnull(D); }
 
   /// CheckImplementationIvars - This routine checks if the instance variables
   /// listed in the implelementation match those listed in the interface.

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
index 151d3e57c1cb8..59805d01be5db 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -781,7 +781,7 @@ class SymbolicRegion : public SubRegion {
   : SubRegion(sreg, SymbolicRegionKind), sym(s) {
 // Because pointer arithmetic is represented by ElementRegion layers,
 // the base symbol here should not contain any arithmetic.
-assert(s && isa(s));
+assert(isa_and_nonnull(s));
 assert(s->getType()->isAnyPointerType() ||
s->getType()->isReferenceType() ||
s->getType()->isBlockPointerType());

diff  --git a/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp 
b/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
index 1e6354f71e294..7390ea17c8a4b 100644
--- a/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
+++ b/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
@@ -371,7 +371,7 @@ class UnbridgedCastRewriter : public 
RecursiveASTVisitor{
   Stmt *parent = E;
   do {
 parent = StmtMap->getParentIgnoreParenImpCasts(parent);
-  } while (parent && isa(parent));
+  } while (isa_and_nonnull(parent));
 
   if (ReturnStmt *retS = dyn_cast_or_null(parent)) {
 std::string note = "remove the cast and change return type of function 
"

diff  --git a/clang/lib/AST/ASTIm

[clang] [llvm] [RISCV] Add processor definition for SpacemiT-X60 (PR #94564)

2024-06-10 Thread Shao-Ce SUN via cfe-commits

https://github.com/sunshaoce edited 
https://github.com/llvm/llvm-project/pull/94564
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Add winsysroot alias to the GNU driver (PR #94731)

2024-06-10 Thread via cfe-commits

https://github.com/Andarwinux updated 
https://github.com/llvm/llvm-project/pull/94731

>From ba93be30a8b402a9f93b0eb5266baf7f0f4cd2c9 Mon Sep 17 00:00:00 2001
From: Andarwinux <144242044+andarwi...@users.noreply.github.com>
Date: Fri, 7 Jun 2024 07:07:40 +
Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver

fixes #91216
---
 clang/include/clang/Driver/Options.td | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d44faa55c456f..1cce7a5146dd8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8569,6 +8569,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">,
 Alias<_SLASH_winsdkdir>;
 def : Separate<["-"], "Xmicrosoft-windows-sdk-version">,
 Alias<_SLASH_winsdkversion>;
+def : Separate<["-"], "Xmicrosoft-windows-sys-root">,
+Alias<_SLASH_winsysroot>;
 
 // Ignored:
 

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


[clang] [CLANG][NFC] Modify test cases to suit assigned default sysroot path (PR #77075)

2024-06-10 Thread via cfe-commits

https://github.com/Yunzezhu94 updated 
https://github.com/llvm/llvm-project/pull/77075

>From e04fa94a98b71e729885b0544add053127180f7d Mon Sep 17 00:00:00 2001
From: Yunze Zhu 
Date: Fri, 5 Jan 2024 17:11:26 +0800
Subject: [PATCH] [CLANG][NFC] Modify test cases to suit assigned default
 sysroot path

When using cmake with option -DDEFAULT_SYSROOT, a default sysroot path is 
assigned.
However, some test cases use a relative path to indicate sysroot path,
but the path goes wrong with default sysroot path assigned.
This patch modified test cases to make them use correct sysroot path.
---
 clang/test/Driver/baremetal.cpp | 10 +-
 clang/test/Driver/csky-toolchain.c  |  4 ++--
 clang/test/Driver/freebsd-include-paths.c   |  4 ++--
 clang/test/Driver/haiku.c   |  2 +-
 clang/test/Driver/hexagon-toolchain-linux.c |  2 ++
 clang/test/Driver/riscv32-toolchain-extra.c |  1 +
 clang/test/Driver/riscv64-toolchain-extra.c |  1 +
 clang/test/Driver/solaris-ld.c  |  2 +-
 8 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index c04f4506a0994..03d0fbcc76fd1 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -157,7 +157,7 @@
 // RUN: %clang -### %s --target=aarch64_be-none-elf -mlittle-endian 
--sysroot=%S/Inputs/baremetal_arm 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-AARCH64LE %s
 
-// RUN: %clang -no-canonical-prefixes %s -### --target=aarch64-none-elf 2>&1 \
+// RUN: %clang -no-canonical-prefixes %s -### --sysroot="" 
--target=aarch64-none-elf 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-AARCH64-NO-HOST-INC %s
 // Verify that the bare metal driver does not include any host system paths:
 // CHECK-AARCH64-NO-HOST-INC: InstalledDir: [[INSTALLEDDIR:.+]]
@@ -385,7 +385,7 @@
 // CHECK-RV32IMAFC-SAME: 
"-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f{{[/\\]+}}lib"
 // CHECK-RV32IMAFC-SAME: 
"-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f"
 
-// RUN: %clang -no-canonical-prefixes %s -### --target=powerpc-unknown-eabi 
2>&1 \
+// RUN: %clang -no-canonical-prefixes %s -### --sysroot="" 
--target=powerpc-unknown-eabi 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PPCEABI %s
 // CHECK-PPCEABI: InstalledDir: [[INSTALLEDDIR:.+]]
 // CHECK-PPCEABI: "-nostdsysteminc"
@@ -398,7 +398,7 @@
 // CHECK-PPCEABI-SAME: "-L[[RESOURCE]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-PPCEABI-SAME: "-lc" "-lm" "-lclang_rt.builtins-powerpc" "-o" "a.out"
 
-// RUN: %clang -no-canonical-prefixes %s -### --target=powerpc64-unknown-eabi 
2>&1 \
+// RUN: %clang -no-canonical-prefixes %s -### --sysroot="" 
--target=powerpc64-unknown-eabi 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PPC64EABI %s
 // CHECK-PPC64EABI: InstalledDir: [[INSTALLEDDIR:.+]]
 // CHECK-PPC64EABI: "-nostdsysteminc"
@@ -411,7 +411,7 @@
 // CHECK-PPC64EABI-SAME: "-L[[RESOURCE]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-PPC64EABI-SAME: "-lc" "-lm" "-lclang_rt.builtins-powerpc64" "-o" 
"a.out"
 
-// RUN: %clang -no-canonical-prefixes %s -### --target=powerpcle-unknown-eabi 
2>&1 \
+// RUN: %clang -no-canonical-prefixes %s -### --sysroot="" 
--target=powerpcle-unknown-eabi 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PPCLEEABI %s
 // CHECK-PPCLEEABI: InstalledDir: [[INSTALLEDDIR:.+]]
 // CHECK-PPCLEEABI: "-nostdsysteminc"
@@ -424,7 +424,7 @@
 // CHECK-PPCLEEABI-SAME: "-L[[RESOURCE]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-PPCLEEABI-SAME: "-lc" "-lm" "-lclang_rt.builtins-powerpcle" "-o" 
"a.out"
 
-// RUN: %clang -no-canonical-prefixes %s -### 
--target=powerpc64le-unknown-eabi 2>&1 \
+// RUN: %clang -no-canonical-prefixes %s -### --sysroot="" 
--target=powerpc64le-unknown-eabi 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PPC64LEEABI %s
 // CHECK-PPC64LEEABI: InstalledDir: [[INSTALLEDDIR:.+]]
 // CHECK-PPC64LEEABI: "-nostdsysteminc"
diff --git a/clang/test/Driver/csky-toolchain.c 
b/clang/test/Driver/csky-toolchain.c
index 66485464652ac..557feeeb1d1d3 100644
--- a/clang/test/Driver/csky-toolchain.c
+++ b/clang/test/Driver/csky-toolchain.c
@@ -7,7 +7,7 @@
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
 
-// RUN: %clang -### %s -fuse-ld=ld -no-pie --target=csky-unknown-linux-gnu 
--rtlib=platform --unwindlib=platform \
+// RUN: %clang -### %s -fuse-ld=ld -no-pie --target=csky-unknown-linux-gnu 
--rtlib=platform --sysroot="" --unwindlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_csky_linux_sdk  2>&1 | FileCheck 
-check-prefix=C-CSKY-LINUX-MULTI %s
 
 // C-CSKY-LINUX-MULTI: 
"{{.*}}/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/../../..{{/|}}..{{/|}}csky-linux-gnuabiv2/bin{{/|}}ld"
@@ -23,7 +23,7 @@
 // C-CSKY-LINUX-MULTI: 
"-L{{.*}}/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnu

[clang] [llvm] [RISCV] Make M imply Zmmul (PR #95070)

2024-06-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-risc-v

Author: Jianjian Guan (jacquesguan)


Changes

According to the spec, M implies Zmmul.

---
Full diff: https://github.com/llvm/llvm-project/pull/95070.diff


9 Files Affected:

- (modified) clang/lib/Basic/Targets/RISCV.cpp (+1-1) 
- (modified) llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp (+1-1) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+9-11) 
- (modified) llvm/lib/Target/RISCV/RISCVISelLowering.cpp (+3-4) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.cpp (+1-1) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoM.td (+10-10) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoZc.td (+3-3) 
- (modified) llvm/test/CodeGen/RISCV/attributes-module-flag.ll (+2-2) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+11-11) 


``diff
diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index a7ce9dda34bdd..25ae7d64b577e 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -168,7 +168,7 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Twine(getVersionValue(ExtInfo.Major, ExtInfo.Minor)));
   }
 
-  if (ISAInfo->hasExtension("m") || ISAInfo->hasExtension("zmmul"))
+  if (ISAInfo->hasExtension("zmmul"))
 Builder.defineMacro("__riscv_mul");
 
   if (ISAInfo->hasExtension("m")) {
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp 
b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
index dbfcab7233bf8..d788c9e29e72b 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -305,7 +305,7 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget 
&ST)
   getActionDefinitionsBuilder({G_GLOBAL_VALUE, G_JUMP_TABLE, G_CONSTANT_POOL})
   .legalFor({p0});
 
-  if (ST.hasStdExtM() || ST.hasStdExtZmmul()) {
+  if (ST.hasStdExtZmmul()) {
 getActionDefinitionsBuilder(G_MUL)
 .legalFor({s32, sXLen})
 .widenScalarToNextPow2(0)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 9bf06850483d8..a2ef24def2981 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -171,23 +171,21 @@ def NoHasStdExtZicfiss : 
Predicate<"!Subtarget->hasStdExtZicfiss()">;
 
 // Multiply Extensions
 
+def FeatureStdExtZmmul
+: RISCVExtension<"zmmul", 1, 0,
+ "'Zmmul' (Integer Multiplication)">;
+def HasStdExtZmmul : Predicate<"Subtarget->hasStdExtZmmul()">,
+ AssemblerPredicate<(all_of FeatureStdExtZmmul),
+ "'Zmmul' (Integer Multiplication)">;
+
 def FeatureStdExtM
 : RISCVExtension<"m", 2, 0,
- "'M' (Integer Multiplication and Division)">;
+ "'M' (Integer Multiplication and Division)",
+ [FeatureStdExtZmmul]>;
 def HasStdExtM : Predicate<"Subtarget->hasStdExtM()">,
  AssemblerPredicate<(all_of FeatureStdExtM),
  "'M' (Integer Multiplication and Division)">;
 
-def FeatureStdExtZmmul
-: RISCVExtension<"zmmul", 1, 0,
- "'Zmmul' (Integer Multiplication)">;
-
-def HasStdExtMOrZmmul
-: Predicate<"Subtarget->hasStdExtM() || Subtarget->hasStdExtZmmul()">,
-  AssemblerPredicate<(any_of FeatureStdExtM, FeatureStdExtZmmul),
- "'M' (Integer Multiplication and Division) or "
- "'Zmmul' (Integer Multiplication)">;
-
 // Atomic Extensions
 
 def FeatureStdExtA
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 4051279fdbf8e..8924f1a81b114 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -300,7 +300,7 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
 setLibcallName(RTLIB::MULO_I64, nullptr);
   }
 
-  if (!Subtarget.hasStdExtM() && !Subtarget.hasStdExtZmmul()) {
+  if (!Subtarget.hasStdExtZmmul()) {
 setOperationAction({ISD::MUL, ISD::MULHS, ISD::MULHU}, XLenVT, Expand);
 if (RV64LegalI32 && Subtarget.is64Bit())
   setOperationAction(ISD::MUL, MVT::i32, Promote);
@@ -21012,14 +21012,13 @@ bool 
RISCVTargetLowering::shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned)
 bool RISCVTargetLowering::decomposeMulByConstant(LLVMContext &Context, EVT VT,
  SDValue C) const {
   // Check integral scalar types.
-  const bool HasExtMOrZmmul =
-  Subtarget.hasStdExtM() || Subtarget.hasStdExtZmmul();
+  const bool HasZmmul = Subtarget.hasStdExtZmmul();
   if (!VT.isScalarInteger())
 return false;
 
   // Omit the optimization if the sub target has the M extension and the data
   // size exceeds XLen.
-  if (HasExtMOrZmmul && VT.getSizeInBits() > Subtarget.getXLen())
+  if (HasZmmul && VT.getSizeInBits() > Subtarget.getXLen())
 ret

[clang] [llvm] [RISCV] Make M imply Zmmul (PR #95070)

2024-06-10 Thread Jianjian Guan via cfe-commits

https://github.com/jacquesguan created 
https://github.com/llvm/llvm-project/pull/95070

According to the spec, M implies Zmmul.

>From b68778d7b46d3f0fd287c5e215ac0f794244604c Mon Sep 17 00:00:00 2001
From: Jianjian GUAN 
Date: Thu, 6 Jun 2024 14:21:12 +0800
Subject: [PATCH] [RISCV] Make M imply Zmmul

According to the spec, M implies Zmmul.
---
 clang/lib/Basic/Targets/RISCV.cpp |  2 +-
 .../Target/RISCV/GISel/RISCVLegalizerInfo.cpp |  2 +-
 llvm/lib/Target/RISCV/RISCVFeatures.td| 20 -
 llvm/lib/Target/RISCV/RISCVISelLowering.cpp   |  7 +++---
 llvm/lib/Target/RISCV/RISCVInstrInfo.cpp  |  2 +-
 llvm/lib/Target/RISCV/RISCVInstrInfoM.td  | 20 -
 llvm/lib/Target/RISCV/RISCVInstrInfoZc.td |  6 ++---
 .../CodeGen/RISCV/attributes-module-flag.ll   |  4 ++--
 llvm/test/CodeGen/RISCV/attributes.ll | 22 +--
 9 files changed, 41 insertions(+), 44 deletions(-)

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index a7ce9dda34bdd..25ae7d64b577e 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -168,7 +168,7 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Twine(getVersionValue(ExtInfo.Major, ExtInfo.Minor)));
   }
 
-  if (ISAInfo->hasExtension("m") || ISAInfo->hasExtension("zmmul"))
+  if (ISAInfo->hasExtension("zmmul"))
 Builder.defineMacro("__riscv_mul");
 
   if (ISAInfo->hasExtension("m")) {
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp 
b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
index dbfcab7233bf8..d788c9e29e72b 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -305,7 +305,7 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget 
&ST)
   getActionDefinitionsBuilder({G_GLOBAL_VALUE, G_JUMP_TABLE, G_CONSTANT_POOL})
   .legalFor({p0});
 
-  if (ST.hasStdExtM() || ST.hasStdExtZmmul()) {
+  if (ST.hasStdExtZmmul()) {
 getActionDefinitionsBuilder(G_MUL)
 .legalFor({s32, sXLen})
 .widenScalarToNextPow2(0)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 9bf06850483d8..a2ef24def2981 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -171,23 +171,21 @@ def NoHasStdExtZicfiss : 
Predicate<"!Subtarget->hasStdExtZicfiss()">;
 
 // Multiply Extensions
 
+def FeatureStdExtZmmul
+: RISCVExtension<"zmmul", 1, 0,
+ "'Zmmul' (Integer Multiplication)">;
+def HasStdExtZmmul : Predicate<"Subtarget->hasStdExtZmmul()">,
+ AssemblerPredicate<(all_of FeatureStdExtZmmul),
+ "'Zmmul' (Integer Multiplication)">;
+
 def FeatureStdExtM
 : RISCVExtension<"m", 2, 0,
- "'M' (Integer Multiplication and Division)">;
+ "'M' (Integer Multiplication and Division)",
+ [FeatureStdExtZmmul]>;
 def HasStdExtM : Predicate<"Subtarget->hasStdExtM()">,
  AssemblerPredicate<(all_of FeatureStdExtM),
  "'M' (Integer Multiplication and Division)">;
 
-def FeatureStdExtZmmul
-: RISCVExtension<"zmmul", 1, 0,
- "'Zmmul' (Integer Multiplication)">;
-
-def HasStdExtMOrZmmul
-: Predicate<"Subtarget->hasStdExtM() || Subtarget->hasStdExtZmmul()">,
-  AssemblerPredicate<(any_of FeatureStdExtM, FeatureStdExtZmmul),
- "'M' (Integer Multiplication and Division) or "
- "'Zmmul' (Integer Multiplication)">;
-
 // Atomic Extensions
 
 def FeatureStdExtA
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 4051279fdbf8e..8924f1a81b114 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -300,7 +300,7 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
 setLibcallName(RTLIB::MULO_I64, nullptr);
   }
 
-  if (!Subtarget.hasStdExtM() && !Subtarget.hasStdExtZmmul()) {
+  if (!Subtarget.hasStdExtZmmul()) {
 setOperationAction({ISD::MUL, ISD::MULHS, ISD::MULHU}, XLenVT, Expand);
 if (RV64LegalI32 && Subtarget.is64Bit())
   setOperationAction(ISD::MUL, MVT::i32, Promote);
@@ -21012,14 +21012,13 @@ bool 
RISCVTargetLowering::shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned)
 bool RISCVTargetLowering::decomposeMulByConstant(LLVMContext &Context, EVT VT,
  SDValue C) const {
   // Check integral scalar types.
-  const bool HasExtMOrZmmul =
-  Subtarget.hasStdExtM() || Subtarget.hasStdExtZmmul();
+  const bool HasZmmul = Subtarget.hasStdExtZmmul();
   if (!VT.isScalarInteger())
 return false;
 
   // Omit the optimization if the sub target has the M extension and the data
   // size exceeds XLen.
-  if (

[clang] [Serialization] No transitive identifier change (PR #92085)

2024-06-10 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

@jansvoboda11 ping~ I hope we can land the series of the patches in 2 weeks to 
give more baking times for them

https://github.com/llvm/llvm-project/pull/92085
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)

2024-06-10 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl closed 
https://github.com/llvm/llvm-project/pull/94559
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 189d471 - [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (#94559)

2024-06-10 Thread via cfe-commits

Author: Farzon Lotfi
Date: 2024-06-10T20:46:26-04:00
New Revision: 189d4711915f4ce89b373f3cbcfe1f19c73becd9

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

LOG: [clang]  Reland Add tanf16 builtin and support for tan constrained 
intrinsic (#94559)

Relanding this PR now that
https://github.com/llvm/llvm-project/pull/90503 has merged. with `FTAN`
landing in
[TargetLoweringBase.cpp:L1021](https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/TargetLoweringBase.cpp#L1020C23-L1021C63
) There is now a llvm tan intrinsic 32\64\128 Expand case for all llvm
backends.

In LLVM, the `llvm.experimental.constrained.cos` and
`llvm.experimental.constrained.sin` intrinsics are used for performing
cosine and sine calculations with additional constraints on
floating-point operations. This behavior is expected for all
floating-point math intrinsics. This change adds these constraints for
the `tan` intrinsic.

-  `Builtins.td` - replace TanF128 with F16F128MathTemplate
- `CGBuiltin.cpp` - map existing tan builtins to `tan` and
`constrained_tan` intrinsic
-   `ConstrainedOps.def` map tan and constrained_tan  to an ISDOpcode.

resolves  #91421

-

Co-authored-by: Farzon Lotfi 

Added: 


Modified: 
clang/include/clang/Basic/Builtins.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/X86/math-builtins.c
clang/test/CodeGen/constrained-math-builtins.c
clang/test/CodeGen/math-libcalls.c
clang/test/CodeGenOpenCL/builtins-f16.cl
llvm/docs/LangRef.rst
llvm/include/llvm/IR/ConstrainedOps.def
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/Assembler/fp-intrinsics-attr.ll
llvm/test/CodeGen/AArch64/fp-intrinsics-fp16.ll
llvm/test/CodeGen/AArch64/fp-intrinsics.ll
llvm/test/CodeGen/ARM/fp-intrinsics.ll
llvm/test/CodeGen/PowerPC/ctrloop-constrained-fp.ll
llvm/test/CodeGen/PowerPC/ppcf128-constrained-fp-intrinsics.ll
llvm/test/CodeGen/PowerPC/vector-constrained-fp-intrinsics.ll
llvm/test/CodeGen/RISCV/double-intrinsics-strict.ll
llvm/test/CodeGen/RISCV/float-intrinsics-strict.ll
llvm/test/CodeGen/SystemZ/vector-constrained-fp-intrinsics.ll
llvm/test/CodeGen/X86/fp-intrinsics.ll
llvm/test/CodeGen/X86/fp-strict-libcalls-msvc32.ll
llvm/test/CodeGen/X86/fp128-libcalls-strict.ll
llvm/test/CodeGen/X86/fp80-strict-libcalls.ll
llvm/test/CodeGen/X86/vector-constrained-fp-intrinsics.ll
llvm/test/Feature/fp-intrinsics.ll

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 11982af3fa609..7bef5fd7ad40f 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -482,11 +482,11 @@ def SqrtF16F128 : Builtin, F16F128MathTemplate {
   let Prototype = "T(T)";
 }
 
-def TanF128 : Builtin {
-  let Spellings = ["__builtin_tanf128"];
+def TanF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_tan"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
 ConstIgnoringErrnoAndExceptions];
-  let Prototype = "__float128(__float128)";
+  let Prototype = "T(T)";
 }
 
 def TanhF128 : Builtin {

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c16b69ba87567..06e201fa71e6f 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2923,6 +2923,18 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   SetSqrtFPAccuracy(Call);
   return RValue::get(Call);
 }
+
+case Builtin::BItan:
+case Builtin::BItanf:
+case Builtin::BItanl:
+case Builtin::BI__builtin_tan:
+case Builtin::BI__builtin_tanf:
+case Builtin::BI__builtin_tanf16:
+case Builtin::BI__builtin_tanl:
+case Builtin::BI__builtin_tanf128:
+  return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
+  *this, E, Intrinsic::tan, Intrinsic::experimental_constrained_tan));
+
 case Builtin::BItrunc:
 case Builtin::BItruncf:
 case Builtin::BItruncl:

diff  --git a/clang/test/CodeGen/X86/math-builtins.c 
b/clang/test/CodeGen/X86/math-builtins.c
index 093239b448260..1e0f129b98610 100644
--- a/clang/test/CodeGen/X86/math-builtins.c
+++ b/clang/test/CodeGen/X86/math-builtins.c
@@ -674,10 +674,10 @@ __builtin_sqrt(f);   __builtin_sqrtf(f);  
__builtin_sqrtl(f); __builtin_
 
 __builtin_tan(f);__builtin_tanf(f);   __builtin_tanl(f); 
__builtin_tanf128(f);
 
-// NO__ERRNO: declare double @tan(double noundef) [[READNONE]]
-// NO__ERRNO: declare float @tanf(float noundef) [[READNONE]]
-// NO__ERRNO: declare x86_fp80 @tanl(x86_fp80 noundef) [[READNONE]]
-// NO__ERRNO: declare fp128 @tanf128(fp128 noundef) [[READNONE]]
+// 

[clang] [llvm] [clang][Driver] Add HIPAMD Driver support for AMDGCN flavoured SPIR-V (PR #95061)

2024-06-10 Thread Alex Voicu via cfe-commits


@@ -128,12 +128,13 @@ enum class CudaArch {
   GFX12_GENERIC,
   GFX1200,
   GFX1201,
+  AMDGCNSPIRV,
   Generic, // A processor model named 'generic' if the target backend defines a
// public one.
   LAST,
 
   CudaDefault = CudaArch::SM_52,
-  HIPDefault = CudaArch::GFX906,
+  HIPDefault = CudaArch::AMDGCNSPIRV,

AlexVlx wrote:

In the long run it should not (the BE is almost baked, for example); in the 
interim, it will need the translator, and I (think I) do see what you are 
saying, that it might be onerous to have HIPAMD depend on that - I can unflip 
the default pending the BE coming along. The only cost would be slightly more 
dubious ergonomics, but those are pre-existing.

https://github.com/llvm/llvm-project/pull/95061
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][Driver] Add HIPAMD Driver support for AMDGCN flavoured SPIR-V (PR #95061)

2024-06-10 Thread Joseph Huber via cfe-commits


@@ -128,12 +128,13 @@ enum class CudaArch {
   GFX12_GENERIC,
   GFX1200,
   GFX1201,
+  AMDGCNSPIRV,
   Generic, // A processor model named 'generic' if the target backend defines a
// public one.
   LAST,
 
   CudaDefault = CudaArch::SM_52,
-  HIPDefault = CudaArch::GFX906,
+  HIPDefault = CudaArch::AMDGCNSPIRV,

jhuber6 wrote:

Yeah, makes sense. But doesn't the SPIR-V toolchain require extra tools?

https://github.com/llvm/llvm-project/pull/95061
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][Driver] Add HIPAMD Driver support for AMDGCN flavoured SPIR-V (PR #95061)

2024-06-10 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 edited 
https://github.com/llvm/llvm-project/pull/95061
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][Driver] Add HIPAMD Driver support for AMDGCN flavoured SPIR-V (PR #95061)

2024-06-10 Thread Alex Voicu via cfe-commits


@@ -128,12 +128,13 @@ enum class CudaArch {
   GFX12_GENERIC,
   GFX1200,
   GFX1201,
+  AMDGCNSPIRV,
   Generic, // A processor model named 'generic' if the target backend defines a
// public one.
   LAST,
 
   CudaDefault = CudaArch::SM_52,
-  HIPDefault = CudaArch::GFX906,
+  HIPDefault = CudaArch::AMDGCNSPIRV,

AlexVlx wrote:

Yes, the intent is for HIP go to to SPIRV for this case, since that'll maximise 
"usability" of the compiled binary, for lack of a better word.

https://github.com/llvm/llvm-project/pull/95061
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 48aebd4 - Revert "[AArch64] Decouple feature dependency expansion. (#94279)" (#95056)

2024-06-10 Thread via cfe-commits

Author: Alexandros Lamprineas
Date: 2024-06-11T00:51:52+01:00
New Revision: 48aebd4cf88b3632e8c3ed6b976287c973628e14

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

LOG: Revert "[AArch64] Decouple feature dependency expansion. (#94279)" (#95056)

This reverts commit 2cf14398c9341feddb419e7ff9c8c5623a3da3db since it
broke the llvm test suite:

SingleSource/UnitTests/AArch64/acle-fmv-features.c:59:9:
  error: instruction requires: altnzcv
SingleSource/UnitTests/AArch64/acle-fmv-features.c:117:10:
  error: instruction requires: aes
...

Looks like the FMV dependencies were used in the target attribute and
now features that are FMVOnly (have AEK_NONE) cannot be expanded in
parseTargetAttr using the ExtensionSet.

This suggests that either the tests are wrong (they are using an FMVOnly
feature in a target attribute), or that we need to turn the FMVOnly
features into Extensions (these two are tablegen classes).

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/CMakeLists.txt
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/test/CodeGen/aarch64-cpu-supports-target.c
clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp
clang/test/CodeGen/aarch64-targetattr.c
clang/test/CodeGen/attr-target-version.c
clang/test/Sema/aarch64-neon-target.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/TargetParser/AArch64TargetParser.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 8bce4812f0d48..a1d1d1c51cd41 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3203,6 +3203,9 @@ class ASTContext : public RefCountedBase {
   /// valid feature names.
   ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
 
+  std::vector
+  filterFunctionTargetVersionAttrs(const TargetVersionAttr *TV) const;
+
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
  const FunctionDecl *) const;
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index cd76b8aa271da..bf74e56a14799 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -87,7 +87,6 @@
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/TargetParser/AArch64TargetParser.h"
 #include "llvm/TargetParser/Triple.h"
 #include 
 #include 
@@ -13664,20 +13663,17 @@ QualType 
ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const {
   }
 }
 
-// Given a list of FMV features, return a concatenated list of the
-// corresponding backend features (which may contain duplicates).
-static std::vector getFMVBackendFeaturesFor(
-const llvm::SmallVectorImpl &FMVFeatStrings) {
-  std::vector BackendFeats;
-  for (StringRef F : FMVFeatStrings) {
-if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) {
-  SmallVector Feats;
-  FMVExt->DependentFeatures.split(Feats, ',', -1, false);
-  for (StringRef F : Feats)
-BackendFeats.push_back(F.str());
-}
-  }
-  return BackendFeats;
+std::vector ASTContext::filterFunctionTargetVersionAttrs(
+const TargetVersionAttr *TV) const {
+  assert(TV != nullptr);
+  llvm::SmallVector Feats;
+  std::vector ResFeats;
+  TV->getFeatures(Feats);
+  for (auto &Feature : Feats)
+if (Target->validateCpuSupports(Feature.str()))
+  // Use '?' to mark features that came from TargetVersion.
+  ResFeats.push_back("?" + Feature.str());
+  return ResFeats;
 }
 
 ParsedTargetAttr
@@ -13712,12 +13708,10 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-// AArch64 handles command line option features in parseTargetAttr().
-if (!Target->getTriple().isAArch64())
-  ParsedAttr.Features.insert(
-  ParsedAttr.Features.begin(),
-  Target->getTargetOpts().FeaturesAsWritten.begin(),
-  Target->getTargetOpts().FeaturesAsWritten.end());
+ParsedAttr.Features.insert(
+ParsedAttr.Features.begin(),
+Target->getTargetOpts().FeaturesAsWritten.begin(),
+Target->getTargetOpts().FeaturesAsWritten.end());
 
 if (ParsedAttr.CPU != "" && Target->isValidCPUName(ParsedAttr.CPU))
   TargetCPU = ParsedAttr.CPU;
@@ -13738,31 +13732,32 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 Target->getTargetOpts().FeaturesAsWritten.end());
 Target->initFeatureMap(F

[clang] [llvm] Revert "[AArch64] Decouple feature dependency expansion. (#94279)" (PR #95056)

2024-06-10 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea closed 
https://github.com/llvm/llvm-project/pull/95056
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][Driver] Add HIPAMD Driver support for AMDGCN flavoured SPIR-V (PR #95061)

2024-06-10 Thread Joseph Huber via cfe-commits


@@ -128,12 +128,13 @@ enum class CudaArch {
   GFX12_GENERIC,
   GFX1200,
   GFX1201,
+  AMDGCNSPIRV,
   Generic, // A processor model named 'generic' if the target backend defines a
// public one.
   LAST,
 
   CudaDefault = CudaArch::SM_52,
-  HIPDefault = CudaArch::GFX906,
+  HIPDefault = CudaArch::AMDGCNSPIRV,

jhuber6 wrote:

Why was the default changed here? The default here is just what HIP compilation 
gives without an explicit arch. Is this intentional?

https://github.com/llvm/llvm-project/pull/95061
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][Driver] Add HIPAMD Driver support for AMDGCN flavoured SPIR-V (PR #95061)

2024-06-10 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 2cf14398c9341feddb419e7ff9c8c5623a3da3db 
9b3275b9a5b62d5fe9be8fbeca69455deefc1fb7 -- clang/include/clang/Basic/Cuda.h 
clang/lib/Basic/Cuda.cpp clang/lib/Basic/Targets/NVPTX.cpp 
clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Driver/Driver.cpp 
clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/HIPAMD.cpp 
clang/lib/Driver/ToolChains/HIPAMD.h clang/test/Misc/target-invalid-cpu-note.c 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index c9c7cbf053..a50ef68dd5 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6518,9 +6518,9 @@ const ToolChain &Driver::getOffloadingDeviceToolChain(
 switch (TargetDeviceOffloadKind) {
 case Action::OFK_HIP: {
   if (((Target.getArch() == llvm::Triple::amdgcn ||
-   Target.getArch() == llvm::Triple::spirv64) &&
-  Target.getVendor() == llvm::Triple::AMD &&
-  Target.getOS() == llvm::Triple::AMDHSA) ||
+Target.getArch() == llvm::Triple::spirv64) &&
+   Target.getVendor() == llvm::Triple::AMD &&
+   Target.getOS() == llvm::Triple::AMDHSA) ||
   !Args.hasArgNoClaim(options::OPT_offload_EQ))
 TC = std::make_unique(*this, Target,
HostTC, Args);
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7fd2b184e7..b60e29a0e8 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4939,8 +4939,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
 if (JA.isDeviceOffloading(Action::OFK_HIP) &&
 (getToolChain().getTriple().isAMDGPU() ||
-(getToolChain().getTriple().isSPIRV() &&
- getToolChain().getTriple().getVendor() == llvm::Triple::AMD))) {
+ (getToolChain().getTriple().isSPIRV() &&
+  getToolChain().getTriple().getVendor() == llvm::Triple::AMD))) {
   // Device side compilation printf
   if (Args.getLastArg(options::OPT_mprintf_kind_EQ)) {
 CmdArgs.push_back(Args.MakeArgString(

``




https://github.com/llvm/llvm-project/pull/95061
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][Driver] Add HIPAMD Driver support for AMDGCN flavoured SPIR-V (PR #95061)

2024-06-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-spir-v

Author: Alex Voicu (AlexVlx)


Changes

This patch augments the HIPAMD driver to allow it to target AMDGCN flavoured 
SPIR-V compilation. It's mostly straightforward, as we re-use some of the 
existing SPIRV infra, however there are a few notable additions:

- we introduce an `amdgcnspirv` offload arch, rather than relying on using 
`generic` (this is already fairly overloaded) or simply using `spirv` or 
`spirv64` (we'll want to use these to denote unflavoured SPIRV, once we bring 
up that capability)
- the default compilation for HIP is switched over from targeting the concrete 
`gfx906` target to `amdgcnspirv`
- in order to retain user provided compiler flags and have them available at 
JIT time, we rely on embedding the command line via `-fembed-bitcode=marker`, 
which the bitcode writer had previously not implemented for SPIRV; we only 
allow it conditionally for AMDGCN flavoured SPIRV, and it is handled correctly 
by the Translator (it ends up as a string literal), but a glance from someone 
working on the SPIRV backend would be appreciated

Once the SPIRV BE is no longer experimental we'll swith to using that rather 
than the translator. There's some additional work that'll come via a separate 
PR around correctly piping through AMDGCN's implementation of `printf`, for now 
we merely handle its flags correctly.

---

Patch is 20.68 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/95061.diff


16 Files Affected:

- (modified) clang/include/clang/Basic/Cuda.h (+2-1) 
- (modified) clang/lib/Basic/Cuda.cpp (+1) 
- (modified) clang/lib/Basic/Targets/NVPTX.cpp (+1) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+2-1) 
- (modified) clang/lib/Driver/Driver.cpp (+17-6) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+3-1) 
- (modified) clang/lib/Driver/ToolChains/HIPAMD.cpp (+43-2) 
- (modified) clang/lib/Driver/ToolChains/HIPAMD.h (+4) 
- (modified) clang/test/Driver/cuda-arch-translation.cu (+6) 
- (modified) clang/test/Driver/hip-default-gpu-arch.hip (+1-1) 
- (modified) clang/test/Driver/hip-offload-compress-zlib.hip (+6-6) 
- (modified) clang/test/Driver/hip-options.hip (+6-6) 
- (modified) clang/test/Frontend/embed-bitcode.ll (+7) 
- (modified) clang/test/Frontend/x86-embed-bitcode.ll (+3) 
- (modified) clang/test/Misc/target-invalid-cpu-note.c (+1-1) 
- (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+2) 


``diff
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index 0d5e38e825aa7..63dcf28f0dd21 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -128,12 +128,13 @@ enum class CudaArch {
   GFX12_GENERIC,
   GFX1200,
   GFX1201,
+  AMDGCNSPIRV,
   Generic, // A processor model named 'generic' if the target backend defines a
// public one.
   LAST,
 
   CudaDefault = CudaArch::SM_52,
-  HIPDefault = CudaArch::GFX906,
+  HIPDefault = CudaArch::AMDGCNSPIRV,
 };
 
 enum class CUDAFunctionTarget {
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index 1d96a929f95d8..af99c4d61021e 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -148,6 +148,7 @@ static const CudaArchToStringMap arch_names[] = {
 {CudaArch::GFX12_GENERIC, "gfx12-generic", "compute_amdgcn"},
 GFX(1200), // gfx1200
 GFX(1201), // gfx1201
+{CudaArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
 {CudaArch::Generic, "generic", ""},
 // clang-format on
 };
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index ff7d2f1f92aa4..8e9006853db65 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -232,6 +232,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CudaArch::GFX12_GENERIC:
   case CudaArch::GFX1200:
   case CudaArch::GFX1201:
+  case CudaArch::AMDGCNSPIRV:
   case CudaArch::Generic:
   case CudaArch::LAST:
 break;
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 75b1449090389..97278ddd3723f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -907,7 +907,8 @@ void CodeGenModule::Release() {
   if (Context.getTargetInfo().getTriple().isWasm())
 EmitMainVoidAlias();
 
-  if (getTriple().isAMDGPU()) {
+  if (getTriple().isAMDGPU() ||
+  (getTriple().isSPIRV() && getTriple().getVendor() == llvm::Triple::AMD)) 
{
 // Emit amdhsa_code_object_version module flag, which is code object 
version
 // times 100.
 if (getTarget().getTargetOpts().CodeObjectVersion !=
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..c9c7cbf0534a0 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -147,7 +147,12 @@ getNVIDIAOffloadTargetTriple(const Driver &D, const 
ArgList &Args,
 static std::optional
 getHIP

[clang] [llvm] Revert "[llvm][IR] Extend BranchWeightMetadata to track provenance of weights" (PR #95060)

2024-06-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-pgo

Author: Paul Kirth (ilovepi)


Changes

Reverts llvm/llvm-project#86609

This change causes compile-time regressions for stage2 builds 
(https://llvm-compile-time-tracker.com/compare.php?from=3254f31a66263ea9647c9547f1531c3123444fcd&to=c5978f1eb5eeca8610b9dfce1fcbf1f473911cd8&stat=instructions:u).
 It also introduced unintended changes to `.text` which should be addressed 
before relanding.

---

Patch is 38.70 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/95060.diff


30 Files Affected:

- (modified) clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp 
(+2-2) 
- (modified) llvm/docs/BranchWeightMetadata.rst (-7) 
- (modified) llvm/include/llvm/IR/MDBuilder.h (+2-9) 
- (modified) llvm/include/llvm/IR/ProfDataUtils.h (+1-16) 
- (modified) llvm/lib/CodeGen/CodeGenPrepare.cpp (+1-2) 
- (modified) llvm/lib/IR/Instruction.cpp (+4-15) 
- (modified) llvm/lib/IR/Instructions.cpp (+1-5) 
- (modified) llvm/lib/IR/MDBuilder.cpp (+5-9) 
- (modified) llvm/lib/IR/Metadata.cpp (+4-4) 
- (modified) llvm/lib/IR/ProfDataUtils.cpp (+9-31) 
- (modified) llvm/lib/IR/Verifier.cpp (+3-6) 
- (modified) llvm/lib/Transforms/IPO/SampleProfile.cpp (+3-4) 
- (modified) llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp 
(+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp 
(+1-2) 
- (modified) llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (+2-3) 
- (modified) llvm/lib/Transforms/Scalar/JumpThreading.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp (+7-9) 
- (modified) llvm/lib/Transforms/Utils/Local.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Utils/LoopPeel.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Utils/LoopRotationUtils.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Utils/SimplifyCFG.cpp (+10-13) 
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+6-6) 
- (modified) llvm/test/Transforms/LowerExpectIntrinsic/basic.ll (+4-4) 
- (modified) 
llvm/test/Transforms/LowerExpectIntrinsic/expect-with-probability.ll (+4-4) 
- (modified) llvm/test/Transforms/LowerExpectIntrinsic/expect_nonboolean.ll 
(+3-2) 
- (modified) llvm/test/Transforms/LowerExpectIntrinsic/phi_merge.ll (+2-2) 
- (modified) llvm/test/Transforms/LowerExpectIntrinsic/phi_or.ll (+2-2) 
- (modified) llvm/test/Transforms/LowerExpectIntrinsic/phi_tern.ll (+1-1) 
- (modified) llvm/test/Transforms/LowerExpectIntrinsic/phi_unexpect.ll (+2-2) 
- (modified) llvm/test/Transforms/PhaseOrdering/AArch64/hoist-runtime-checks.ll 
(+1-1) 


``diff
diff --git a/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp 
b/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
index 81d9334356520..fb236aeb982e0 100644
--- a/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
+++ b/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
@@ -221,5 +221,5 @@ void tu2(int &i) {
   }
 }
 
-// CHECK: [[BW_LIKELY]] = !{!"branch_weights", !"expected", i32 2000, i32 1}
-// CHECK: [[BW_UNLIKELY]] = !{!"branch_weights", !"expected", i32 1, i32 2000}
+// CHECK: [[BW_LIKELY]] = !{!"branch_weights", i32 2000, i32 1}
+// CHECK: [[BW_UNLIKELY]] = !{!"branch_weights", i32 1, i32 2000}
diff --git a/llvm/docs/BranchWeightMetadata.rst 
b/llvm/docs/BranchWeightMetadata.rst
index 62204753e29b0..522f37cdad4fc 100644
--- a/llvm/docs/BranchWeightMetadata.rst
+++ b/llvm/docs/BranchWeightMetadata.rst
@@ -28,14 +28,11 @@ Supported Instructions
 
 Metadata is only assigned to the conditional branches. There are two extra
 operands for the true and the false branch.
-We optionally track if the metadata was added by ``__builtin_expect`` or
-``__builtin_expect_with_probability`` with an optional field ``!"expected"``.
 
 .. code-block:: none
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 ,
 i32 
   }
@@ -50,7 +47,6 @@ is always case #0).
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ... ]
   }
@@ -64,7 +60,6 @@ Branch weights are assigned to every destination.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ... ]
   }
@@ -80,7 +75,6 @@ block and entry counts which may not be accurate with 
sampling.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
   }
 
@@ -101,7 +95,6 @@ is used.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ]
   }
diff --git a/llvm/include/llvm/IR/MDBuilder.h b/llvm/include/llvm/IR/MDBuilder.h
index e02ec8f5a3d8b..3265589b7c8df 100644
--- a/llvm/include/llvm/IR/MDBuilder.h
+++ b/llvm/include/llvm/IR/MDBuilder.h
@@ -59,11 +59,7 @@ class MDBuilder {
   //===--===//
 
   /// Return metadata containing two branch weights.
-  /// @param TrueWeight the weight of the true branch
-  /// @param FalseWeight the weight of the false branch
-  /// @param Do these weight

[clang] [llvm] Revert "[llvm][IR] Extend BranchWeightMetadata to track provenance of weights" (PR #95060)

2024-06-10 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi created 
https://github.com/llvm/llvm-project/pull/95060

Reverts llvm/llvm-project#86609

This change causes compile-time regressions for stage2 builds 
(https://llvm-compile-time-tracker.com/compare.php?from=3254f31a66263ea9647c9547f1531c3123444fcd&to=c5978f1eb5eeca8610b9dfce1fcbf1f473911cd8&stat=instructions:u).
 It also introduced unintended changes to `.text` which should be addressed 
before relanding.

>From 809adec88edb2cdca5c97d612865c9789233d3c3 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Mon, 10 Jun 2024 16:43:14 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"[llvm][IR]=20Extend=20BranchWeightMet?=
 =?UTF-8?q?adata=20to=20track=20provenance=20of=20weights=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit c5978f1eb5eeca8610b9dfce1fcbf1f473911cd8.
---
 .../attr-likelihood-if-vs-builtin-expect.cpp  |  4 +-
 llvm/docs/BranchWeightMetadata.rst|  7 
 llvm/include/llvm/IR/MDBuilder.h  | 11 +
 llvm/include/llvm/IR/ProfDataUtils.h  | 17 +---
 llvm/lib/CodeGen/CodeGenPrepare.cpp   |  3 +-
 llvm/lib/IR/Instruction.cpp   | 19 ++---
 llvm/lib/IR/Instructions.cpp  |  6 +--
 llvm/lib/IR/MDBuilder.cpp | 14 +++
 llvm/lib/IR/Metadata.cpp  |  8 ++--
 llvm/lib/IR/ProfDataUtils.cpp | 40 +--
 llvm/lib/IR/Verifier.cpp  |  9 ++---
 llvm/lib/Transforms/IPO/SampleProfile.cpp |  7 ++--
 .../ControlHeightReduction.cpp|  2 +-
 .../Instrumentation/IndirectCallPromotion.cpp |  3 +-
 .../Instrumentation/PGOInstrumentation.cpp|  5 +--
 llvm/lib/Transforms/Scalar/JumpThreading.cpp  |  4 +-
 .../Scalar/LowerExpectIntrinsic.cpp   | 16 
 llvm/lib/Transforms/Utils/Local.cpp   |  2 +-
 llvm/lib/Transforms/Utils/LoopPeel.cpp|  4 +-
 .../Transforms/Utils/LoopRotationUtils.cpp|  4 +-
 llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 23 +--
 .../Transforms/Vectorize/LoopVectorize.cpp| 12 +++---
 .../Transforms/LowerExpectIntrinsic/basic.ll  |  8 ++--
 .../expect-with-probability.ll|  8 ++--
 .../LowerExpectIntrinsic/expect_nonboolean.ll |  5 ++-
 .../LowerExpectIntrinsic/phi_merge.ll |  4 +-
 .../Transforms/LowerExpectIntrinsic/phi_or.ll |  4 +-
 .../LowerExpectIntrinsic/phi_tern.ll  |  2 +-
 .../LowerExpectIntrinsic/phi_unexpect.ll  |  4 +-
 .../AArch64/hoist-runtime-checks.ll   |  2 +-
 30 files changed, 88 insertions(+), 169 deletions(-)

diff --git a/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp 
b/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
index 81d9334356520..fb236aeb982e0 100644
--- a/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
+++ b/clang/test/CodeGenCXX/attr-likelihood-if-vs-builtin-expect.cpp
@@ -221,5 +221,5 @@ void tu2(int &i) {
   }
 }
 
-// CHECK: [[BW_LIKELY]] = !{!"branch_weights", !"expected", i32 2000, i32 1}
-// CHECK: [[BW_UNLIKELY]] = !{!"branch_weights", !"expected", i32 1, i32 2000}
+// CHECK: [[BW_LIKELY]] = !{!"branch_weights", i32 2000, i32 1}
+// CHECK: [[BW_UNLIKELY]] = !{!"branch_weights", i32 1, i32 2000}
diff --git a/llvm/docs/BranchWeightMetadata.rst 
b/llvm/docs/BranchWeightMetadata.rst
index 62204753e29b0..522f37cdad4fc 100644
--- a/llvm/docs/BranchWeightMetadata.rst
+++ b/llvm/docs/BranchWeightMetadata.rst
@@ -28,14 +28,11 @@ Supported Instructions
 
 Metadata is only assigned to the conditional branches. There are two extra
 operands for the true and the false branch.
-We optionally track if the metadata was added by ``__builtin_expect`` or
-``__builtin_expect_with_probability`` with an optional field ``!"expected"``.
 
 .. code-block:: none
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 ,
 i32 
   }
@@ -50,7 +47,6 @@ is always case #0).
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ... ]
   }
@@ -64,7 +60,6 @@ Branch weights are assigned to every destination.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ... ]
   }
@@ -80,7 +75,6 @@ block and entry counts which may not be accurate with 
sampling.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
   }
 
@@ -101,7 +95,6 @@ is used.
 
   !0 = !{
 !"branch_weights",
-[ !"expected", ]
 i32 
 [ , i32  ]
   }
diff --git a/llvm/include/llvm/IR/MDBuilder.h b/llvm/include/llvm/IR/MDBuilder.h
index e02ec8f5a3d8b..3265589b7c8df 100644
--- a/llvm/include/llvm/IR/MDBuilder.h
+++ b/llvm/include/llvm/IR/MDBuilder.h
@@ -59,11 +59,7 @@ class MDBuilder {
   //===--===//
 
   /// Return metadata containing two branch weights.
-  /// @param TrueWeight the weight of the true branch
-  /// @param FalseWeight the weight of the false

[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)

2024-06-10 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/94559
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Return RValue from `EmitVAArg` (PR #94635)

2024-06-10 Thread John McCall via cfe-commits

https://github.com/rjmccall edited 
https://github.com/llvm/llvm-project/pull/94635
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Return RValue from `EmitVAArg` (PR #94635)

2024-06-10 Thread John McCall via cfe-commits


@@ -2161,6 +2161,19 @@ static RValue EmitLoadOfMatrixLValue(LValue LV, 
SourceLocation Loc,
   return RValue::get(CGF.EmitLoadOfScalar(LV, Loc));
 }
 
+RValue CodeGenFunction::EmitLoadOfAnyValue(LValue LV, SourceLocation Loc) {
+  QualType Ty = LV.getType();
+  switch (getEvaluationKind(Ty)) {
+  case TEK_Scalar:
+return EmitLoadOfLValue(LV, Loc);
+  case TEK_Complex:
+return RValue::getComplex(EmitLoadOfComplex(LV, Loc));
+  case TEK_Aggregate:
+return RValue::getAggregate(LV.getAddress());

rjmccall wrote:

I'm concerned about this laundering an l-value address into an aggregate 
r-value address.  If someone used this as a generic routine somewhere else in 
CodeGen, this could pretty easily cause subtle miscompiles.  Can we have the 
AggExprEmitter pass the `AggValueSlot` to `EmitVAArg` and so on, so that it 
eventually gets passed to this method?  And then this method can call 
`EmitAggFinalDestCopy`.


  It's probably okay for our existing use case here, though, where we're 

That might be okay for our specific use case here — we probably never mutate 
the aggregate slot we get back during aggregate expression evaluation, and the 
slot in the `va_list` should otherwise be 

https://github.com/llvm/llvm-project/pull/94635
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hexagon] Add {con, de}structive interference size defn (PR #94877)

2024-06-10 Thread Brian Cain via cfe-commits

androm3da wrote:

> LGTM as far as the code goes, but please add some test coverage for the 
> changes.

Not sure why I omitted it -- thanks.  Fixed.  

https://github.com/llvm/llvm-project/pull/94877
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hexagon] Add {con, de}structive interference size defn (PR #94877)

2024-06-10 Thread Brian Cain via cfe-commits

https://github.com/androm3da updated 
https://github.com/llvm/llvm-project/pull/94877

>From 537cda866200e636cf679fa24f6b857ce6b36339 Mon Sep 17 00:00:00 2001
From: Brian Cain 
Date: Sat, 8 Jun 2024 16:25:11 -0700
Subject: [PATCH] [hexagon] Add {con,de}structive interference size defn

This support was originally added in 72c373bfdc98 ([C++17] Support
__GCC_[CON|DE]STRUCTIVE_SIZE (#89446), 2024-04-26).  We're overriding
the values for Hexagon here.

Signed-off-by: Brian Cain 
---
 clang/lib/Basic/Targets/Hexagon.h| 4 
 clang/test/Preprocessor/hexagon-predefines.c | 9 +
 2 files changed, 13 insertions(+)

diff --git a/clang/lib/Basic/Targets/Hexagon.h 
b/clang/lib/Basic/Targets/Hexagon.h
index cdb47dbae7999..f5e7a8878f01b 100644
--- a/clang/lib/Basic/Targets/Hexagon.h
+++ b/clang/lib/Basic/Targets/Hexagon.h
@@ -139,6 +139,10 @@ class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public 
TargetInfo {
   }
 
   bool hasBitIntType() const override { return true; }
+
+  std::pair hardwareInterferenceSizes() const override {
+return std::make_pair(32, 32);
+  }
 };
 } // namespace targets
 } // namespace clang
diff --git a/clang/test/Preprocessor/hexagon-predefines.c 
b/clang/test/Preprocessor/hexagon-predefines.c
index bd55753a090de..0e35e974b6058 100644
--- a/clang/test/Preprocessor/hexagon-predefines.c
+++ b/clang/test/Preprocessor/hexagon-predefines.c
@@ -169,3 +169,12 @@
 // CHECK-ATOMIC: #define __CLANG_ATOMIC_POINTER_LOCK_FREE 2
 // CHECK-ATOMIC: #define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
 // CHECK-ATOMIC: #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-linux-musl \
+// RUN: -target-cpu hexagonv67 | FileCheck \
+// RUN: %s -check-prefix CHECK-INTERFERENCE
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-none-elf \
+// RUN: -target-cpu hexagonv67 | FileCheck \
+// RUN: %s -check-prefix CHECK-INTERFERENCE
+// CHECK-INTERFERENCE: #define __GCC_CONSTRUCTIVE_SIZE 32
+// CHECK-INTERFERENCE: #define __GCC_DESTRUCTIVE_SIZE 32

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


[clang] [ObjC][CodeGen] Assume a for-in loop is in bounds and cannot overflow (PR #94885)

2024-06-10 Thread John McCall via cfe-commits

https://github.com/rjmccall commented:

LGTM.  Do we not have any tests that actually test the add?

https://github.com/llvm/llvm-project/pull/94885
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hexagon] Add {con, de}structive interference size defn (PR #94877)

2024-06-10 Thread Ikhlas Ajbar via cfe-commits

https://github.com/iajbar approved this pull request.


https://github.com/llvm/llvm-project/pull/94877
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-06-10 Thread via cfe-commits

goldsteinn wrote:

ping

https://github.com/llvm/llvm-project/pull/91101
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [libcxx] [libcxxabi] [libunwind] [libunwind][libcxx][libcxxabi][compiler-rt-builtins] Fix Exception Handling build for wasm (PR #79667)

2024-06-10 Thread via cfe-commits

https://github.com/trcrsired updated 
https://github.com/llvm/llvm-project/pull/79667

>From 4f1ce895254dd9505150c1f5f5cb77454b9aca68 Mon Sep 17 00:00:00 2001
From: cqwrteur <100043421+trcrsi...@users.noreply.github.com>
Date: Sat, 1 Jun 2024 02:55:50 -0400
Subject: [PATCH] [libunwind][libcxx][libcxxabi] Fix Exception Handling build
 for wasm

The wasm unwind build appears to be dysfunctional, likely because the author 
has only supplied a customized LLVM build on request, rather than a fully 
functional patch.

This patch fixes the build

Apply formatting patch proposed by github bot

use "" to prevent CMAKE_SYSTEM_PROCESSOR not defined

[libunwind] logAPI functions should also be built

[libcxxabi] Fix function signatures for wasm

wasm does not define the function signatures correctly for cxxabi
Fix them

Fix formatting issues for libcxxabi's wasm eh change

Merge remote-tracking branch 'parent/main' into wasmlibunwindfix

remove unwanted changes in unwind-wasm.c

Make Unwind-wasm.c compile correctly without workaround in
CMakeLists.txt

using __wasm__ macro to guard against all wasm eh build

fix UnwindLevel.c's formatting issue

ISO C requires a translation unit to contain at least one declaration 
[-Werror,-Wempty-translation-unit]

compiler-rt does not define CMP_RESULT correct on wasm64
Fixed

Merge code
---
 compiler-rt/lib/builtins/fp_compare_impl.inc |   2 +-
 libcxx/include/__exception/exception_ptr.h   |  21 +-
 libcxxabi/include/cxxabi.h   | 179 ++---
 libcxxabi/src/cxa_exception.cpp  | 712 ---
 libcxxabi/src/cxa_exception.h|   7 +-
 libunwind/include/libunwind.h|   2 +
 libunwind/src/Unwind-wasm.c  |  13 +-
 libunwind/src/UnwindRegistersRestore.S   |   3 +-
 libunwind/src/UnwindRegistersSave.S  |   3 +
 libunwind/src/assembly.h |   2 +
 libunwind/src/cet_unwind.h   |   3 +
 libunwind/src/config.h   |  15 +-
 libunwind/src/libunwind.cpp  |   2 +
 libunwind/src/libunwind_ext.h|   2 +
 14 files changed, 423 insertions(+), 543 deletions(-)

diff --git a/compiler-rt/lib/builtins/fp_compare_impl.inc 
b/compiler-rt/lib/builtins/fp_compare_impl.inc
index a9a4f6fbf5dfe..83bdea46a45da 100644
--- a/compiler-rt/lib/builtins/fp_compare_impl.inc
+++ b/compiler-rt/lib/builtins/fp_compare_impl.inc
@@ -12,7 +12,7 @@
 // functions. We need to ensure that the return value is sign-extended in the
 // same way as GCC expects (since otherwise GCC-generated __builtin_isinf
 // returns true for finite 128-bit floating-point numbers).
-#ifdef __aarch64__
+#if defined(__aarch64__) || defined(__wasm__)
 // AArch64 GCC overrides libgcc_cmp_return to use int instead of long.
 typedef int CMP_RESULT;
 #elif __SIZEOF_POINTER__ == 8 && __SIZEOF_LONG__ == 4
diff --git a/libcxx/include/__exception/exception_ptr.h 
b/libcxx/include/__exception/exception_ptr.h
index 0a8337fa39de3..01f340a587ec3 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -29,22 +29,21 @@
 
 namespace __cxxabiv1 {
 
+#if defined(__wasm__)
+typedef void* (*__libcpp_exception_destructor_func)(void*);
+#elif defined(_WIN32)
+typedef void(__thiscall* __libcpp_exception_destructor_func)(void*);
+#else
+typedef void (*__libcpp_exception_destructor_func)(void*);
+#endif
+
 extern "C" {
 _LIBCPP_OVERRIDABLE_FUNC_VIS void* __cxa_allocate_exception(size_t) throw();
 _LIBCPP_OVERRIDABLE_FUNC_VIS void __cxa_free_exception(void*) throw();
 
 struct __cxa_exception;
-_LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(
-void*,
-std::type_info*,
-#if defined(_WIN32)
-void(__thiscall*)(void*)) throw();
-#elif defined(__wasm__)
-// In Wasm, a destructor returns its argument
-void* (*)(void*)) throw();
-#else
-void (*)(void*)) throw();
-#endif
+_LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception*
+__cxa_init_primary_exception(void*, std::type_info*, 
__libcpp_exception_destructor_func) throw();
 }
 
 } // namespace __cxxabiv1
diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h
index 0e3969084e04f..4162fd7ec2ba7 100644
--- a/libcxxabi/include/cxxabi.h
+++ b/libcxxabi/include/cxxabi.h
@@ -20,62 +20,51 @@
 #include <__cxxabi_config.h>
 
 #define _LIBCPPABI_VERSION 15000
-#define _LIBCXXABI_NORETURN  __attribute__((noreturn))
+#define _LIBCXXABI_NORETURN __attribute__((noreturn))
 #define _LIBCXXABI_ALWAYS_COLD __attribute__((cold))
 
 #ifdef __cplusplus
 
 namespace std {
-#if defined(_WIN32)
+#  if defined(_WIN32)
 class _LIBCXXABI_TYPE_VIS type_info; // forward declaration
-#else
+#  else
 class type_info; // forward declaration
-#endif
-}
-
+#  endif
+} // namespace std
 
 // runtime routines use C calling conventions, but are in __cxxabiv1 namespace
 namespace __cxxabiv1 {
 
 struct __cxa_exception;
+#  if defined(__wasm__)
+typedef void*

[clang] [llvm] Revert "[AArch64] Decouple feature dependency expansion. (#94279)" (PR #95056)

2024-06-10 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea updated 
https://github.com/llvm/llvm-project/pull/95056

>From 8d58882c51051a09de10536a418b5518d6ccd14d Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Mon, 10 Jun 2024 23:17:54 +0100
Subject: [PATCH] Revert "[AArch64] Decouple feature dependency expansion.
 (#94279)"

This reverts commit 2cf14398c9341feddb419e7ff9c8c5623a3da3db since
it broke the llvm test suite:

SingleSource/UnitTests/AArch64/acle-fmv-features.c:59:9:
  error: instruction requires: altnzcv
SingleSource/UnitTests/AArch64/acle-fmv-features.c:117:10:
  error: instruction requires: aes
...

Looks like the FMV dependencies were used in the target attribute
and now features that are FMVOnly (have AEK_NONE) cannot be expanded
in parseTargetAttr using the ExtensionSet.

This suggests that either the tests are wrong (they are using an
FMVOnly feature in a target attribute), or that we need to turn the
FMVOnly features into Extensions (these two are tablegen classes).
---
 clang/include/clang/AST/ASTContext.h  |   3 +
 clang/lib/AST/ASTContext.cpp  |  59 +-
 clang/lib/AST/CMakeLists.txt  |   2 -
 clang/lib/Basic/Targets/AArch64.cpp   | 105 +++--
 clang/lib/Basic/Targets/AArch64.h |   4 +
 .../CodeGen/aarch64-cpu-supports-target.c |   4 +-
 .../aarch64-sme-attrs.cpp |   2 +-
 clang/test/CodeGen/aarch64-targetattr.c   |  48 
 clang/test/CodeGen/attr-target-version.c  |  46 
 clang/test/Sema/aarch64-neon-target.c |   4 +-
 .../llvm/TargetParser/AArch64TargetParser.h   | 107 +++---
 llvm/lib/TargetParser/AArch64TargetParser.cpp |  51 +++--
 12 files changed, 222 insertions(+), 213 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 8bce4812f0d48..a1d1d1c51cd41 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3203,6 +3203,9 @@ class ASTContext : public RefCountedBase {
   /// valid feature names.
   ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
 
+  std::vector
+  filterFunctionTargetVersionAttrs(const TargetVersionAttr *TV) const;
+
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
  const FunctionDecl *) const;
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index cd76b8aa271da..bf74e56a14799 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -87,7 +87,6 @@
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/TargetParser/AArch64TargetParser.h"
 #include "llvm/TargetParser/Triple.h"
 #include 
 #include 
@@ -13664,20 +13663,17 @@ QualType 
ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const {
   }
 }
 
-// Given a list of FMV features, return a concatenated list of the
-// corresponding backend features (which may contain duplicates).
-static std::vector getFMVBackendFeaturesFor(
-const llvm::SmallVectorImpl &FMVFeatStrings) {
-  std::vector BackendFeats;
-  for (StringRef F : FMVFeatStrings) {
-if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) {
-  SmallVector Feats;
-  FMVExt->DependentFeatures.split(Feats, ',', -1, false);
-  for (StringRef F : Feats)
-BackendFeats.push_back(F.str());
-}
-  }
-  return BackendFeats;
+std::vector ASTContext::filterFunctionTargetVersionAttrs(
+const TargetVersionAttr *TV) const {
+  assert(TV != nullptr);
+  llvm::SmallVector Feats;
+  std::vector ResFeats;
+  TV->getFeatures(Feats);
+  for (auto &Feature : Feats)
+if (Target->validateCpuSupports(Feature.str()))
+  // Use '?' to mark features that came from TargetVersion.
+  ResFeats.push_back("?" + Feature.str());
+  return ResFeats;
 }
 
 ParsedTargetAttr
@@ -13712,12 +13708,10 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-// AArch64 handles command line option features in parseTargetAttr().
-if (!Target->getTriple().isAArch64())
-  ParsedAttr.Features.insert(
-  ParsedAttr.Features.begin(),
-  Target->getTargetOpts().FeaturesAsWritten.begin(),
-  Target->getTargetOpts().FeaturesAsWritten.end());
+ParsedAttr.Features.insert(
+ParsedAttr.Features.begin(),
+Target->getTargetOpts().FeaturesAsWritten.begin(),
+Target->getTargetOpts().FeaturesAsWritten.end());
 
 if (ParsedAttr.CPU != "" && Target->isValidCPUName(ParsedAttr.CPU))
   TargetCPU = ParsedAttr.CPU;
@@ -13738,31 +13732,32 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 Target->getTargetOpts().FeaturesAsWritten.

[clang] [llvm] Revert "[AArch64] Decouple feature dependency expansion. (#94279)" (PR #95056)

2024-06-10 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea updated 
https://github.com/llvm/llvm-project/pull/95056

>From dc660f11e90e771dd95acf8d37936dbb402588f6 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Mon, 10 Jun 2024 23:17:54 +0100
Subject: [PATCH] Revert "[AArch64] Decouple feature dependency expansion.
 (#94279)"

This reverts commit 2cf14398c9341feddb419e7ff9c8c5623a3da3db since
it broke the llvm test suite:

SingleSource/UnitTests/AArch64/acle-fmv-features.c:59:9:
  error: instruction requires: altnzcv
SingleSource/UnitTests/AArch64/acle-fmv-features.c:117:10:
  error: instruction requires: aes
...

Looks like the FMV dependencies were used in the target attribute
and now features that are FMVOnly (have AEK_NONE) cannot be expanded
in parseTargetAttr using the ExtensionSet.

This suggests that either the tests are wrong (they are using an
FMVOnly feature in a target attribute), or that we need to turn the
FMVOnly features into Extensions (these two are tablegen classes).
---
 clang/include/clang/AST/ASTContext.h  |   3 +
 clang/lib/AST/ASTContext.cpp  |  59 +-
 clang/lib/AST/CMakeLists.txt  |   2 -
 clang/lib/Basic/Targets/AArch64.cpp   | 105 +++--
 clang/lib/Basic/Targets/AArch64.h |   4 +
 .../CodeGen/aarch64-cpu-supports-target.c |   4 +-
 .../aarch64-sme-attrs.cpp |   2 +-
 clang/test/CodeGen/aarch64-targetattr.c   |  48 
 clang/test/CodeGen/attr-target-version.c  |  46 
 clang/test/Sema/aarch64-neon-target.c |   4 +-
 .../llvm/TargetParser/AArch64TargetParser.h   | 107 +++---
 llvm/lib/TargetParser/AArch64TargetParser.cpp |  51 +++--
 12 files changed, 222 insertions(+), 213 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 8bce4812f0d48..a1d1d1c51cd41 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3203,6 +3203,9 @@ class ASTContext : public RefCountedBase {
   /// valid feature names.
   ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
 
+  std::vector
+  filterFunctionTargetVersionAttrs(const TargetVersionAttr *TV) const;
+
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
  const FunctionDecl *) const;
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index cd76b8aa271da..bf74e56a14799 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -87,7 +87,6 @@
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/TargetParser/AArch64TargetParser.h"
 #include "llvm/TargetParser/Triple.h"
 #include 
 #include 
@@ -13664,20 +13663,17 @@ QualType 
ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const {
   }
 }
 
-// Given a list of FMV features, return a concatenated list of the
-// corresponding backend features (which may contain duplicates).
-static std::vector getFMVBackendFeaturesFor(
-const llvm::SmallVectorImpl &FMVFeatStrings) {
-  std::vector BackendFeats;
-  for (StringRef F : FMVFeatStrings) {
-if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) {
-  SmallVector Feats;
-  FMVExt->DependentFeatures.split(Feats, ',', -1, false);
-  for (StringRef F : Feats)
-BackendFeats.push_back(F.str());
-}
-  }
-  return BackendFeats;
+std::vector ASTContext::filterFunctionTargetVersionAttrs(
+const TargetVersionAttr *TV) const {
+  assert(TV != nullptr);
+  llvm::SmallVector Feats;
+  std::vector ResFeats;
+  TV->getFeatures(Feats);
+  for (auto &Feature : Feats)
+if (Target->validateCpuSupports(Feature.str()))
+  // Use '?' to mark features that came from TargetVersion.
+  ResFeats.push_back("?" + Feature.str());
+  return ResFeats;
 }
 
 ParsedTargetAttr
@@ -13712,12 +13708,10 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-// AArch64 handles command line option features in parseTargetAttr().
-if (!Target->getTriple().isAArch64())
-  ParsedAttr.Features.insert(
-  ParsedAttr.Features.begin(),
-  Target->getTargetOpts().FeaturesAsWritten.begin(),
-  Target->getTargetOpts().FeaturesAsWritten.end());
+ParsedAttr.Features.insert(
+ParsedAttr.Features.begin(),
+Target->getTargetOpts().FeaturesAsWritten.begin(),
+Target->getTargetOpts().FeaturesAsWritten.end());
 
 if (ParsedAttr.CPU != "" && Target->isValidCPUName(ParsedAttr.CPU))
   TargetCPU = ParsedAttr.CPU;
@@ -13738,31 +13732,32 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 Target->getTargetOpts().FeaturesAsWritten.

  1   2   3   4   5   >