[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-11-20 Thread via cfe-commits

https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/116331

>From 3c792216f88e87b69b3ea7415c2fd74b7f5d7469 Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Fri, 25 Oct 2024 17:48:41 +
Subject: [PATCH 1/9] adding comments

---
 clang/include/clang/Basic/Attr.td | 10 ++
 clang/lib/CodeGen/CGStmt.cpp  |  2 ++
 clang/lib/CodeGen/CodeGenFunction.cpp |  2 ++
 clang/lib/Sema/SemaStmtAttr.cpp   |  8 
 4 files changed, 22 insertions(+)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index b3c357ec906a23..6d3e07ce83100b 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4302,6 +4302,16 @@ def HLSLLoopHint: StmtAttr {
   let Documentation = [HLSLLoopHintDocs, HLSLUnrollHintDocs];
 }
 
+def HLSLBranchHint: StmtAttr {
+  /// [branch]
+  /// [flatten]
+  let Spellings = [Microsoft<"branch">, Microsoft<"flatten">];
+  let Subjects = SubjectList<[IfStmt],
+  ErrorDiag, "'if' statements">;
+  let LangOpts = [HLSL];
+  let Documentation = [InternalOnly];
+}
+
 def CapturedRecord : InheritableAttr {
   // This attribute has no spellings as it is only ever created implicitly.
   let Spellings = [];
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 698baf853507f4..7b01dc84b55365 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -761,6 +761,7 @@ void CodeGenFunction::EmitAttributedStmt(const 
AttributedStmt &S) {
 Builder.CreateAssumption(AssumptionVal);
   }
 } break;
+// [jderezende] TODO: Add HLSLBranchHint, to mark if flatten/branch is 
present.
 }
   }
   SaveAndRestore save_nomerge(InNoMergeAttributedStmt, nomerge);
@@ -768,6 +769,7 @@ void CodeGenFunction::EmitAttributedStmt(const 
AttributedStmt &S) {
   SaveAndRestore save_alwaysinline(InAlwaysInlineAttributedStmt, alwaysinline);
   SaveAndRestore save_noconvergent(InNoConvergentAttributedStmt, noconvergent);
   SaveAndRestore save_musttail(MustTailCall, musttail);
+  // [jderezende] TODO: Save HLSLBranchHint information
   EmitStmt(S.getSubStmt(), S.getAttrs());
 }
 
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 6ead45793742d6..fc4fde81984d64 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -43,6 +43,7 @@
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
+#include "llvm/IR/Metadata.h"
 #include "llvm/IR/Operator.h"
 #include "llvm/Support/CRC.h"
 #include "llvm/Support/xxhash.h"
@@ -2076,6 +2077,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(
 Weights = createProfileWeights(TrueCount, CurrentCount - TrueCount);
   }
 
+  // [jderezende] TODO: Emit branch metadata marking it as flatten/branch, if 
exists.
   Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights, Unpredictable);
 }
 
diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp
index f801455596fe6f..68323092cb564d 100644
--- a/clang/lib/Sema/SemaStmtAttr.cpp
+++ b/clang/lib/Sema/SemaStmtAttr.cpp
@@ -623,6 +623,12 @@ static Attr *handleHLSLLoopHintAttr(Sema &S, Stmt *St, 
const ParsedAttr &A,
   return ::new (S.Context) HLSLLoopHintAttr(S.Context, A, UnrollFactor);
 }
 
+static Attr *handleHLSLBranchHint(Sema &S, Stmt *St, const ParsedAttr &A,
+SourceRange Range) {
+
+  return ::new (S.Context) HLSLBranchHintAttr(S.Context, A);
+}
+
 static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A,
   SourceRange Range) {
   if (A.isInvalid() || A.getKind() == ParsedAttr::IgnoredAttribute)
@@ -659,6 +665,8 @@ static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const 
ParsedAttr &A,
 return handleLoopHintAttr(S, St, A, Range);
   case ParsedAttr::AT_HLSLLoopHint:
 return handleHLSLLoopHintAttr(S, St, A, Range);
+  case ParsedAttr::AT_HLSLBranchHint:
+return handleHLSLBranchHint(S, St, A, Range);
   case ParsedAttr::AT_OpenCLUnrollHint:
 return handleOpenCLUnrollHint(S, St, A, Range);
   case ParsedAttr::AT_Suppress:

>From f48e382b7ff396fbf1b2ce7dcea9529a06fa9b12 Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Mon, 28 Oct 2024 23:58:10 +
Subject: [PATCH 2/9] continue exploration

---
 llvm/include/llvm/IR/FixedMetadataKinds.def | 3 +++
 llvm/lib/Target/SPIRV/SPIRVStructurizer.cpp | 1 +
 2 files changed, 4 insertions(+)

diff --git a/llvm/include/llvm/IR/FixedMetadataKinds.def 
b/llvm/include/llvm/IR/FixedMetadataKinds.def
index df572e8791e13b..02a986d42f1933 100644
--- a/llvm/include/llvm/IR/FixedMetadataKinds.def
+++ b/llvm/include/llvm/IR/FixedMetadataKinds.def
@@ -53,3 +53,6 @@ LLVM_FIXED_MD_KIND(MD_DIAssignID, "DIAssignID", 38)
 LLVM_FIXED_MD_KIND(MD_coro_outside_frame, "coro.outside.frame", 39)
 LLVM_FIXED_MD_KIND(MD_mmra, "mmra", 40)
 LLVM_FIXED_MD_KIND(MD_noalias_addrspace

[clang] [CUDA] pass -fno-threadsafe-statics to GPU sub-compilations. (PR #117074)

2024-11-20 Thread Artem Belevich via cfe-commits

https://github.com/Artem-B created 
https://github.com/llvm/llvm-project/pull/117074

We do not have support for the threadsafe statics on the GPU side.

However, we do sometimes end up with empty local static initializers, and those 
happen to trigger calls to `__cxa_guard*`, which breaks compilation.

Partially addresses https://github.com/llvm/llvm-project/issues/117023

>From 1c8829a1defa6dd06aacb9a2047e7f79db238e2b Mon Sep 17 00:00:00 2001
From: Artem Belevich 
Date: Wed, 20 Nov 2024 14:24:00 -0800
Subject: [PATCH] [CUDA] pass -fno-threadsafe-statics to GPU sub-compilations.

We do not have support for the threadsafe statics on the GPU side.

However, we do sometimes end up with empty local static initializers,
and those happen to trigger calls to `__cxa_guard*`, which breaks compilation.

Partially addresses https://github.com/llvm/llvm-project/issues/117023
---
 clang/lib/Driver/ToolChains/Cuda.cpp|  5 +++--
 clang/test/Driver/cuda-no-threadsafe-statics.cu | 10 ++
 2 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/cuda-no-threadsafe-statics.cu

diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index ddd5ea248ca0cc..102794829795da 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -856,8 +856,9 @@ void CudaToolChain::addClangTargetOptions(
   DeviceOffloadingKind == Action::OFK_Cuda) &&
  "Only OpenMP or CUDA offloading kinds are supported for NVIDIA 
GPUs.");
 
-  CC1Args.append(
-  {"-fcuda-is-device", "-mllvm", "-enable-memcpyopt-without-libcalls"});
+  CC1Args.append({"-fcuda-is-device", "-mllvm",
+  "-enable-memcpyopt-without-libcalls",
+  "-fno-threadsafe-statics"});
 
   // Unsized function arguments used for variadics were introduced in CUDA-9.0
   // We still do not support generating code that actually uses variadic
diff --git a/clang/test/Driver/cuda-no-threadsafe-statics.cu 
b/clang/test/Driver/cuda-no-threadsafe-statics.cu
new file mode 100644
index 00..fd0465f175846d
--- /dev/null
+++ b/clang/test/Driver/cuda-no-threadsafe-statics.cu
@@ -0,0 +1,10 @@
+// Check that -fno-thread-safe-statics get passed down to device-side
+// compilation only.
+//
+// RUN: not %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s 
2>&1 \
+// RUN:   | FileCheck %s
+//
+// CHECK: "-fcuda-is-device"
+// CHECK-SAME: "-fno-threadsafe-statics"
+// CHECK: "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-NOT: "-fno-threadsafe-statics"

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


[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-11-20 Thread via cfe-commits


@@ -53,3 +53,6 @@ LLVM_FIXED_MD_KIND(MD_DIAssignID, "DIAssignID", 38)
 LLVM_FIXED_MD_KIND(MD_coro_outside_frame, "coro.outside.frame", 39)
 LLVM_FIXED_MD_KIND(MD_mmra, "mmra", 40)
 LLVM_FIXED_MD_KIND(MD_noalias_addrspace, "noalias.addrspace", 41)
+// TODO: this will likelly be placed somewhere else,
+// so we don't mix dxil/hlsl/spirv and clang metadata
+LLVM_FIXED_MD_KIND(MD_dxil_controlflow_hints, "dx.controlflow.hints", 42)

joaosaffran wrote:

@nikic @llvm-beanz removed the changes in IR Builder. Since this metadata is 
just passing through the backend, I am using `hlsl.controlflow.hint` and 
`dx.controlflow.hints`, the latter to keep compatibility with DXIL. 

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


[clang] allow prefer 256 bit attribute target (PR #117092)

2024-11-20 Thread Matthias Braun via cfe-commits

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


[clang] [clang] Use a Worklist for some CodeGenFunctions (PR #115395)

2024-11-20 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic commented:

In general, it's hard to avoid recursion: an AST is fundamentally a tree, and 
the most natural way to walk a tree is recursive, which is why we have issues 
in the first place.  This usually isn't an issue because people don't write 
deeply nested code, but unfortunately it's easy to get extreme nesting with 
switch cases.  (Also with template instantiation, but that's not relevant in 
this context.)

A more targeted hack specifically targeting CaseStmt would probably be 
sufficient, but I guess making the whole thing iterative is also fine.

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


[clang] [webkit.UncountedLambdaCapturesChecker] Fix debug assertion failure. (PR #117090)

2024-11-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: Ryosuke Niwa (rniwa)


Changes

Only call getThisType() on an instance method.

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


2 Files Affected:

- (modified) 
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp 
(+2-1) 
- (modified) clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp 
(+4) 


``diff
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
index 3fb763e72e6809..9312bf0af16dbf 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
@@ -51,7 +51,8 @@ class UncountedLambdaCapturesChecker
 
   bool TraverseCXXMethodDecl(CXXMethodDecl *CXXMD) override {
 llvm::SaveAndRestore SavedDecl(ClsType);
-ClsType = CXXMD->getThisType();
+if (CXXMD && CXXMD->isInstance())
+  ClsType = CXXMD->getThisType();
 return DynamicRecursiveASTVisitor::TraverseCXXMethodDecl(CXXMD);
   }
 
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp 
b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
index 9bfcdea04755d2..b63ffed8809fef 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_analyze_cc1 
-analyzer-checker=webkit.UncountedLambdaCapturesChecker -verify %s
 
+struct A {
+  static void b();
+};
+
 struct RefCountable {
   void ref() {}
   void deref() {}

``




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


[clang] [webkit.UncountedLambdaCapturesChecker] Fix debug assertion failure. (PR #117090)

2024-11-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ryosuke Niwa (rniwa)


Changes

Only call getThisType() on an instance method.

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


2 Files Affected:

- (modified) 
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp 
(+2-1) 
- (modified) clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp 
(+4) 


``diff
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
index 3fb763e72e6809..9312bf0af16dbf 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
@@ -51,7 +51,8 @@ class UncountedLambdaCapturesChecker
 
   bool TraverseCXXMethodDecl(CXXMethodDecl *CXXMD) override {
 llvm::SaveAndRestore SavedDecl(ClsType);
-ClsType = CXXMD->getThisType();
+if (CXXMD && CXXMD->isInstance())
+  ClsType = CXXMD->getThisType();
 return DynamicRecursiveASTVisitor::TraverseCXXMethodDecl(CXXMD);
   }
 
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp 
b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
index 9bfcdea04755d2..b63ffed8809fef 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_analyze_cc1 
-analyzer-checker=webkit.UncountedLambdaCapturesChecker -verify %s
 
+struct A {
+  static void b();
+};
+
 struct RefCountable {
   void ref() {}
   void deref() {}

``




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


[clang] allow prefer 256 bit attribute target (PR #117092)

2024-11-20 Thread Matthias Braun via cfe-commits

MatzeB wrote:

Note that this has the test changes from #117091  included.

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


[clang] [llvm] [HLSL] Add implicit resource element type concepts to AST (PR #116413)

2024-11-20 Thread Joshua Batista via cfe-commits

https://github.com/bob80905 updated 
https://github.com/llvm/llvm-project/pull/116413

>From 92ccbe72ca95ad2df5a81b76244a8a8d7cedef40 Mon Sep 17 00:00:00 2001
From: Joshua Batista 
Date: Fri, 15 Nov 2024 09:00:15 -0800
Subject: [PATCH 1/4] update new tests

---
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 210 +-
 .../AST/HLSL/AppendStructuredBuffer-AST.hlsl  |   4 +-
 .../AST/HLSL/ConsumeStructuredBuffer-AST.hlsl |   4 +-
 clang/test/AST/HLSL/RWBuffer-AST.hlsl |  22 +-
 .../test/AST/HLSL/RWStructuredBuffer-AST.hlsl |   4 +-
 ...RasterizerOrderedStructuredBuffer-AST.hlsl |   4 +-
 clang/test/AST/HLSL/StructuredBuffer-AST.hlsl |   4 +-
 ...d_resource_element_compatible_concept.hlsl |  10 +
 clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl   |  16 +-
 .../SemaHLSL/BuiltIns/StructuredBuffers.hlsl  |   4 +-
 10 files changed, 253 insertions(+), 29 deletions(-)
 create mode 100644 
clang/test/AST/HLSL/is_typed_resource_element_compatible_concept.hlsl

diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index cac15b974a276e..400d3334f6f0de 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -289,8 +289,9 @@ struct BuiltinTypeDeclBuilder {
   }
 
   TemplateParameterListBuilder addTemplateArgumentList(Sema &S);
-  BuiltinTypeDeclBuilder &addSimpleTemplateParams(Sema &S,
-  ArrayRef Names);
+  BuiltinTypeDeclBuilder &
+  addSimpleTemplateParams(Sema &S, ArrayRef Names, ConceptDecl *CD);
+  BuiltinTypeDeclBuilder &addConceptSpecializationExpr(Sema &S);
 };
 
 struct TemplateParameterListBuilder {
@@ -312,8 +313,9 @@ struct TemplateParameterListBuilder {
 S.Context, Builder.Record->getDeclContext(), SourceLocation(),
 SourceLocation(), /* TemplateDepth */ 0, Position,
 &S.Context.Idents.get(Name, tok::TokenKind::identifier),
-/* Typename */ false,
-/* ParameterPack */ false);
+/* Typename */ true,
+/* ParameterPack */ false,
+/* HasTypeConstraint*/ false);
 if (!DefaultValue.isNull())
   Decl->setDefaultArgument(
   S.Context, S.getTrivialTemplateArgumentLoc(DefaultValue, QualType(),
@@ -323,19 +325,114 @@ struct TemplateParameterListBuilder {
 return *this;
   }
 
-  BuiltinTypeDeclBuilder &finalizeTemplateArgs() {
+  /*
+The concept specialization expression (CSE) constructed in
+constructConceptSpecializationExpr is constructed so that it
+matches the CSE that is constructed when parsing the below C++ code:
+template
+concept is_typed_resource_element_compatible = sizeof(T) <= 16;
+template requires
+is_typed_resource_element_compatible
+struct RWBuffer {
+element_type Val;
+};
+int fn() {
+RWBuffer Buf;
+}
+When dumping the AST and filtering for "RWBuffer", the resulting AST
+structure is what we're trying to construct below, specifically the
+CSE portion.
+*/
+  ConceptSpecializationExpr *
+  constructConceptSpecializationExpr(Sema &S, ConceptDecl *CD) {
+ASTContext &Context = S.getASTContext();
+SourceLocation Loc = Builder.Record->getBeginLoc();
+DeclarationNameInfo DNI(CD->getDeclName(), Loc);
+NestedNameSpecifierLoc NNSLoc;
+DeclContext *DC = Builder.Record->getDeclContext();
+TemplateArgumentListInfo TALI(Loc, Loc);
+
+// Assume that the concept decl has just one template parameter
+// This parameter should have been added when CD was constructed
+// in getTypedBufferConceptDecl
+assert(CD->getTemplateParameters()->size() == 1 &&
+   "unexpected concept decl parameter count");
+TemplateTypeParmDecl *ConceptTTPD = dyn_cast(
+CD->getTemplateParameters()->getParam(0));
+
+// this TemplateTypeParmDecl is the template for the resource, and is
+// used to construct a template argumentthat will be used
+// to construct the ImplicitConceptSpecializationDecl
+TemplateTypeParmDecl *T = TemplateTypeParmDecl::Create(
+Context,  // AST context
+Builder.Record->getDeclContext(), // DeclContext
+SourceLocation(), SourceLocation(),
+/*depth=*/0,// Depth in the template parameter list
+/*position=*/0, // Position in the template parameter list
+/*id=*/nullptr, // Identifier for 'T'
+/*Typename=*/true,  // Indicates this is a 'typename' or 
'class'
+/*ParameterPack=*/false,// Not a parameter pack
+/*HasTypeConstraint=*/false // Has no type constraint
+);
+
+T->setDeclContext(DC);
+
+QualType ConceptTType = Context.getTypeDeclType(ConceptTTPD);
+
+// this is the 2nd template argument node, on which
+// the concept constraint is actually being applied: 'element_type'
+TemplateArgument ConceptTA = TemplateArgument(ConceptTType);
+
+QualType CSETType = Context.getTypeDeclType(T);
+
+// this is the 1st template argume

[clang] [compiler-rt] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

2024-11-20 Thread Trevor Gross via cfe-commits


@@ -255,4 +255,9 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
 }
 setLibcallName(RTLIB::MULO_I128, nullptr);
   }
+
+  if (TT.isSystemZ()) {
+setLibcallName(RTLIB::FPROUND_F32_F16, "__truncsfhf2");
+setLibcallName(RTLIB::FPEXT_F16_F32, "__extendhfsf2");
+  }

tgross35 wrote:

Regarding how to build and link, they are in compiler-rt if that can be built 
https://github.com/llvm/llvm-project/blob/fa22100d57631bbb0a507dd27e3ebb24b1354623/compiler-rt/lib/builtins/truncsfhf2.c#L15.
 `__trunc` and `__extend` are what you want to emit here, I'm just not sure 
what exactly this file needs to do because it seems like `HasLegalHalfType` 
controls `__extend`/`__trunc` vs. `__gnu_` lowering somehow 
https://github.com/llvm/llvm-project/pull/109164#issuecomment-2433525551.

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


[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)

2024-11-20 Thread Jeremy Morse via cfe-commits

https://github.com/jmorse commented:

Behold, I've added a bunch of pedantic comments about the tests.

I think a significant matter is that they all run an LLVM optimisation 
pipeline, which I believe means they cover too much of the project to be 
"clang" tests, they're more end-to-end or cross project tests. Potentially we 
can move them there; it's more preferable to test for the exact output of clang 
without the optimisation passes instead though.

(If there's optimisation behaviour that does need testing, it should be part of 
the relevant LLVM pass).

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


[clang] Reland [Clang] skip default argument instantiation for non-defining friend declarations to meet [dcl.fct.default] p4 (PR #115487)

2024-11-20 Thread Younan Zhang via cfe-commits

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


[clang] Reland [Clang] skip default argument instantiation for non-defining friend declarations to meet [dcl.fct.default] p4 (PR #115487)

2024-11-20 Thread Younan Zhang via cfe-commits

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

LGTM modulo 1 nit.
@mizvekov are you happy with it?

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


[clang] Reland [Clang] skip default argument instantiation for non-defining friend declarations to meet [dcl.fct.default] p4 (PR #115487)

2024-11-20 Thread Younan Zhang via cfe-commits


@@ -185,3 +185,46 @@ template struct S {
   friend void X::f(T::type);
 };
 }
+
+namespace GH113324 {
+template  struct S1 {
+  friend void f1(S1, int = 0); // expected-error {{friend declaration 
specifying a default argument must be a definition}}
+  friend void f2(S1 a, S1 = decltype(a){}); // expected-error {{friend 
declaration specifying a default argument must be a definition}}
+};
+
+template  using alias = int;
+template  struct S2 {
+  // FIXME: We miss diagnosing the default argument instantiation failure
+  // (forming reference to void)
+  friend void f3(S2, int a = alias(1)); // expected-error {{friend 
declaration specifying a default argument must be a definition}}
+};
+
+struct S3 {
+  friend void f4(S3, int = 42) { }
+};

zyn0217 wrote:

Does the regression fail within `fsyntax-only` mode previously? I remembered 
those reports were related to codegen parts, so you might need to move the case 
to e.g. `test/CodeGenCXX/default-arguments.cpp`.

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


[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)

2024-11-20 Thread Jeremy Morse via cfe-commits


@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -O1 -emit-llvm 
-fextend-lifetimes -o - | FileCheck %s
+// Make sure we don't crash compiling a lambda that is not nested in a 
function.
+// We also check that fake uses are properly issued in lambdas.
+
+int glob;
+
+extern int foo();
+
+struct S {
+  static const int a;
+};
+
+const int S::a = [](int b) __attribute__((noinline)) {
+  return b * foo();
+}
+(glob);
+
+int func(int param) {
+  return ([=](int lambdaparm) __attribute__((noinline))->int {
+int lambdalocal = lambdaparm * 2;
+return lambdalocal;
+  }(glob));
+}
+
+// We are looking for the first lambda's call operator, which should contain
+// 2 fake uses, one for 'b' and one for its 'this' pointer (in that order).
+// The mangled function name contains a $_0, followed by 'cl'.
+// This lambda is an orphaned lambda, i.e. one without lexical parent.
+//
+// CHECK: define internal {{.+\"_Z.+\$_0.*cl.*\"}}

jmorse wrote:

CHECK-LABEL, and for the other define below?

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


[clang] [CUDA] pass -fno-threadsafe-statics to GPU sub-compilations. (PR #117074)

2024-11-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Artem Belevich (Artem-B)


Changes

We do not have support for the threadsafe statics on the GPU side.

However, we do sometimes end up with empty local static initializers, and those 
happen to trigger calls to `__cxa_guard*`, which breaks compilation.

Partially addresses https://github.com/llvm/llvm-project/issues/117023

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Cuda.cpp (+3-2) 
- (added) clang/test/Driver/cuda-no-threadsafe-statics.cu (+10) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index ddd5ea248ca0cc..102794829795da 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -856,8 +856,9 @@ void CudaToolChain::addClangTargetOptions(
   DeviceOffloadingKind == Action::OFK_Cuda) &&
  "Only OpenMP or CUDA offloading kinds are supported for NVIDIA 
GPUs.");
 
-  CC1Args.append(
-  {"-fcuda-is-device", "-mllvm", "-enable-memcpyopt-without-libcalls"});
+  CC1Args.append({"-fcuda-is-device", "-mllvm",
+  "-enable-memcpyopt-without-libcalls",
+  "-fno-threadsafe-statics"});
 
   // Unsized function arguments used for variadics were introduced in CUDA-9.0
   // We still do not support generating code that actually uses variadic
diff --git a/clang/test/Driver/cuda-no-threadsafe-statics.cu 
b/clang/test/Driver/cuda-no-threadsafe-statics.cu
new file mode 100644
index 00..fd0465f175846d
--- /dev/null
+++ b/clang/test/Driver/cuda-no-threadsafe-statics.cu
@@ -0,0 +1,10 @@
+// Check that -fno-thread-safe-statics get passed down to device-side
+// compilation only.
+//
+// RUN: not %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s 
2>&1 \
+// RUN:   | FileCheck %s
+//
+// CHECK: "-fcuda-is-device"
+// CHECK-SAME: "-fno-threadsafe-statics"
+// CHECK: "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-NOT: "-fno-threadsafe-statics"

``




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


[clang] [CUDA] pass -fno-threadsafe-statics to GPU sub-compilations. (PR #117074)

2024-11-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Artem Belevich (Artem-B)


Changes

We do not have support for the threadsafe statics on the GPU side.

However, we do sometimes end up with empty local static initializers, and those 
happen to trigger calls to `__cxa_guard*`, which breaks compilation.

Partially addresses https://github.com/llvm/llvm-project/issues/117023

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Cuda.cpp (+3-2) 
- (added) clang/test/Driver/cuda-no-threadsafe-statics.cu (+10) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index ddd5ea248ca0cc..102794829795da 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -856,8 +856,9 @@ void CudaToolChain::addClangTargetOptions(
   DeviceOffloadingKind == Action::OFK_Cuda) &&
  "Only OpenMP or CUDA offloading kinds are supported for NVIDIA 
GPUs.");
 
-  CC1Args.append(
-  {"-fcuda-is-device", "-mllvm", "-enable-memcpyopt-without-libcalls"});
+  CC1Args.append({"-fcuda-is-device", "-mllvm",
+  "-enable-memcpyopt-without-libcalls",
+  "-fno-threadsafe-statics"});
 
   // Unsized function arguments used for variadics were introduced in CUDA-9.0
   // We still do not support generating code that actually uses variadic
diff --git a/clang/test/Driver/cuda-no-threadsafe-statics.cu 
b/clang/test/Driver/cuda-no-threadsafe-statics.cu
new file mode 100644
index 00..fd0465f175846d
--- /dev/null
+++ b/clang/test/Driver/cuda-no-threadsafe-statics.cu
@@ -0,0 +1,10 @@
+// Check that -fno-thread-safe-statics get passed down to device-side
+// compilation only.
+//
+// RUN: not %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s 
2>&1 \
+// RUN:   | FileCheck %s
+//
+// CHECK: "-fcuda-is-device"
+// CHECK-SAME: "-fno-threadsafe-statics"
+// CHECK: "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-NOT: "-fno-threadsafe-statics"

``




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


[clang] [CUDA] pass -fno-threadsafe-statics to GPU sub-compilations. (PR #117074)

2024-11-20 Thread Artem Belevich via cfe-commits

Artem-B wrote:

@yxsamliu -- should I add it for HIP, too?

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-11-20 Thread via cfe-commits


@@ -2302,6 +2302,10 @@ def err_init_list_bad_dest_type : Error<
 def warn_cxx20_compat_aggregate_init_with_ctors : Warning<
   "aggregate initialization of type %0 with user-declared constructors "
   "is incompatible with C++20">, DefaultIgnore, InGroup;
+def warn_cxx20_compat_requires_explicit_init_non_aggregate : Warning<
+  "explicit initialization of field %0 may not be enforced in C++20 as type %1 
"
+  "will become a non-aggregate due to the presence of user-declared "
+  "constructors">, DefaultIgnore, InGroup;

higher-performance wrote:

It seems strictly like a compatibility warning to me -- because it isn't 
relevant for someone who _doesn't_ want to support later versions of the 
standard. I'd prefer to keep it that way if possible.

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-11-20 Thread via cfe-commits


@@ -551,3 +551,14 @@ struct full_of_empty empty_test_2(void) {
   struct full_of_empty e;
   return e; // no-warning
 }
+
+struct with_explicit_field {

higher-performance wrote:

Done.

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-11-20 Thread via cfe-commits


@@ -1419,6 +1419,42 @@ is not specified.
   }];
 }
 
+def ExplicitInitDocs : Documentation {
+  let Category = DocCatField;
+  let Content = [{
+The ``clang::requires_explicit_initialization`` attribute indicates that the
+field of an aggregate must be initialized explicitly by users when the class
+is constructed. Its usage is invalid on non-aggregates.
+
+Note that this attribute is *not* a memory safety feature, and is *not* 
intended
+to guard against use of uninitialized memory.
+
+Rather, it is intended for use in "parameter-objects", used to simulate the
+passing of named parameters.
+The attribute generates a warning when explicit initializers for such
+"named parameters" are not provided:

higher-performance wrote:

Done.

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-11-20 Thread via cfe-commits


@@ -6919,6 +6923,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
   case ParsedAttr::AT_NoMerge:
 handleNoMergeAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_ExplicitInit:
+handleExplicitInitAttr(S, D, AL);

higher-performance wrote:

Done.

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


[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Daniel Stone via cfe-commits

fooishbar wrote:

cc @karolherbst @airlied who are better contacts for CL in Mesa these days

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


[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Matt Arsenault via cfe-commits

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


[clang] [Clang/AMDGPU] Zero sized arrays not allowed in HIP device code. (PR #113470)

2024-11-20 Thread Eli Friedman via cfe-commits

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

LGTM

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


[clang] [Clang] skip warnings for constructors marked with the [[noreturn]] attribute (PR #115558)

2024-11-20 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/115558

>From f63263a1aa4873a63918649ea92352eb5cfe66eb Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sat, 9 Nov 2024 00:41:13 +0200
Subject: [PATCH 1/3] [Clang] skip warnings for constructors marked with the
 [[noreturn]] attribute

---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/lib/Analysis/CFG.cpp| 15 ++-
 .../CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp | 12 
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c3424e0e6f34c9..11d0e35d12a786 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -527,6 +527,8 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables 
(#GH90073).
 
+- Clang now omits warnings for constructors marked with the ``[[noreturn]]`` 
attribute (#GH63009).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index f678ac6f2ff36a..4d83f04c23060a 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -4889,16 +4889,21 @@ CFGBlock 
*CFGBuilder::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E,
   return Visit(E->getSubExpr(), asc);
 }
 
-CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C,
+CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E,
   AddStmtChoice asc) {
   // If the constructor takes objects as arguments by value, we need to 
properly
   // construct these objects. Construction contexts we find here aren't for the
   // constructor C, they're for its arguments only.
-  findConstructionContextsForArguments(C);
+  findConstructionContextsForArguments(E);
 
-  autoCreateBlock();
-  appendConstructor(Block, C);
-  return VisitChildren(C);
+  CXXConstructorDecl *C = E->getConstructor();
+  if (C && C->isNoReturn())
+Block = createNoReturnBlock();
+  else
+autoCreateBlock();
+
+  appendConstructor(Block, E);
+  return VisitChildren(E);
 }
 
 CFGBlock *CFGBuilder::VisitImplicitCastExpr(ImplicitCastExpr *E,
diff --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
index 56920ea8e8cf20..a96224dd03e360 100644
--- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
@@ -49,3 +49,15 @@ void check() {
   test_type(g);
   test_type(h); // expected-note {{instantiation}}
 }
+
+namespace GH63009 {
+struct S {
+  [[noreturn]] S() { throw int {}; }
+};
+
+int test_no_return_constructor() { S(); } // ok
+
+int main() {
+  test_no_return_constructor();
+}
+}

>From 99582e7e30048b07dba57d0c284acf209f53b83e Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Thu, 21 Nov 2024 01:25:43 +0200
Subject: [PATCH 2/3] suppress warnings for constructor expressions with the
 [[noreturn]] attribute

---
 clang/lib/Analysis/CFG.cpp| 16 --
 .../dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp | 11 +++---
 clang/test/SemaCXX/warn-missing-noreturn.cpp  | 22 +++
 3 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 4d83f04c23060a..35cf8c49bd27eb 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -760,6 +760,12 @@ class CFGBuilder {
   void cleanupConstructionContext(Expr *E);
 
   void autoCreateBlock() { if (!Block) Block = createBlock(); }
+  void createConstructorBlock(CXXConstructorDecl *C) {
+if (C && C->isNoReturn())
+  Block = createNoReturnBlock();
+else
+  autoCreateBlock();
+  };
   CFGBlock *createBlock(bool add_successor = true);
   CFGBlock *createNoReturnBlock();
 
@@ -4830,7 +4836,7 @@ CFGBlock 
*CFGBuilder::VisitCXXConstructExpr(CXXConstructExpr *C,
   // constructor C, they're for its arguments only.
   findConstructionContextsForArguments(C);
 
-  autoCreateBlock();
+  createConstructorBlock(C->getConstructor());
   appendConstructor(Block, C);
 
   return VisitChildren(C);
@@ -4896,13 +4902,9 @@ CFGBlock 
*CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E,
   // constructor C, they're for its arguments only.
   findConstructionContextsForArguments(E);
 
-  CXXConstructorDecl *C = E->getConstructor();
-  if (C && C->isNoReturn())
-Block = createNoReturnBlock();
-  else
-autoCreateBlock();
-
+  createConstructorBlock(E->getConstructor());
   appendConstructor(Block, E);
+
   return VisitChildren(E);
 }
 
diff --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
index a96224dd03e360..afcb133e48a1a8 100644
--- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
+++ b/clan

[clang] Add support for aligning BlockComments in declarations (PR #109497)

2024-11-20 Thread via cfe-commits

https://github.com/JessehMSFT updated 
https://github.com/llvm/llvm-project/pull/109497

>From 38333491868dfad9c84719d9dd8fd872a2aa7584 Mon Sep 17 00:00:00 2001
From: Jesse Harvey 
Date: Fri, 20 Sep 2024 16:40:35 -0700
Subject: [PATCH 1/3] Add support for aligning BlockComments in declarations

---
 clang/include/clang/Format/Format.h| 25 +++-
 clang/lib/Format/Format.cpp| 22 ---
 clang/lib/Format/WhitespaceManager.cpp | 11 +++-
 clang/unittests/Format/ConfigParseTest.cpp | 73 +++---
 clang/unittests/Format/FormatTest.cpp  | 49 ++-
 5 files changed, 134 insertions(+), 46 deletions(-)

diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index d8b62c7652a0f6..f7b6bfffd61314 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -260,12 +260,35 @@ struct FormatStyle {
 ///   bbb >>= 2;
 /// \endcode
 bool PadOperators;
+/// Only for ``AlignConsecutiveDeclarations``.  Whether block comments
+/// are aligned in declarations.
+/// \code
+///   true:
+///   someLongFunction(int/*a*/,
+///bool   b,
+///const std::string& c)
+///
+///   const bool ret = someLongFunction(4/*a*/,
+/// true /*b*/,
+/// str  /*c*/);
+///
+///   false:
+///   someLongFunction(int /*a*/,
+///bool b,
+///const std::string& c)
+///
+///   const bool ret = someLongFunction(4 /*a*/,
+/// true /*b*/,
+/// str /*c*/);
+/// \endcode
+bool AlignBlockComments;
 bool operator==(const AlignConsecutiveStyle &R) const {
   return Enabled == R.Enabled && AcrossEmptyLines == R.AcrossEmptyLines &&
  AcrossComments == R.AcrossComments &&
  AlignCompound == R.AlignCompound &&
  AlignFunctionPointers == R.AlignFunctionPointers &&
- PadOperators == R.PadOperators;
+ PadOperators == R.PadOperators &&
+ AlignBlockComments == R.AlignBlockComments;
 }
 bool operator!=(const AlignConsecutiveStyle &R) const {
   return !(*this == R);
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d2463b892fbb96..ab8eadd0171aa6 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -48,39 +48,46 @@ template <> struct 
MappingTraits {
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/false, /*AcrossEmptyLines=*/false,
  /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "Consecutive",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/false,
  /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "AcrossEmptyLines",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/true,
  /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "AcrossComments",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/false,
  /*AcrossComments=*/true, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "AcrossEmptyLinesAndComments",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/true,
  /*AcrossComments=*/true, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 
 // For backward compatibility.
 IO.enumCase(Value, "true",
 FormatStyle::AlignConsecutiveStyle(

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-11-20 Thread Aaron Ballman via cfe-commits


@@ -1419,6 +1419,42 @@ is not specified.
   }];
 }
 
+def ExplicitInitDocs : Documentation {
+  let Category = DocCatField;
+  let Content = [{
+The ``clang::requires_explicit_initialization`` attribute indicates that the
+field of an aggregate must be initialized explicitly by users when the class
+is constructed. Its usage is invalid on non-aggregates.
+
+Note that this attribute is *not* a memory safety feature, and is *not* 
intended
+to guard against use of uninitialized memory.
+
+Rather, it is intended for use in "parameter-objects", used to simulate the
+passing of named parameters.
+The attribute generates a warning when explicit initializers for such
+"named parameters" are not provided:

AaronBallman wrote:

I think a few things may be missing here.

1) This implies to me that using initialization other than a designated 
initializer which names the field are not supported, so it might be useful to 
show a field initialized via position as part of the example to make it clear 
that the field has to be initialized, it doesn't have to be named in the 
initializer explicitly.
2) The phrasing is pretty C++ specific so perhaps this should mention C support.
3) You should mention what happens if the attribute is written on a field with 
an in-class initializer and there is no explicit initialization of that field.

WDYT?

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


[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits

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


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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-11-20 Thread via cfe-commits


@@ -1419,6 +1419,42 @@ is not specified.
   }];
 }
 
+def ExplicitInitDocs : Documentation {
+  let Category = DocCatField;
+  let Content = [{
+The ``clang::requires_explicit_initialization`` attribute indicates that the
+field of an aggregate must be initialized explicitly by users when the class
+is constructed. Its usage is invalid on non-aggregates.
+
+Note that this attribute is *not* a memory safety feature, and is *not* 
intended
+to guard against use of uninitialized memory.
+
+Rather, it is intended for use in "parameter-objects", used to simulate the
+passing of named parameters.
+The attribute generates a warning when explicit initializers for such
+"named parameters" are not provided:
+
+.. code-block:: c++
+
+  struct ArrayIOParams {
+size_t count [[clang::requires_explicit_initialization]];
+size_t element_size [[clang::requires_explicit_initialization]];
+int flags = 0;
+  };
+
+  size_t ReadArray(FILE *file, void *buffer, ArrayIOParams params);
+
+  int main() {
+unsigned int buf[512];
+ReadArray(stdin, buf, {
+  .count = sizeof(buf) / sizeof(*buf),
+  // warning: field 'element_size' is not explicitly initialized

higher-performance wrote:

Done.

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-11-20 Thread via cfe-commits


@@ -,6 +1116,10 @@ void CXXRecordDecl::addedMember(Decl *D) {
 } else if (!T.isCXX98PODType(Context))
   data().PlainOldData = false;
 
+if (Field->hasAttr() && !Field->hasInClassInitializer()) 
{
+  setHasUninitializedExplicitInitFields(true);
+}

higher-performance wrote:

Oh wow, done -- thanks for the catch, looks like this slipped through. I 
thought I had a test for this, but it seems like the test didn't catch it 
because there was _also_ an explicit field that _didn't_ have an in-class 
initializer, so the flag was set anyway. I modified another one of the tests to 
account for this too.

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


[clang] [clang] Add support for `__declspec(no_init_all)` (PR #116847)

2024-11-20 Thread Eli Friedman via cfe-commits

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

LGTM

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


[clang] [Webkit Checkers] Introduce a Webkit checker for memory unsafe casts (PR #114606)

2024-11-20 Thread Rashmi Mudduluru via cfe-commits

https://github.com/t-rasmud updated 
https://github.com/llvm/llvm-project/pull/114606

>From cc19550fdbaca4b77e90de57c472a31a8c3f8293 Mon Sep 17 00:00:00 2001
From: Rashmi Mudduluru 
Date: Fri, 1 Nov 2024 14:10:50 -0700
Subject: [PATCH 1/7] [Webkit Checkers] Introduce a Webkit checker for memory
 unsafe casts

The checker warns all downcasts from a base type to a derived type.

rdar://137766829
---
 clang/docs/analyzer/checkers.rst  |  25 +++
 clang/docs/tools/clang-formatted-files.txt|   1 +
 .../clang/StaticAnalyzer/Checkers/Checkers.td |   4 +
 .../StaticAnalyzer/Checkers/CMakeLists.txt|   1 +
 .../WebKit/MemoryUnsafeCastChecker.cpp|  86 ++
 .../Checkers/WebKit/memory-unsafe-cast.cpp| 151 ++
 .../Checkers/WebKit/memory-unsafe-cast.mm |  29 
 7 files changed, 297 insertions(+)
 create mode 100644 
clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp
 create mode 100644 clang/test/Analysis/Checkers/WebKit/memory-unsafe-cast.cpp
 create mode 100644 clang/test/Analysis/Checkers/WebKit/memory-unsafe-cast.mm

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 87b03438e6e0b9..f01755ce7a236a 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -3452,6 +3452,31 @@ alpha.WebKit
 
 .. _alpha-webkit-NoUncheckedPtrMemberChecker:
 
+alpha.webkit.MemoryUnsafeCastChecker
+""
+Check for all casts from a base type to its derived type as these might be 
memory-unsafe.
+
+Example:
+
+.. code-block:: cpp
+
+class Base { };
+class Derived : public Base { };
+
+void f(Base* base) {
+Derived* derived = static_cast(base); // ERROR
+}
+
+For all cast operations (C-style casts, static_cast, reinterpret_cast, 
dynamic_cast), if the source type a `Base*` and the destination type is 
`Derived*`, where `Derived` inherits from `Base`, the static analyzer should 
signal an error.
+
+This applies to:
+
+- C structs, C++ structs and classes, and Objective-C classes and protocols.
+- Pointers and references.
+- Inside template instantiations and macro expansions that are visible to the 
compiler.
+
+For types like this, instead of using built in casts, the programmer will use 
helper functions that internally perform the appropriate type check and disable 
static analysis.
+
 alpha.webkit.NoUncheckedPtrMemberChecker
 
 Raw pointers and references to an object which supports CheckedPtr or 
CheckedRef can't be used as class members. Only CheckedPtr, CheckedRef, RefPtr, 
or Ref are allowed.
diff --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 67ff085144f4de..74ab155d6174fd 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -537,6 +537,7 @@ 
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
 clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
 clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
 clang/lib/StaticAnalyzer/Checkers/WebKit/DiagOutputUtils.h
+clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp
 clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
 clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
 clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 9a6b35c1b9f774..445379e88ab9e3 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1752,6 +1752,10 @@ def UncountedLambdaCapturesChecker : 
Checker<"UncountedLambdaCapturesChecker">,
 
 let ParentPackage = WebKitAlpha in {
 
+def MemoryUnsafeCastChecker : Checker<"MemoryUnsafeCastChecker">,
+  HelpText<"Check for memory unsafe casts from base type to derived type.">,
+  Documentation;
+
 def NoUncheckedPtrMemberChecker : Checker<"NoUncheckedPtrMemberChecker">,
   HelpText<"Check for no unchecked member variables.">,
   Documentation;
diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 62aa5ff7f002a9..7e987740f9ee2d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -132,6 +132,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   VirtualCallChecker.cpp
   WebKit/RawPtrRefMemberChecker.cpp
   WebKit/ASTUtils.cpp
+  WebKit/MemoryUnsafeCastChecker.cpp
   WebKit/PtrTypesSemantics.cpp
   WebKit/RefCntblBaseVirtualDtorChecker.cpp
   WebKit/UncountedCallArgsChecker.cpp
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/MemoryUnsafeCastChecker.cpp
new file mode 100644
index 00..05a5f89d28c8fe
--- /dev/null
+++ b/clang/lib/StaticAnal

[clang] [ASTMatchers] AST matcher support for ObjC pointers (PR #117021)

2024-11-20 Thread Rashmi Mudduluru via cfe-commits

https://github.com/t-rasmud created 
https://github.com/llvm/llvm-project/pull/117021

Add `ObjCInterfaceDecl` to the list of types supported by the `hasType` and 
`hasDeclaration` matchers, `ObjCObjectPointerType` to the list of types 
supported by `pointee`.

>From 87ba2a10ca7435fdf6b5c47d2c1c97c1e188cfcd Mon Sep 17 00:00:00 2001
From: Rashmi Mudduluru 
Date: Tue, 19 Nov 2024 14:50:24 -0800
Subject: [PATCH] [ASTMatchers] AST matcher support for ObjC pointers

Add `ObjCInterfaceDecl` to the list of types supported by the `hasType` and 
`hasDeclaration` matchers,
`ObjCObjectPointerType` to the list of types supported by `pointee`.
---
 clang/include/clang/ASTMatchers/ASTMatchers.h |  5 +++--
 clang/include/clang/ASTMatchers/ASTMatchersInternal.h | 11 ++-
 clang/lib/ASTMatchers/ASTMatchersInternal.cpp |  2 +-
 .../ASTMatchers/ASTMatchersTraversalTest.cpp  |  7 +++
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 4bcaa953a61af2..dc6d60a1bcd17f 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4033,7 +4033,7 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
 hasType,
 AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl,
-CXXBaseSpecifier),
+CXXBaseSpecifier, ObjCInterfaceDecl),
 internal::Matcher, InnerMatcher, 1) {
   QualType QT = internal::getUnderlyingType(Node);
   if (!QT.isNull())
@@ -7434,7 +7434,8 @@ extern const AstTypeMatcher 
rValueReferenceType;
 AST_TYPELOC_TRAVERSE_MATCHER_DECL(
 pointee, getPointee,
 AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType,
-PointerType, ReferenceType));
+PointerType, ReferenceType,
+ObjCObjectPointerType));
 
 /// Matches typedef types.
 ///
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index ab8b146453e761..2c690275dab71f 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -161,6 +161,9 @@ inline QualType getUnderlyingType(const FriendDecl &Node) {
 inline QualType getUnderlyingType(const CXXBaseSpecifier &Node) {
   return Node.getType();
 }
+inline QualType getUnderlyingType(const ObjCInterfaceDecl &Node) {
+  return Node.getTypeForDecl()->getPointeeType();
+}
 
 /// Unifies obtaining a `TypeSourceInfo` from different node types.
 template  
{
 return matchesDecl(Node.getDecl(), Finder, Builder);
   }
 
+  bool matchesSpecialized(const ObjCInterfaceDecl &Node,
+  ASTMatchFinder *Finder,
+  BoundNodesTreeBuilder *Builder) const {
+return matchesDecl(Node.getCanonicalDecl(), Finder, Builder);
+  }
+
   /// Extracts the operator new of the new call and returns whether the
   /// inner matcher matches on it.
   bool matchesSpecialized(const CXXNewExpr &Node,
@@ -1213,7 +1222,7 @@ using HasDeclarationSupportedTypes =
  ElaboratedType, InjectedClassNameType, LabelStmt, AddrLabelExpr,
  MemberExpr, QualType, RecordType, TagType,
  TemplateSpecializationType, TemplateTypeParmType, TypedefType,
- UnresolvedUsingType, ObjCIvarRefExpr>;
+ UnresolvedUsingType, ObjCIvarRefExpr, ObjCInterfaceDecl>;
 
 /// A Matcher that allows binding the node it matches to an id.
 ///
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 46dd44e6f2b24f..8def98ff6dc328 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -1097,7 +1097,7 @@ AST_TYPELOC_TRAVERSE_MATCHER_DEF(hasValueType,
 AST_TYPELOC_TRAVERSE_MATCHER_DEF(
 pointee,
 AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType,
-PointerType, ReferenceType));
+PointerType, ReferenceType, 
ObjCObjectPointerType));
 
 const internal::VariadicDynCastAllOfMatcher
 ompExecutableDirective;
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index 1d18869a6b8afc..adf8749a642fc3 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -283,6 +283,13 @@ TEST(HasDeclaration, HasDeclarationOfTypeAlias) {
   hasDeclaration(typeAliasTemplateDecl();
 }
 
+TEST(HasDeclaration, HasDeclarationOfObjCInterface) {
+  EXPECT_TRUE(matchesObjC(
+  "@interface BaseClass @end void f() {BaseClass* b;}",
+  varDecl(hasType(objcObjectPointerTyp

[clang] 53a6a11 - [LLVM][NFC] Use `used`'s element type if available (#116804)

2024-11-20 Thread via cfe-commits

Author: Alex Voicu
Date: 2024-11-20T23:57:55Z
New Revision: 53a6a11e0d51229d341b8906252645cd8a5de796

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

LOG: [LLVM][NFC] Use `used`'s element type if available (#116804)

When embedding, if `compiler.used` exists, we should re-use it's element
type instead of blindly assuming it's an unqualified pointer.

Added: 
clang/test/CodeGen/embed-bitcode-marker-with-nonzero-as.c

Modified: 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Removed: 




diff  --git a/clang/test/CodeGen/embed-bitcode-marker-with-nonzero-as.c 
b/clang/test/CodeGen/embed-bitcode-marker-with-nonzero-as.c
new file mode 100644
index 00..df7118859c7640
--- /dev/null
+++ b/clang/test/CodeGen/embed-bitcode-marker-with-nonzero-as.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple spirv64-amd-amdhsa -emit-llvm -fcuda-is-device 
-fembed-bitcode=marker -x hip %s -o - \
+// RUN:   | FileCheck %s --check-prefix=CHECK
+
+// CHECK: @llvm.embedded.module = private addrspace(1) constant [0 x i8] 
zeroinitializer, section ".llvmbc", align 1
+// CHECK-NEXT: @llvm.cmdline = private addrspace(1) constant [{{[0-9]+}} x i8] 
c"{{.*}}", section ".llvmcmd", align 1
+// CHECK-NEXT: @llvm.compiler.used = appending addrspace(1) global [5 x ptr 
addrspace(4)] [ptr addrspace(4) addrspacecast (ptr addrspace(1) @foo.managed to 
ptr addrspace(4)), ptr addrspace(4) addrspacecast (ptr addrspace(1) @foo to ptr 
addrspace(4)), ptr addrspace(4) addrspacecast (ptr addrspace(1) @__hip_cuid_ to 
ptr addrspace(4)), ptr addrspace(4) addrspacecast (ptr addrspace(1) 
@llvm.embedded.module to ptr addrspace(4)), ptr addrspace(4) addrspacecast (ptr 
addrspace(1) @llvm.cmdline to ptr addrspace(4))], section "llvm.metadata"
+
+__attribute__((managed)) int foo = 42;

diff  --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp 
b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 24a4c2e8303d5a..80e12bef502ace 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -5501,8 +5501,9 @@ void llvm::embedBitcodeInModule(llvm::Module &M, 
llvm::MemoryBufferRef Buf,
   // Save llvm.compiler.used and remove it.
   SmallVector UsedArray;
   SmallVector UsedGlobals;
-  Type *UsedElementType = PointerType::getUnqual(M.getContext());
   GlobalVariable *Used = collectUsedGlobalVariables(M, UsedGlobals, true);
+  Type *UsedElementType = Used ? Used->getValueType()->getArrayElementType()
+   : PointerType::getUnqual(M.getContext());
   for (auto *GV : UsedGlobals) {
 if (GV->getName() != "llvm.embedded.module" &&
 GV->getName() != "llvm.cmdline")



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


[clang] [llvm] [LLVM][NFC] Use `used`'s element type if available (PR #116804)

2024-11-20 Thread Alex Voicu via cfe-commits

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


[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2024-11-20 Thread Campbell Barton via cfe-commits

ideasman42 wrote:

> I don't disagree these are all potential pitfalls (and there are certainly 
> more), I just don't see how having the diff code in a separate project 
> ameliorates any of them. And as stated earlier, I think it in fact 
> complicates them.

>From a user perspective it likely just means one extra package,possibly 
>setting a configuration value.
In a sense this PR is incomplete in that it only supports git/diff on Unix like 
systems.

We could consider a change to the PR that makes it less implementation spesific:

Use `vc-diff` to generate the diff - this abstracts away all the details of 
calling git or diff directly, personally I would still rather keep the 
functionality separate - then this can be easily integrated with `hl-diff` or 
other packages that already track changed lines, removing the overhead of the 
current method used.



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


[clang] Reland [Clang] skip default argument instantiation for non-defining friend declarations to meet [dcl.fct.default] p4 (PR #115487)

2024-11-20 Thread Younan Zhang via cfe-commits

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


[clang] [clang][UBSan] Make sure that the implicit-conversion group is compatible with minimal runtime (PR #114865)

2024-11-20 Thread Richard Smith via cfe-commits

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


[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2024-11-20 Thread Ashley Coleman via cfe-commits


@@ -17,12 +17,10 @@ double test_int_builtin(double p0) {
 
 double2 test_int_builtin_2(double2 p0) {
   return __builtin_hlsl_elementwise_firstbithigh(p0);
-  // expected-error@-1 {{1st argument must be a vector of integers
-  // (was 'double2' (aka 'vector'))}}
+  // expected-error@-1 {{1st argument must be a vector of integers (was 
'double2' (aka 'vector'))}}
 }
 
 float test_int_builtin_3(float p0) {
   return __builtin_hlsl_elementwise_firstbithigh(p0);
-  // expected-error@-1 {{1st argument must be a vector of integers
-  // (was 'float')}}
+  // expected-error@-1 {{1st argument must be a vector of integers (was 
'double')}}

V-FEXrt wrote:

The test framework doesn't actually assert these lines when split. I had to 
unsplit them which raised a test failure that was then fixed

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


[clang] f710e4c - Clarify use of contractions in diagnostic messages (#116803)

2024-11-20 Thread via cfe-commits

Author: Aaron Ballman
Date: 2024-11-20T08:33:05-05:00
New Revision: f710e4c0219c97d4726742b294446b833e604819

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

LOG: Clarify use of contractions in diagnostic messages (#116803)

This dissuades contributors from using contractions when writing
diagnostic wording for Clang. Contractions should be avoided because of
the potential for visual confusion with single quoting syntactic
constructs and because they can be harder to understand for non-native
English speakers.

Added: 


Modified: 
clang/docs/InternalsManual.rst

Removed: 




diff  --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index f189cb4e6a2ac3..39d389b816f129 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -160,6 +160,10 @@ wording a diagnostic.
   named in a diagnostic message. e.g., prefer wording like ``'this' pointer
   cannot be null in well-defined C++ code`` over wording like ``this pointer
   cannot be null in well-defined C++ code``.
+* Prefer diagnostic wording without contractions whenever possible. The single
+  quote in a contraction can be visually distracting due to its use with
+  syntactic constructs and contractions can be harder to understand for non-
+  native English speakers.
 
 The Format String
 ^



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


[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Matt Arsenault via cfe-commits


@@ -322,22 +322,26 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
 if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
   set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
-  set( opt_flags )
+  set( clc_opt_flags )
+  # Inline CLC functions into OpenCL builtins
+  set( opencl_opt_flags "--passes=always-inline" )

arsenm wrote:

Relying on anything libclc doing isn't structurally correct. It sounds like 
what you want is nobuiltin, not forced no-inlining 

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


[clang] [Clang/AMDGPU] Zero sized arrays not allowed in HIP device code. (PR #113470)

2024-11-20 Thread Eli Friedman via cfe-commits

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


[clang] [Clang/AMDGPU] Zero sized arrays not allowed in HIP device code. (PR #113470)

2024-11-20 Thread Eli Friedman via cfe-commits


@@ -8714,6 +8714,21 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
 }
   }
 
+  // zero sized static arrays are not allowed in HIP device functions
+  if (LangOpts.CUDAIsDevice && LangOpts.HIP) {
+if (FunctionDecl *FD = getCurFunctionDecl();
+FD &&
+(FD->hasAttr() || FD->hasAttr())) {

efriedma-quic wrote:

In that case, I guess the current version is fine.

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


[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Matt Arsenault via cfe-commits

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


[clang] [clang] Add support for `__declspec(no_init_all)` (PR #116847)

2024-11-20 Thread Eli Friedman via cfe-commits

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

LGTM

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


[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,38 @@
+#include 
+#include 
+#include 
+
+#define CLC_SIGN(TYPE, F)  
\
+  _CLC_DEF _CLC_OVERLOAD TYPE __clc_sign(TYPE x) { 
\
+if (__clc_isnan(x)) {  
\
+  return 0.0F; 
\
+}  
\
+if (x > 0.0F) {
\
+  return 1.0F; 
\
+}  
\
+if (x < 0.0F) {
\
+  return -1.0F;
\
+}  
\
+return x; /* -0.0 or +0.0 */   
\

arsenm wrote:

You swapped the operands. 0 is the magnitude in the snippet I posted 

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


[clang] [Clang] skip warnings for constructors marked with the [[noreturn]] attribute (PR #115558)

2024-11-20 Thread Oleksandr T. via cfe-commits


@@ -555,6 +555,8 @@ Improvements to Clang's diagnostics
   getS(); // Now diagnoses "Reason 2", previously diagnoses "Reason 1"
 }
 
+- Clang now omits warnings for constructors marked with the ``[[noreturn]]`` 
attribute (#GH63009).

a-tarasyuk wrote:

@Sirraide thanks. I've updated.

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


[clang] [Clang] skip warnings for constructors marked with the [[noreturn]] attribute (PR #115558)

2024-11-20 Thread Oleksandr T. via cfe-commits


@@ -49,3 +49,15 @@ void check() {
   test_type(g);
   test_type(h); // expected-note {{instantiation}}
 }
+
+namespace GH63009 {
+struct S {
+  [[noreturn]] S() { throw int {}; }
+};
+
+int test_no_return_constructor() { S(); } // ok

a-tarasyuk wrote:

@AaronBallman I've added tests.

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


[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits


@@ -206,12 +206,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type 
*Ty) {
 if (!CodeGenOpts.PointerTBAA)
   return AnyPtr;
 // Compute the depth of the pointer and generate a tag of the form 
"p
-// ".
+// ". Look through pointer and array types to determine the
+// base type.

rjmccall wrote:

Suggestion as a replacement for the comment:

```
// C++ [basic.lval]p11 permits objects to accessed through an l-value
// of similar type. Two types are similar under C++ [conv.qual]p2
// if the decomposition of the types into pointers, member pointers,
// and arrays has the same structure when ignoring cv-qualifiers at
// each level of the decomposition. Meanwhile, C makes T(*)[] and
// T(*)[N] compatible, which would really complicate any attempt to
// distinguish pointers to arrays by their bounds. It's simpler, and
// much easier to explain to users, to simply treat all pointers to
// arrays as pointers to their element type for aliasing purposes.
// So when creating a TBAA tag for a pointer type, we recursively
// ignore both qualifiers and array types when decomposing
// the pointee type. The only meaningful remaining structure is the
// number of pointer types we encountered along the way, so we
// just produce the tag "p ". If we do find a
// member pointer type, for now we just conservatively bail out
// with AnyPtr (below) rather than trying to create a tag that
// honors the similar-type rules while still distinguishing different
// kinds of member pointer.
```

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


[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits


@@ -230,6 +232,11 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type 
*Ty) {
   ->getString();
   TyName = Name;
 } else {
+  // Be conservative if the type a MemberPointerType. Those would require
+  // stripping const-qualifiers inside the type.
+  if (Ty->isMemberPointerType())
+return AnyPtr;

rjmccall wrote:

You know, you were probably right the first time to bail out for all non-record 
types — if we run into a vector type, or an ObjC pointer type, or something 
like that, it'd be better to fall back on AnyPtr.  Please leave a comment 
saying that we're specifically *required* to do this for member pointers until 
we implement the similar-types rule, though.

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


[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits


@@ -206,12 +206,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type 
*Ty) {
 if (!CodeGenOpts.PointerTBAA)
   return AnyPtr;
 // Compute the depth of the pointer and generate a tag of the form 
"p
-// ".
+// ". Look through pointer and array types to determine the
+// base type.
 unsigned PtrDepth = 0;
 do {
   PtrDepth++;
-  Ty = Ty->getPointeeType().getTypePtr();
-} while (Ty->isPointerType());
+  Ty = Ty->isPointerType() ? Ty->getPointeeType().getTypePtr()
+   : Ty->getArrayElementTypeNoTypeQual();

rjmccall wrote:

You can just do `Ty = Ty->getPointeeType()->getBaseElementTypeUnsafe();`.  The 
"unsafety" is just incorrectness about type qualifiers, which we're fine with 
here.

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


[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits


@@ -206,12 +206,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type 
*Ty) {
 if (!CodeGenOpts.PointerTBAA)
   return AnyPtr;
 // Compute the depth of the pointer and generate a tag of the form 
"p
-// ".
+// ". Look through pointer and array types to determine the
+// base type.
 unsigned PtrDepth = 0;
 do {
   PtrDepth++;
-  Ty = Ty->getPointeeType().getTypePtr();
-} while (Ty->isPointerType());
+  Ty = Ty->isPointerType() ? Ty->getPointeeType().getTypePtr()
+   : Ty->getArrayElementTypeNoTypeQual();
+} while (Ty->isPointerType() || Ty->isArrayType());
 Ty = Context.getBaseElementType(QualType(Ty, 0)).getTypePtr();

rjmccall wrote:

You can drop this now.

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


[clang] Add a testcase for riscv64-linux-android triple (PR #116892)

2024-11-20 Thread via cfe-commits

https://github.com/hiraditya updated 
https://github.com/llvm/llvm-project/pull/116892

>From 2974c9d52c45145de1735f79ccaa11b037269083 Mon Sep 17 00:00:00 2001
From: AdityaK 
Date: Tue, 19 Nov 2024 15:54:16 -0800
Subject: [PATCH] Add a testcase for riscv64-linux-android triple

---
 clang/test/Driver/android-ndk-standalone.cpp | 33 ++--
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/clang/test/Driver/android-ndk-standalone.cpp 
b/clang/test/Driver/android-ndk-standalone.cpp
index 2670a6707a96c9..6f2245a71401a8 100644
--- a/clang/test/Driver/android-ndk-standalone.cpp
+++ b/clang/test/Driver/android-ndk-standalone.cpp
@@ -14,7 +14,7 @@
 // CHECK: "-internal-externc-isystem" 
"{{.*}}/sysroot/usr/include/arm-linux-androideabi"
 // CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
-// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK: "{{.*}}ld.lld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb"
 // CHECK-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a"
 // CHECK-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb"
@@ -56,7 +56,7 @@
 // CHECK-STDCXX-NOT: "-internal-isystem" 
"{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
 // CHECK-STDCXX-NOT: "-internal-isystem" 
"{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
 // CHECK-STDCXX: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
-// CHECK-STDCXX: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STDCXX: "{{.*}}ld.lld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb"
 // CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a"
 // CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb"
@@ -87,7 +87,7 @@
 // CHECK-ARMV7: "-internal-externc-isystem" 
"{{.*}}/sysroot/usr/include/arm-linux-androideabi"
 // CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
-// CHECK-ARMV7: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ARMV7: "{{.*}}ld.lld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-ARMV7-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb"
 // CHECK-ARMV7-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb"
 // CHECK-ARMV7-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9"
@@ -140,7 +140,7 @@
 // CHECK-THUMB: "-internal-externc-isystem" 
"{{.*}}/sysroot/usr/include/arm-linux-androideabi"
 // CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
-// CHECK-THUMB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-THUMB: "{{.*}}ld.lld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb"
 // CHECK-THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a"
 // CHECK-THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9"
@@ -174,7 +174,7 @@
 // CHECK-ARMV7THUMB: "-internal-externc-isystem" 
"{{.*}}/sysroot/usr/include/arm-linux-androideabi"
 // CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
-// CHECK-ARMV7THUMB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ARMV7THUMB: "{{.*}}ld.lld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-ARMV7THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb"
 // CHECK-ARMV7THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a"
 // CHECK-ARMV7THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9"
@@ -223,7 +223,7 @@
 // CHECK-AARCH64: "-internal-externc-isystem" 
"{{.*}}/sysroot/usr/include/aarch64-linux-android"
 // CHECK-AARCH64: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-AARCH64: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
-// CHECK-AARCH64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-AARCH64: "{{.*}}ld.lld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-AARCH64: "-L{{.*}}/lib/gcc/aarch64-linux-android/4.9"
 // CHECK-AARCH64: "-L{{.*}}/sysroot/usr/lib/aarch64-linux-android/21"
 // CHECK-AARCH64: "-L{{.*}}/sysroot/usr/lib/aarch64-linux-android"
@@ -239,7 +239,7 @@
 // CHECK-ARM64: "-internal-externc-isystem" 
"{{.*}}/sysroot/usr/include/aarch64-linux-android"
 // CHECK-ARM64: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-ARM64: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
-// CHECK-ARM64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ARM64: "{{.*}}ld.lld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-ARM64: "-L{{.*}}/lib/gcc/aarch64-linux-android/4.9"
 // CHECK-ARM64: "-L{{.*}}/sysroot/usr/lib/aarch64-linux-android/21"
 // CHECK-ARM64: "-L{{.*}}/sysroot/usr/lib/aarch64-linux-

[clang] [lld] [llvm] [WebAssembly] Support the new "Lime1" CPU (PR #112035)

2024-11-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-lld

Author: Dan Gohman (sunfishcode)


Changes

This adds WebAssembly support for the new [Lime1 CPU].

First, this defines some new target features. These are subsets of existing
features that reflect implementation concerns:

 - "call-indirect-overlong" - implied by "reference-types"; just the overlong
   encoding for the `call_indirect` immediate, and not the actual reference
   types.

 - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and
   `memory.fill`, and not the other instructions in the bulk-memory
proposal.

Next, this defines a new target CPU, "lime1", which enables mutable-globals,
bulk-memory-opt, multivalue, sign-ext, nontrapping-fptoint, extended-const,
and call-indirect-overlong. Unlike the default "generic" CPU, "lime1" is meant
to be frozen, and followed up by "lime2" and so on when new features are
desired.

[Lime1 CPU]: 
https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1


---

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


33 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+6) 
- (modified) clang/lib/Basic/Targets/WebAssembly.cpp (+47) 
- (modified) clang/lib/Basic/Targets/WebAssembly.h (+2) 
- (modified) lld/test/wasm/compress-relocs.ll (+1-1) 
- (modified) lld/test/wasm/import-table-explicit.s (+1-1) 
- (modified) lld/test/wasm/invalid-mvp-table-use.s (+1-1) 
- (modified) lld/test/wasm/lto/Inputs/libcall-archive.ll (+1-1) 
- (modified) lld/test/wasm/lto/libcall-archive.ll (+1-1) 
- (modified) lld/test/wasm/lto/stub-library-libcall.s (+2-2) 
- (modified) lld/test/wasm/multi-table.s (+1-1) 
- (modified) lld/wasm/InputFiles.cpp (+6-5) 
- (modified) lld/wasm/SyntheticSections.cpp (+1-1) 
- (modified) llvm/docs/ReleaseNotes.md (+6) 
- (modified) llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp 
(+21-7) 
- (modified) llvm/lib/Target/WebAssembly/WebAssembly.td (+22-6) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td (+4-4) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td (+8) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp (+2-2) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblySubtarget.cpp (+9) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h (+4) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/bulk-memory.ll (+3-3) 
- (modified) llvm/test/CodeGen/WebAssembly/bulk-memory64.ll (+3-3) 
- (modified) llvm/test/CodeGen/WebAssembly/call-indirect.ll (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.ll (+3-3) 
- (modified) llvm/test/CodeGen/WebAssembly/disable-feature.ll (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/function-pointer64.ll (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/target-features-cpus.ll (+47-7) 
- (modified) llvm/test/MC/WebAssembly/extern-functype-intrinsic.ll (+2-2) 
- (modified) llvm/test/MC/WebAssembly/function-alias.ll (+2-2) 
- (modified) llvm/test/MC/WebAssembly/libcall.ll (+1-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 999c88455b64a5..b333251fd08c8d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -854,9 +854,15 @@ and `-mbulk-memory` flags, which correspond to the [Bulk 
Memory Operations]
 and [Non-trapping float-to-int Conversions] language features, which are
 [widely implemented in engines].
 
+A new Lime1 target CPU is added, -mcpu=lime1. This CPU follows the definition 
of
+the Lime1 CPU [here], and enables -mmultivalue, -mmutable-globals,
+-mcall-indirect-overlong, -msign-ext, -mbulk-memory-opt, -mnontrapping-fptoint,
+and -mextended-const.
+
 [Bulk Memory Operations]: 
https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
 [Non-trapping float-to-int Conversions]: 
https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
 [widely implemented in engines]: https://webassembly.org/features/
+[here]: https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1
 
 AVR Support
 ^^^
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 0b380bdf835ffb..1a13cd4070a88d 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -47,6 +47,8 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   return llvm::StringSwitch(Feature)
   .Case("atomics", HasAtomics)
   .Case("bulk-memory", HasBulkMemory)
+  .Case("bulk-memory-opt", HasBulkMemoryOpt)
+  .Case("call-indirect-overlong", HasCallIndirectOverlong)
   .Case("exception-hand

[clang] [lld] [llvm] [WebAssembly] Support the new "Lime1" CPU (PR #112035)

2024-11-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Dan Gohman (sunfishcode)


Changes

This adds WebAssembly support for the new [Lime1 CPU].

First, this defines some new target features. These are subsets of existing
features that reflect implementation concerns:

 - "call-indirect-overlong" - implied by "reference-types"; just the overlong
   encoding for the `call_indirect` immediate, and not the actual reference
   types.

 - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and
   `memory.fill`, and not the other instructions in the bulk-memory
proposal.

Next, this defines a new target CPU, "lime1", which enables mutable-globals,
bulk-memory-opt, multivalue, sign-ext, nontrapping-fptoint, extended-const,
and call-indirect-overlong. Unlike the default "generic" CPU, "lime1" is meant
to be frozen, and followed up by "lime2" and so on when new features are
desired.

[Lime1 CPU]: 
https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1


---

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


33 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+6) 
- (modified) clang/lib/Basic/Targets/WebAssembly.cpp (+47) 
- (modified) clang/lib/Basic/Targets/WebAssembly.h (+2) 
- (modified) lld/test/wasm/compress-relocs.ll (+1-1) 
- (modified) lld/test/wasm/import-table-explicit.s (+1-1) 
- (modified) lld/test/wasm/invalid-mvp-table-use.s (+1-1) 
- (modified) lld/test/wasm/lto/Inputs/libcall-archive.ll (+1-1) 
- (modified) lld/test/wasm/lto/libcall-archive.ll (+1-1) 
- (modified) lld/test/wasm/lto/stub-library-libcall.s (+2-2) 
- (modified) lld/test/wasm/multi-table.s (+1-1) 
- (modified) lld/wasm/InputFiles.cpp (+6-5) 
- (modified) lld/wasm/SyntheticSections.cpp (+1-1) 
- (modified) llvm/docs/ReleaseNotes.md (+6) 
- (modified) llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp 
(+21-7) 
- (modified) llvm/lib/Target/WebAssembly/WebAssembly.td (+22-6) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td (+4-4) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td (+8) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp (+2-2) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblySubtarget.cpp (+9) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h (+4) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/bulk-memory.ll (+3-3) 
- (modified) llvm/test/CodeGen/WebAssembly/bulk-memory64.ll (+3-3) 
- (modified) llvm/test/CodeGen/WebAssembly/call-indirect.ll (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.ll (+3-3) 
- (modified) llvm/test/CodeGen/WebAssembly/disable-feature.ll (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/function-pointer64.ll (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/target-features-cpus.ll (+47-7) 
- (modified) llvm/test/MC/WebAssembly/extern-functype-intrinsic.ll (+2-2) 
- (modified) llvm/test/MC/WebAssembly/function-alias.ll (+2-2) 
- (modified) llvm/test/MC/WebAssembly/libcall.ll (+1-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 999c88455b64a5..b333251fd08c8d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -854,9 +854,15 @@ and `-mbulk-memory` flags, which correspond to the [Bulk 
Memory Operations]
 and [Non-trapping float-to-int Conversions] language features, which are
 [widely implemented in engines].
 
+A new Lime1 target CPU is added, -mcpu=lime1. This CPU follows the definition 
of
+the Lime1 CPU [here], and enables -mmultivalue, -mmutable-globals,
+-mcall-indirect-overlong, -msign-ext, -mbulk-memory-opt, -mnontrapping-fptoint,
+and -mextended-const.
+
 [Bulk Memory Operations]: 
https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
 [Non-trapping float-to-int Conversions]: 
https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
 [widely implemented in engines]: https://webassembly.org/features/
+[here]: https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1
 
 AVR Support
 ^^^
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 0b380bdf835ffb..1a13cd4070a88d 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -47,6 +47,8 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   return llvm::StringSwitch(Feature)
   .Case("atomics", HasAtomics)
   .Case("bulk-memory", HasBulkMemory)
+  .Case("bulk-memory-opt", HasBulkMemoryOpt)
+  .Case("call-indirect-overlong", HasCallIndirectOverlong)
   .Case("exception-ha

[clang] [lld] [llvm] [WebAssembly] Support the new "Lime1" CPU (PR #112035)

2024-11-20 Thread Dan Gohman via cfe-commits

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


[clang] [lld] [llvm] [WebAssembly] Support the new "Lime1" CPU (PR #112035)

2024-11-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-lld-wasm

Author: Dan Gohman (sunfishcode)


Changes

This adds WebAssembly support for the new [Lime1 CPU].

First, this defines some new target features. These are subsets of existing
features that reflect implementation concerns:

 - "call-indirect-overlong" - implied by "reference-types"; just the overlong
   encoding for the `call_indirect` immediate, and not the actual reference
   types.

 - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and
   `memory.fill`, and not the other instructions in the bulk-memory
proposal.

Next, this defines a new target CPU, "lime1", which enables mutable-globals,
bulk-memory-opt, multivalue, sign-ext, nontrapping-fptoint, extended-const,
and call-indirect-overlong. Unlike the default "generic" CPU, "lime1" is meant
to be frozen, and followed up by "lime2" and so on when new features are
desired.

[Lime1 CPU]: 
https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1


---

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


33 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+6) 
- (modified) clang/lib/Basic/Targets/WebAssembly.cpp (+47) 
- (modified) clang/lib/Basic/Targets/WebAssembly.h (+2) 
- (modified) lld/test/wasm/compress-relocs.ll (+1-1) 
- (modified) lld/test/wasm/import-table-explicit.s (+1-1) 
- (modified) lld/test/wasm/invalid-mvp-table-use.s (+1-1) 
- (modified) lld/test/wasm/lto/Inputs/libcall-archive.ll (+1-1) 
- (modified) lld/test/wasm/lto/libcall-archive.ll (+1-1) 
- (modified) lld/test/wasm/lto/stub-library-libcall.s (+2-2) 
- (modified) lld/test/wasm/multi-table.s (+1-1) 
- (modified) lld/wasm/InputFiles.cpp (+6-5) 
- (modified) lld/wasm/SyntheticSections.cpp (+1-1) 
- (modified) llvm/docs/ReleaseNotes.md (+6) 
- (modified) llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp 
(+21-7) 
- (modified) llvm/lib/Target/WebAssembly/WebAssembly.td (+22-6) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td (+4-4) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td (+8) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp (+2-2) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblySubtarget.cpp (+9) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblySubtarget.h (+4) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/bulk-memory.ll (+3-3) 
- (modified) llvm/test/CodeGen/WebAssembly/bulk-memory64.ll (+3-3) 
- (modified) llvm/test/CodeGen/WebAssembly/call-indirect.ll (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.ll (+3-3) 
- (modified) llvm/test/CodeGen/WebAssembly/disable-feature.ll (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/function-pointer64.ll (+2-2) 
- (modified) llvm/test/CodeGen/WebAssembly/target-features-cpus.ll (+47-7) 
- (modified) llvm/test/MC/WebAssembly/extern-functype-intrinsic.ll (+2-2) 
- (modified) llvm/test/MC/WebAssembly/function-alias.ll (+2-2) 
- (modified) llvm/test/MC/WebAssembly/libcall.ll (+1-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 999c88455b64a5..b333251fd08c8d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -854,9 +854,15 @@ and `-mbulk-memory` flags, which correspond to the [Bulk 
Memory Operations]
 and [Non-trapping float-to-int Conversions] language features, which are
 [widely implemented in engines].
 
+A new Lime1 target CPU is added, -mcpu=lime1. This CPU follows the definition 
of
+the Lime1 CPU [here], and enables -mmultivalue, -mmutable-globals,
+-mcall-indirect-overlong, -msign-ext, -mbulk-memory-opt, -mnontrapping-fptoint,
+and -mextended-const.
+
 [Bulk Memory Operations]: 
https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
 [Non-trapping float-to-int Conversions]: 
https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
 [widely implemented in engines]: https://webassembly.org/features/
+[here]: https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1
 
 AVR Support
 ^^^
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 0b380bdf835ffb..1a13cd4070a88d 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -47,6 +47,8 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   return llvm::StringSwitch(Feature)
   .Case("atomics", HasAtomics)
   .Case("bulk-memory", HasBulkMemory)
+  .Case("bulk-memory-opt", HasBulkMemoryOpt)
+  .Case("call-indirect-overlong", HasCallIndirectOverlong)
   .Case("exception

[clang] [lld] [llvm] [WebAssembly] Support the new "Lime1" CPU (PR #112035)

2024-11-20 Thread Sam Clegg via cfe-commits


@@ -854,9 +854,15 @@ and `-mbulk-memory` flags, which correspond to the [Bulk 
Memory Operations]
 and [Non-trapping float-to-int Conversions] language features, which are
 [widely implemented in engines].
 
+A new Lime1 target CPU is added, -mcpu=lime1. This CPU follows the definition 
of
+the Lime1 CPU [here], and enables -mmultivalue, -mmutable-globals,
+-mcall-indirect-overlong, -msign-ext, -mbulk-memory-opt, -mnontrapping-fptoint,

sbc100 wrote:

What is the rationale for including the overlong call indirect here? 

Would it be unreasonable to suggest that we land the two new features in a 
separate PR before landing the new CPU type that uses them?  (Maybe its hard to 
split up and test?)

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


[clang] [rtsan] NFC: Update docs with customizable functions (PR #117086)

2024-11-20 Thread Chris Apple via cfe-commits

https://github.com/cjappl created 
https://github.com/llvm/llvm-project/pull/117086

These functions recently were helpful for a user, so I decided to add them to 
the official docs.

Any feedback on wording or content appreciated as always 

>From 056fa6a787efb0721b30fee6e0bdea9843e303d4 Mon Sep 17 00:00:00 2001
From: Chris Apple 
Date: Wed, 20 Nov 2024 16:46:37 -0800
Subject: [PATCH] [rtsan] NFC: Update docs with customizable functions

---
 clang/docs/RealtimeSanitizer.rst | 38 
 1 file changed, 38 insertions(+)

diff --git a/clang/docs/RealtimeSanitizer.rst b/clang/docs/RealtimeSanitizer.rst
index 193f5217c1a1a1..5431e38fea62ec 100644
--- a/clang/docs/RealtimeSanitizer.rst
+++ b/clang/docs/RealtimeSanitizer.rst
@@ -203,6 +203,44 @@ Some issues with flags can be debugged using the 
``verbosity=$NUM`` flag:
misspelled_flag
...
 
+Additional customization
+
+
+In addition to ``__rtsan_default_options`` outlined above, you can provide 
definitions of other functions that affect how RTSan operates.
+
+To be notified on every error reported by RTsan, provide a definition of 
``__sanitizer_report_error_summary``.
+
+.. code-block:: c
+
+   extern "C" void __sanitizer_report_error_summary(const char *error_summary) 
{
+  fprintf(stderr, "%s %s\n", "In custom handler! ", error_summary);
+  /* do other custom things */
+   }
+
+The error summary will be of the form: 
+
+.. code-block:: console
+
+   SUMMARY: RealtimeSanitizer: unsafe-library-call main.cpp:8 in 
process(std::__1::vector>&)
+
+To register a callback which will be invoked before a RTSan kills the process:
+
+.. code-block:: c
+
+  extern "C" void __sanitizer_set_death_callback(void (*callback)(void));
+
+  void custom_on_die_callback() {
+fprintf(stderr, "In custom handler!")
+/* do other custom things */
+  }
+
+  int main()
+  {
+__sanitizer_set_death_callback(custom_on_die_callback);
+...
+  }
+
+
 Disabling and suppressing
 -
 

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


[clang] c86899d - [clang] Add support for `__declspec(no_init_all)` (#116847)

2024-11-20 Thread via cfe-commits

Author: Daniel Paoliello
Date: 2024-11-20T16:48:30-08:00
New Revision: c86899d2d218e19f5a69d9f97f6ff43abc6c897c

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

LOG: [clang] Add support for `__declspec(no_init_all)` (#116847)

In MSVC, when `/d1initall` is enabled, `__declspec(no_init_all)` can be
applied to a type to suppress auto-initialization for all instances of
that type or to a function to suppress auto-initialization for all
locals within that function.

This change does the same for Clang, except that it applies to the
`-ftrivial-auto-var-init` flag instead.

NOTE: I did not add a Clang-specific spelling for this but would be
happy to make a followup PR if folks are interested in that.

Added: 
clang/test/CodeGenCXX/auto-var-init-attr.cpp

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CGDecl.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 6035a563d5fce7..634253d0032560 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4888,3 +4888,10 @@ def ClspvLibclcBuiltin: InheritableAttr {
   let Documentation = [ClspvLibclcBuiltinDoc];
   let SimpleHandler = 1;
 }
+
+def NoTrivialAutoVarInit: InheritableAttr {
+  let Spellings = [Declspec<"no_init_all">];
+  let Subjects = SubjectList<[Function, Tag]>;
+  let Documentation = [NoTrivialAutoVarInitDocs];
+  let SimpleHandler = 1;
+}

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 94d6d15365cef6..6fb2eb3eb3e663 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -8760,6 +8760,18 @@ Attribute used by `clspv`_ (OpenCL-C to Vulkan SPIR-V 
compiler) to identify func
 }];
 }
 
+def NoTrivialAutoVarInitDocs : Documentation {
+  let Category = DocCatDecl;
+  let Content = [{
+The ``__declspec(no_init_all)`` attribute disables the automatic 
initialization that the
+`-ftrivial-auto-var-init`_ flag would have applied to locals in a marked 
function, or instances of
+a marked type. Note that this attribute has no effect for locals that are 
automatically initialized
+without the `-ftrivial-auto-var-init`_ flag.
+
+.. _`-ftrivial-auto-var-init`: 
ClangCommandLineReference.html#cmdoption-clang-ftrivial-auto-var-init
+}];
+}
+
 def DocCatNonBlockingNonAllocating : DocumentationCategory<"Performance 
Constraint Attributes"> {
   let Content = [{
 The ``nonblocking``, ``blocking``, ``nonallocating`` and ``allocating`` 
attributes can be attached

diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 6e9d28cea28e79..47b21bc9f63f04 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1899,13 +1899,16 @@ void CodeGenFunction::EmitAutoVarInit(const 
AutoVarEmission &emission) {
   const Address Loc =
   locIsByrefHeader ? emission.getObjectAddress(*this) : emission.Addr;
 
+  auto hasNoTrivialAutoVarInitAttr = [&](const Decl *D) {
+return D && D->hasAttr();
+  };
   // Note: constexpr already initializes everything correctly.
   LangOptions::TrivialAutoVarInitKind trivialAutoVarInit =
-  (D.isConstexpr()
+  ((D.isConstexpr() || D.getAttr() ||
+hasNoTrivialAutoVarInitAttr(type->getAsTagDecl()) ||
+hasNoTrivialAutoVarInitAttr(CurFuncDecl))
? LangOptions::TrivialAutoVarInitKind::Uninitialized
-   : (D.getAttr()
-  ? LangOptions::TrivialAutoVarInitKind::Uninitialized
-  : getContext().getLangOpts().getTrivialAutoVarInit()));
+   : getContext().getLangOpts().getTrivialAutoVarInit());
 
   auto initializeWhatIsTechnicallyUninitialized = [&](Address Loc) {
 if (trivialAutoVarInit ==
@@ -1944,13 +1947,13 @@ void CodeGenFunction::EmitAutoVarInit(const 
AutoVarEmission &emission) {
   replaceUndef(CGM, isPattern, constant));
 }
 
-if (constant && D.getType()->isBitIntType() &&
-CGM.getTypes().typeRequiresSplitIntoByteArray(D.getType())) {
+if (constant && type->isBitIntType() &&
+CGM.getTypes().typeRequiresSplitIntoByteArray(type)) {
   // Constants for long _BitInt types are split into individual bytes.
   // Try to fold these back into an integer constant so it can be stored
   // properly.
-  llvm::Type *LoadType = CGM.getTypes().convertTypeForLoadStore(
-  D.getType(), constant->getType());
+  llvm::Type *LoadType =
+  CGM.getTypes().convertTypeForLoadStore(type, constant->getType());
   constant = llvm::ConstantFoldLoadFromConst(
   constant, LoadType, llvm::APInt::getZero(32), CGM.getDataLayout());
 }
@@ -1967,8 +1970,7 @@ void CodeGenFun

[clang] [clang] Add support for `__declspec(no_init_all)` (PR #116847)

2024-11-20 Thread Daniel Paoliello via cfe-commits

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


[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Karol Herbst via cfe-commits


@@ -322,22 +322,26 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
 if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
   set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
-  set( opt_flags )
+  set( clc_opt_flags )
+  # Inline CLC functions into OpenCL builtins
+  set( opencl_opt_flags "--passes=always-inline" )

karolherbst wrote:

An alternative good solution would be to have things like `HAVE_HW_FMA32()` 
compiling to a SPIR-V specialization constant and then we just specialize the 
SPIR-V, but I'm not sure if it's worth the effort.

But of course things here could also be more formalized for libclc compiled to 
a generic SPIR-V binary.

There are many possible paths to make it "proper".

But anyway, I'm not in the mood to discuss this any further with this kind of 
attitude, soo.. have fun.

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


[clang] Add support for aligning BlockComments in declarations (PR #109497)

2024-11-20 Thread via cfe-commits

https://github.com/JessehMSFT updated 
https://github.com/llvm/llvm-project/pull/109497

>From 38333491868dfad9c84719d9dd8fd872a2aa7584 Mon Sep 17 00:00:00 2001
From: Jesse Harvey 
Date: Fri, 20 Sep 2024 16:40:35 -0700
Subject: [PATCH 1/4] Add support for aligning BlockComments in declarations

---
 clang/include/clang/Format/Format.h| 25 +++-
 clang/lib/Format/Format.cpp| 22 ---
 clang/lib/Format/WhitespaceManager.cpp | 11 +++-
 clang/unittests/Format/ConfigParseTest.cpp | 73 +++---
 clang/unittests/Format/FormatTest.cpp  | 49 ++-
 5 files changed, 134 insertions(+), 46 deletions(-)

diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index d8b62c7652a0f6..f7b6bfffd61314 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -260,12 +260,35 @@ struct FormatStyle {
 ///   bbb >>= 2;
 /// \endcode
 bool PadOperators;
+/// Only for ``AlignConsecutiveDeclarations``.  Whether block comments
+/// are aligned in declarations.
+/// \code
+///   true:
+///   someLongFunction(int/*a*/,
+///bool   b,
+///const std::string& c)
+///
+///   const bool ret = someLongFunction(4/*a*/,
+/// true /*b*/,
+/// str  /*c*/);
+///
+///   false:
+///   someLongFunction(int /*a*/,
+///bool b,
+///const std::string& c)
+///
+///   const bool ret = someLongFunction(4 /*a*/,
+/// true /*b*/,
+/// str /*c*/);
+/// \endcode
+bool AlignBlockComments;
 bool operator==(const AlignConsecutiveStyle &R) const {
   return Enabled == R.Enabled && AcrossEmptyLines == R.AcrossEmptyLines &&
  AcrossComments == R.AcrossComments &&
  AlignCompound == R.AlignCompound &&
  AlignFunctionPointers == R.AlignFunctionPointers &&
- PadOperators == R.PadOperators;
+ PadOperators == R.PadOperators &&
+ AlignBlockComments == R.AlignBlockComments;
 }
 bool operator!=(const AlignConsecutiveStyle &R) const {
   return !(*this == R);
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d2463b892fbb96..ab8eadd0171aa6 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -48,39 +48,46 @@ template <> struct 
MappingTraits {
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/false, /*AcrossEmptyLines=*/false,
  /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "Consecutive",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/false,
  /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "AcrossEmptyLines",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/true,
  /*AcrossComments=*/false, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "AcrossComments",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/false,
  /*AcrossComments=*/true, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 IO.enumCase(Value, "AcrossEmptyLinesAndComments",
 FormatStyle::AlignConsecutiveStyle(
 {/*Enabled=*/true, /*AcrossEmptyLines=*/true,
  /*AcrossComments=*/true, /*AlignCompound=*/false,
- /*AlignFunctionPointers=*/false, /*PadOperators=*/true}));
+ /*AlignFunctionPointers=*/false, /*PadOperators=*/true,
+ /*AlignBlockComments=*/false}));
 
 // For backward compatibility.
 IO.enumCase(Value, "true",
 FormatStyle::AlignConsecutiveStyle(

[clang] [rtsan] NFC: Update docs with customizable functions (PR #117086)

2024-11-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Chris Apple (cjappl)


Changes

These functions recently were helpful for a user, so I decided to add them to 
the official docs.

Any feedback on wording or content appreciated as always 

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


1 Files Affected:

- (modified) clang/docs/RealtimeSanitizer.rst (+38) 


``diff
diff --git a/clang/docs/RealtimeSanitizer.rst b/clang/docs/RealtimeSanitizer.rst
index 193f5217c1a1a1..5431e38fea62ec 100644
--- a/clang/docs/RealtimeSanitizer.rst
+++ b/clang/docs/RealtimeSanitizer.rst
@@ -203,6 +203,44 @@ Some issues with flags can be debugged using the 
``verbosity=$NUM`` flag:
misspelled_flag
...
 
+Additional customization
+
+
+In addition to ``__rtsan_default_options`` outlined above, you can provide 
definitions of other functions that affect how RTSan operates.
+
+To be notified on every error reported by RTsan, provide a definition of 
``__sanitizer_report_error_summary``.
+
+.. code-block:: c
+
+   extern "C" void __sanitizer_report_error_summary(const char *error_summary) 
{
+  fprintf(stderr, "%s %s\n", "In custom handler! ", error_summary);
+  /* do other custom things */
+   }
+
+The error summary will be of the form: 
+
+.. code-block:: console
+
+   SUMMARY: RealtimeSanitizer: unsafe-library-call main.cpp:8 in 
process(std::__1::vector>&)
+
+To register a callback which will be invoked before a RTSan kills the process:
+
+.. code-block:: c
+
+  extern "C" void __sanitizer_set_death_callback(void (*callback)(void));
+
+  void custom_on_die_callback() {
+fprintf(stderr, "In custom handler!")
+/* do other custom things */
+  }
+
+  int main()
+  {
+__sanitizer_set_death_callback(custom_on_die_callback);
+...
+  }
+
+
 Disabling and suppressing
 -
 

``




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


[clang] [webkit.UncountedLambdaCapturesChecker] Fix debug assertion failure. (PR #117090)

2024-11-20 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa created 
https://github.com/llvm/llvm-project/pull/117090

Only call getThisType() on an instance method.

>From 31481cda425206408eb3aeef844503b110dfaa4d Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Wed, 20 Nov 2024 17:23:18 -0800
Subject: [PATCH] [webkit.UncountedLambdaCapturesChecker] Fix debug assertion
 failure.

Only call getThisType() on an instance method.
---
 .../Checkers/WebKit/UncountedLambdaCapturesChecker.cpp| 3 ++-
 .../Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp| 4 
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
index 3fb763e72e6809..9312bf0af16dbf 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
@@ -51,7 +51,8 @@ class UncountedLambdaCapturesChecker
 
   bool TraverseCXXMethodDecl(CXXMethodDecl *CXXMD) override {
 llvm::SaveAndRestore SavedDecl(ClsType);
-ClsType = CXXMD->getThisType();
+if (CXXMD && CXXMD->isInstance())
+  ClsType = CXXMD->getThisType();
 return DynamicRecursiveASTVisitor::TraverseCXXMethodDecl(CXXMD);
   }
 
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp 
b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
index 9bfcdea04755d2..b63ffed8809fef 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_analyze_cc1 
-analyzer-checker=webkit.UncountedLambdaCapturesChecker -verify %s
 
+struct A {
+  static void b();
+};
+
 struct RefCountable {
   void ref() {}
   void deref() {}

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


[clang] [clang] Use a Worklist for some CodeGenFunctions (PR #115395)

2024-11-20 Thread Eli Friedman via cfe-commits


@@ -0,0 +1,37 @@
+// RUN: split-file %s %t
+// RUN: python %t/gen.py %t/switch-overflow.c %t/tmp.c && %clang_cc1 
-emit-llvm %t/tmp.c -o - | FileCheck %t/tmp.c
+
+//--- gen.py

efriedma-quic wrote:

I guess 32000 is small enough that a test won't be that expensive, but a python 
script seems like overkill.  Maybe use a bit of C preprocessor trickery like 
the following:

```
#define CASES1(n) case n: case n+1: case n+2 case n+3:
#define CASES2(n) CASES1(n) CASES1(n+4) CASES1(n+8) CASES1(n+12)
#define CASES3(n) CASES2(n) CASES2(n+16) CASES2(n+32) CASES2(n+48)
void foo() {
  switch (1337) {
  CASES3(0)
break;
  }
}
```

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


[clang] [clang] Use a Worklist for some CodeGenFunctions (PR #115395)

2024-11-20 Thread Eli Friedman via cfe-commits

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


[clang] allow prefer 256 bit attribute target (PR #117092)

2024-11-20 Thread Matthias Braun via cfe-commits

https://github.com/MatzeB created 
https://github.com/llvm/llvm-project/pull/117092

- Rework attr-target-x86 test
- Allow prefer-256-bit for __attribute__((target))


>From 3bab9f901045426321d687fc36e4ba3034cc0f30 Mon Sep 17 00:00:00 2001
From: Matthias Braun 
Date: Wed, 20 Nov 2024 17:23:56 -0800
Subject: [PATCH 1/2] Rework attr-target-x86 test

Rework the attr-target-x86 test so the CHECK lines for the attributes
are next to their corresponding `__attribute__`.
---
 clang/test/CodeGen/attr-target-x86.c | 153 ---
 1 file changed, 89 insertions(+), 64 deletions(-)

diff --git a/clang/test/CodeGen/attr-target-x86.c 
b/clang/test/CodeGen/attr-target-x86.c
index 2033a8b4c335f9..75e6dd18be2090 100644
--- a/clang/test/CodeGen/attr-target-x86.c
+++ b/clang/test/CodeGen/attr-target-x86.c
@@ -1,80 +1,105 @@
 // RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu i686 
-emit-llvm %s -o - | FileCheck %s
 
-int baz(int a) { return 4; }
+// CHECK: define {{.*}}@f_default({{.*}} [[f_default:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx_sse4_2_ivybridge({{.*}} 
[[f_avx_sse4_2_ivybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_fpmath_387({{.*}} [[f_default]]
+// CHECK: define {{.*}}@f_no_sse2({{.*}} [[f_no_sse2:#[0-9]+]]
+// CHECK: define {{.*}}@f_sse4({{.*}} [[f_sse4:#[0-9]+]]
+// CHECK: define {{.*}}@f_no_sse4({{.*}} [[f_no_sse4:#[0-9]+]]
+// CHECK: define {{.*}}@f_default2({{.*}} [[f_default]]
+// CHECK: define {{.*}}@f_avx_sse4_2_ivybridge_2({{.*}} 
[[f_avx_sse4_2_ivybridge]]
+// CHECK: define {{.*}}@f_no_aes_ivybridge({{.*}} 
[[f_no_aes_ivybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_no_mmx({{.*}} [[f_no_mmx:#[0-9]+]]
+// CHECK: define {{.*}}@f_lakemont_mmx({{.*}} [[f_lakemont_mmx:#[0-9]+]]
+// CHECK: define {{.*}}@f_use_before_def({{.*}} [[f_lakemont_mmx]]
+// CHECK: define {{.*}}@f_tune_sandybridge({{.*}} 
[[f_tune_sandybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v2({{.*}} [[f_x86_64_v2:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v3({{.*}} [[f_x86_64_v3:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v4({{.*}} [[f_x86_64_v4:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx10_1_256{{.*}} [[f_avx10_1_256:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx10_1_512{{.*}} [[f_avx10_1_512:#[0-9]+]]
+
+// CHECK: [[f_default]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87" "tune-cpu"="i686"
+void f_default(void) {}
+
+// CHECK: [[f_avx_sse4_2_ivybridge]] = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+__attribute__((target("avx,sse4.2,arch=ivybridge")))
+void f_avx_sse4_2_ivybridge(void) {}
+
+// We're currently ignoring the fpmath attribute. So checked above that
+// attributes are identical to f_default.
+__attribute__((target("fpmath=387")))
+void f_fpmath_387(void) {}
 
-int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(int a) { return 
4; }
-
-int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
-
-int __attribute__((target("no-sse2"))) echidna(int a) { return 4; }
-
-int __attribute__((target("sse4"))) panda(int a) { return 4; }
-int __attribute__((target("no-sse4"))) narwhal(int a) { return 4; }
+// CHECK-NOT: tune-cpu
+// CHECK: [[f_no_sse2]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87,-aes,-amx-avx512,-avx,-avx10.1-256,-avx10.1-512,-avx10.2-256,-avx10.2-512,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint16,-avxvnniint8,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sha512,-sm3,-sm4,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop"
 "tune-cpu"="i686"
+__attribute__((target("no-sse2")))
+void f_no_sse2(void) {}
+
+// CHECK: [[f_sse4]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
 "tune-cpu"="i686"
+__attribute__((target("sse4")))
+void f_sse4(void) {}
+
+// CHECK: [[f_no_sse4]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87,-amx-avx512,-avx,-avx10.1-256,-avx10.1-512,-avx10.2-256,-avx10.2-512,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint16,-avxvnniint8,-f16c,-fma,-fma4,-sha512,-sm3,-sm4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop"
 "tune-cpu"="i686"
+__attribute__((target("no-sse4")))
+void f_no_sse4(void) {}
+
+// checked above that attributes are identical to f_default
+void f_default2(void) {
+  f_avx_sse4_2_ivybridge();
+  return f_default();
+}
 
-int bar(int a) { return baz(a) + foo(a); }
+// Checked above to have same attributes as f_avx_sse4_2_ivybridge
+__attribute__((target("avx,  sse4.2,  arch=   ivybridge")))
+void 

[clang] Rework attr-target-x86 test (PR #117091)

2024-11-20 Thread Matthias Braun via cfe-commits

https://github.com/MatzeB created 
https://github.com/llvm/llvm-project/pull/117091

Rework the attr-target-x86 test so the CHECK lines for the attributes
are next to their corresponding `__attribute__`.


>From 3bab9f901045426321d687fc36e4ba3034cc0f30 Mon Sep 17 00:00:00 2001
From: Matthias Braun 
Date: Wed, 20 Nov 2024 17:23:56 -0800
Subject: [PATCH] Rework attr-target-x86 test

Rework the attr-target-x86 test so the CHECK lines for the attributes
are next to their corresponding `__attribute__`.
---
 clang/test/CodeGen/attr-target-x86.c | 153 ---
 1 file changed, 89 insertions(+), 64 deletions(-)

diff --git a/clang/test/CodeGen/attr-target-x86.c 
b/clang/test/CodeGen/attr-target-x86.c
index 2033a8b4c335f9..75e6dd18be2090 100644
--- a/clang/test/CodeGen/attr-target-x86.c
+++ b/clang/test/CodeGen/attr-target-x86.c
@@ -1,80 +1,105 @@
 // RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu i686 
-emit-llvm %s -o - | FileCheck %s
 
-int baz(int a) { return 4; }
+// CHECK: define {{.*}}@f_default({{.*}} [[f_default:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx_sse4_2_ivybridge({{.*}} 
[[f_avx_sse4_2_ivybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_fpmath_387({{.*}} [[f_default]]
+// CHECK: define {{.*}}@f_no_sse2({{.*}} [[f_no_sse2:#[0-9]+]]
+// CHECK: define {{.*}}@f_sse4({{.*}} [[f_sse4:#[0-9]+]]
+// CHECK: define {{.*}}@f_no_sse4({{.*}} [[f_no_sse4:#[0-9]+]]
+// CHECK: define {{.*}}@f_default2({{.*}} [[f_default]]
+// CHECK: define {{.*}}@f_avx_sse4_2_ivybridge_2({{.*}} 
[[f_avx_sse4_2_ivybridge]]
+// CHECK: define {{.*}}@f_no_aes_ivybridge({{.*}} 
[[f_no_aes_ivybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_no_mmx({{.*}} [[f_no_mmx:#[0-9]+]]
+// CHECK: define {{.*}}@f_lakemont_mmx({{.*}} [[f_lakemont_mmx:#[0-9]+]]
+// CHECK: define {{.*}}@f_use_before_def({{.*}} [[f_lakemont_mmx]]
+// CHECK: define {{.*}}@f_tune_sandybridge({{.*}} 
[[f_tune_sandybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v2({{.*}} [[f_x86_64_v2:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v3({{.*}} [[f_x86_64_v3:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v4({{.*}} [[f_x86_64_v4:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx10_1_256{{.*}} [[f_avx10_1_256:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx10_1_512{{.*}} [[f_avx10_1_512:#[0-9]+]]
+
+// CHECK: [[f_default]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87" "tune-cpu"="i686"
+void f_default(void) {}
+
+// CHECK: [[f_avx_sse4_2_ivybridge]] = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+__attribute__((target("avx,sse4.2,arch=ivybridge")))
+void f_avx_sse4_2_ivybridge(void) {}
+
+// We're currently ignoring the fpmath attribute. So checked above that
+// attributes are identical to f_default.
+__attribute__((target("fpmath=387")))
+void f_fpmath_387(void) {}
 
-int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(int a) { return 
4; }
-
-int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
-
-int __attribute__((target("no-sse2"))) echidna(int a) { return 4; }
-
-int __attribute__((target("sse4"))) panda(int a) { return 4; }
-int __attribute__((target("no-sse4"))) narwhal(int a) { return 4; }
+// CHECK-NOT: tune-cpu
+// CHECK: [[f_no_sse2]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87,-aes,-amx-avx512,-avx,-avx10.1-256,-avx10.1-512,-avx10.2-256,-avx10.2-512,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint16,-avxvnniint8,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sha512,-sm3,-sm4,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop"
 "tune-cpu"="i686"
+__attribute__((target("no-sse2")))
+void f_no_sse2(void) {}
+
+// CHECK: [[f_sse4]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
 "tune-cpu"="i686"
+__attribute__((target("sse4")))
+void f_sse4(void) {}
+
+// CHECK: [[f_no_sse4]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87,-amx-avx512,-avx,-avx10.1-256,-avx10.1-512,-avx10.2-256,-avx10.2-512,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint16,-avxvnniint8,-f16c,-fma,-fma4,-sha512,-sm3,-sm4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop"
 "tune-cpu"="i686"
+__attribute__((target("no-sse4")))
+void f_no_sse4(void) {}
+
+// checked above that attributes are identical to f_default
+void f_default2(void) {
+  f_avx_sse4_2_ivybridge();
+  return f_default();
+}
 
-int bar(int a) { return baz(a) + foo(a); }
+// Checked above to have same attributes as f_avx_sse4_2_ivybridge
+__attribute__((target("avx,  sse4.2,

[clang] [lld] [llvm] [WebAssembly] Define call-indirect-overlong and bulk-memory-opt features (PR #117087)

2024-11-20 Thread Dan Gohman via cfe-commits

sunfishcode wrote:

The short answer is that's what the [Lime1 CPU calls 
it](https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1) 
:smile: .

> Can you explain why you want call-indirect-overlong in lime1? Is it because 
> you want to be able to link files compiles with multi-table? i.e. do you 
> want/expect type relocations at every call_indirect site? If so then perhaps 
> a better name might be call-indirect-relocatable? Or maybe even 
> multi-table-compatible? Sorry for the bikesheding and this late stage..

I included call-indirect-overlong in my original Lime1 proposal because of the 
simplicity of it. I expected it's easy for mvp-level engines to add support for 
it. And the more engines support it, the fewer users will see obscure binary 
decoding errors in cases where a toolchain tries to use an overlong and an 
engine doesn't recognize it.

Concerning naming, from Lime1's perspective, call-indirect-overlong is just a 
language feature. It's not inherently *for* call-indirect relocations or 
multi-table separate compilation strategies. Engines should just accept 
`call_indirect` instructions with overlongs, so it's called 
"call-indirect-overlong". Toolchains can then use that behavior whenever they 
have a need for it.


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


[clang] Rework attr-target-x86 test (PR #117091)

2024-11-20 Thread Matthias Braun via cfe-commits

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


[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-11-20 Thread via cfe-commits

https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/116331

>From 3c792216f88e87b69b3ea7415c2fd74b7f5d7469 Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Fri, 25 Oct 2024 17:48:41 +
Subject: [PATCH 1/8] adding comments

---
 clang/include/clang/Basic/Attr.td | 10 ++
 clang/lib/CodeGen/CGStmt.cpp  |  2 ++
 clang/lib/CodeGen/CodeGenFunction.cpp |  2 ++
 clang/lib/Sema/SemaStmtAttr.cpp   |  8 
 4 files changed, 22 insertions(+)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index b3c357ec906a23..6d3e07ce83100b 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4302,6 +4302,16 @@ def HLSLLoopHint: StmtAttr {
   let Documentation = [HLSLLoopHintDocs, HLSLUnrollHintDocs];
 }
 
+def HLSLBranchHint: StmtAttr {
+  /// [branch]
+  /// [flatten]
+  let Spellings = [Microsoft<"branch">, Microsoft<"flatten">];
+  let Subjects = SubjectList<[IfStmt],
+  ErrorDiag, "'if' statements">;
+  let LangOpts = [HLSL];
+  let Documentation = [InternalOnly];
+}
+
 def CapturedRecord : InheritableAttr {
   // This attribute has no spellings as it is only ever created implicitly.
   let Spellings = [];
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 698baf853507f4..7b01dc84b55365 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -761,6 +761,7 @@ void CodeGenFunction::EmitAttributedStmt(const 
AttributedStmt &S) {
 Builder.CreateAssumption(AssumptionVal);
   }
 } break;
+// [jderezende] TODO: Add HLSLBranchHint, to mark if flatten/branch is 
present.
 }
   }
   SaveAndRestore save_nomerge(InNoMergeAttributedStmt, nomerge);
@@ -768,6 +769,7 @@ void CodeGenFunction::EmitAttributedStmt(const 
AttributedStmt &S) {
   SaveAndRestore save_alwaysinline(InAlwaysInlineAttributedStmt, alwaysinline);
   SaveAndRestore save_noconvergent(InNoConvergentAttributedStmt, noconvergent);
   SaveAndRestore save_musttail(MustTailCall, musttail);
+  // [jderezende] TODO: Save HLSLBranchHint information
   EmitStmt(S.getSubStmt(), S.getAttrs());
 }
 
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 6ead45793742d6..fc4fde81984d64 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -43,6 +43,7 @@
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
+#include "llvm/IR/Metadata.h"
 #include "llvm/IR/Operator.h"
 #include "llvm/Support/CRC.h"
 #include "llvm/Support/xxhash.h"
@@ -2076,6 +2077,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(
 Weights = createProfileWeights(TrueCount, CurrentCount - TrueCount);
   }
 
+  // [jderezende] TODO: Emit branch metadata marking it as flatten/branch, if 
exists.
   Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights, Unpredictable);
 }
 
diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp
index f801455596fe6f..68323092cb564d 100644
--- a/clang/lib/Sema/SemaStmtAttr.cpp
+++ b/clang/lib/Sema/SemaStmtAttr.cpp
@@ -623,6 +623,12 @@ static Attr *handleHLSLLoopHintAttr(Sema &S, Stmt *St, 
const ParsedAttr &A,
   return ::new (S.Context) HLSLLoopHintAttr(S.Context, A, UnrollFactor);
 }
 
+static Attr *handleHLSLBranchHint(Sema &S, Stmt *St, const ParsedAttr &A,
+SourceRange Range) {
+
+  return ::new (S.Context) HLSLBranchHintAttr(S.Context, A);
+}
+
 static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A,
   SourceRange Range) {
   if (A.isInvalid() || A.getKind() == ParsedAttr::IgnoredAttribute)
@@ -659,6 +665,8 @@ static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const 
ParsedAttr &A,
 return handleLoopHintAttr(S, St, A, Range);
   case ParsedAttr::AT_HLSLLoopHint:
 return handleHLSLLoopHintAttr(S, St, A, Range);
+  case ParsedAttr::AT_HLSLBranchHint:
+return handleHLSLBranchHint(S, St, A, Range);
   case ParsedAttr::AT_OpenCLUnrollHint:
 return handleOpenCLUnrollHint(S, St, A, Range);
   case ParsedAttr::AT_Suppress:

>From f48e382b7ff396fbf1b2ce7dcea9529a06fa9b12 Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Mon, 28 Oct 2024 23:58:10 +
Subject: [PATCH 2/8] continue exploration

---
 llvm/include/llvm/IR/FixedMetadataKinds.def | 3 +++
 llvm/lib/Target/SPIRV/SPIRVStructurizer.cpp | 1 +
 2 files changed, 4 insertions(+)

diff --git a/llvm/include/llvm/IR/FixedMetadataKinds.def 
b/llvm/include/llvm/IR/FixedMetadataKinds.def
index df572e8791e13b..02a986d42f1933 100644
--- a/llvm/include/llvm/IR/FixedMetadataKinds.def
+++ b/llvm/include/llvm/IR/FixedMetadataKinds.def
@@ -53,3 +53,6 @@ LLVM_FIXED_MD_KIND(MD_DIAssignID, "DIAssignID", 38)
 LLVM_FIXED_MD_KIND(MD_coro_outside_frame, "coro.outside.frame", 39)
 LLVM_FIXED_MD_KIND(MD_mmra, "mmra", 40)
 LLVM_FIXED_MD_KIND(MD_noalias_addrspace

[clang] Rework attr-target-x86 test (PR #117091)

2024-11-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matthias Braun (MatzeB)


Changes

Rework the attr-target-x86 test so the CHECK lines for the attributes
are next to their corresponding `__attribute__`.


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


1 Files Affected:

- (modified) clang/test/CodeGen/attr-target-x86.c (+89-64) 


``diff
diff --git a/clang/test/CodeGen/attr-target-x86.c 
b/clang/test/CodeGen/attr-target-x86.c
index 2033a8b4c335f9..75e6dd18be2090 100644
--- a/clang/test/CodeGen/attr-target-x86.c
+++ b/clang/test/CodeGen/attr-target-x86.c
@@ -1,80 +1,105 @@
 // RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu i686 
-emit-llvm %s -o - | FileCheck %s
 
-int baz(int a) { return 4; }
+// CHECK: define {{.*}}@f_default({{.*}} [[f_default:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx_sse4_2_ivybridge({{.*}} 
[[f_avx_sse4_2_ivybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_fpmath_387({{.*}} [[f_default]]
+// CHECK: define {{.*}}@f_no_sse2({{.*}} [[f_no_sse2:#[0-9]+]]
+// CHECK: define {{.*}}@f_sse4({{.*}} [[f_sse4:#[0-9]+]]
+// CHECK: define {{.*}}@f_no_sse4({{.*}} [[f_no_sse4:#[0-9]+]]
+// CHECK: define {{.*}}@f_default2({{.*}} [[f_default]]
+// CHECK: define {{.*}}@f_avx_sse4_2_ivybridge_2({{.*}} 
[[f_avx_sse4_2_ivybridge]]
+// CHECK: define {{.*}}@f_no_aes_ivybridge({{.*}} 
[[f_no_aes_ivybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_no_mmx({{.*}} [[f_no_mmx:#[0-9]+]]
+// CHECK: define {{.*}}@f_lakemont_mmx({{.*}} [[f_lakemont_mmx:#[0-9]+]]
+// CHECK: define {{.*}}@f_use_before_def({{.*}} [[f_lakemont_mmx]]
+// CHECK: define {{.*}}@f_tune_sandybridge({{.*}} 
[[f_tune_sandybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v2({{.*}} [[f_x86_64_v2:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v3({{.*}} [[f_x86_64_v3:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v4({{.*}} [[f_x86_64_v4:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx10_1_256{{.*}} [[f_avx10_1_256:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx10_1_512{{.*}} [[f_avx10_1_512:#[0-9]+]]
+
+// CHECK: [[f_default]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87" "tune-cpu"="i686"
+void f_default(void) {}
+
+// CHECK: [[f_avx_sse4_2_ivybridge]] = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+__attribute__((target("avx,sse4.2,arch=ivybridge")))
+void f_avx_sse4_2_ivybridge(void) {}
+
+// We're currently ignoring the fpmath attribute. So checked above that
+// attributes are identical to f_default.
+__attribute__((target("fpmath=387")))
+void f_fpmath_387(void) {}
 
-int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(int a) { return 
4; }
-
-int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
-
-int __attribute__((target("no-sse2"))) echidna(int a) { return 4; }
-
-int __attribute__((target("sse4"))) panda(int a) { return 4; }
-int __attribute__((target("no-sse4"))) narwhal(int a) { return 4; }
+// CHECK-NOT: tune-cpu
+// CHECK: [[f_no_sse2]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87,-aes,-amx-avx512,-avx,-avx10.1-256,-avx10.1-512,-avx10.2-256,-avx10.2-512,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint16,-avxvnniint8,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sha512,-sm3,-sm4,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop"
 "tune-cpu"="i686"
+__attribute__((target("no-sse2")))
+void f_no_sse2(void) {}
+
+// CHECK: [[f_sse4]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
 "tune-cpu"="i686"
+__attribute__((target("sse4")))
+void f_sse4(void) {}
+
+// CHECK: [[f_no_sse4]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87,-amx-avx512,-avx,-avx10.1-256,-avx10.1-512,-avx10.2-256,-avx10.2-512,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint16,-avxvnniint8,-f16c,-fma,-fma4,-sha512,-sm3,-sm4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop"
 "tune-cpu"="i686"
+__attribute__((target("no-sse4")))
+void f_no_sse4(void) {}
+
+// checked above that attributes are identical to f_default
+void f_default2(void) {
+  f_avx_sse4_2_ivybridge();
+  return f_default();
+}
 
-int bar(int a) { return baz(a) + foo(a); }
+// Checked above to have same attributes as f_avx_sse4_2_ivybridge
+__attribute__((target("avx,  sse4.2,  arch=   ivybridge")))
+void f_avx_sse4_2_ivybridge_2(void) {}
 
-int __attribute__((target("avx,  sse4.2,  arch=   ivybridge"))) 
qux(int a) { return 4; }
-int __attribute__((target("no-aes, arch=ivybridge"))) qax(int a) { return 4; }
+// 

[clang] [lld] [llvm] [WebAssembly] Define call-indirect-overlong and bulk-memory-opt features (PR #117087)

2024-11-20 Thread Sam Clegg via cfe-commits

sbc100 wrote:

> The short answer is that's what the [Lime1 CPU calls 
> it](https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1) 
> 😄 .
> 
> > Can you explain why you want call-indirect-overlong in lime1? Is it because 
> > you want to be able to link files compiles with multi-table? i.e. do you 
> > want/expect type relocations at every call_indirect site? If so then 
> > perhaps a better name might be call-indirect-relocatable? Or maybe even 
> > multi-table-compatible? Sorry for the bikesheding and this late stage..
> 
> I included call-indirect-overlong in my original Lime1 proposal because of 
> the simplicity of it. I expected it's easy for mvp-level engines to add 
> support for it. And the more engines support it, the fewer users will see 
> obscure binary decoding errors in cases where a toolchain tries to use an 
> overlong and an engine doesn't recognize it.
> 
> Concerning naming, from Lime1's perspective, call-indirect-overlong is just a 
> language feature. It's not inherently _for_ call-indirect relocations or 
> multi-table separate compilation strategies. Engines should just accept 
> `call_indirect` instructions with overlongs, so it's called 
> "call-indirect-overlong". Toolchains can then use that behavior whenever they 
> have a need for it.

I see, so in practice the effect on LLVM is that you get a relocation at each 
call_indirect site but we don't need this relocation of the wide encoding for 
any particular reason. 

It seems like a lot of steps and complexity just to force some binary decoders 
to support an otherwise unused feature.. but you think its worth the effort?

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


[clang] allow prefer 256 bit attribute target (PR #117092)

2024-11-20 Thread Matthias Braun via cfe-commits

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


[clang] allow prefer 256 bit attribute target (PR #117092)

2024-11-20 Thread Matthias Braun via cfe-commits

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


[clang] allow prefer 256 bit attribute target (PR #117092)

2024-11-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matthias Braun (MatzeB)


Changes

It would be useful for us to have `__attribue__((target("prefer-256-bit")))` / 
`__attribue__((target("no-prefer-256-bit")))` to create variants of a functions 
to generate AVX code with 256/512 bit vector sizes within the same applications.

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


2 Files Affected:

- (modified) clang/lib/Basic/Targets/X86.cpp (+1) 
- (modified) clang/test/CodeGen/attr-target-x86.c (+99-64) 


``diff
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 5993257e27d5a9..e903e16032bf02 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -1162,6 +1162,7 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) 
const {
   .Case("pconfig", true)
   .Case("pku", true)
   .Case("popcnt", true)
+  .Case("prefer-256-bit", true)
   .Case("prefetchi", true)
   .Case("prfchw", true)
   .Case("ptwrite", true)
diff --git a/clang/test/CodeGen/attr-target-x86.c 
b/clang/test/CodeGen/attr-target-x86.c
index 2033a8b4c335f9..e9264efaa85c4f 100644
--- a/clang/test/CodeGen/attr-target-x86.c
+++ b/clang/test/CodeGen/attr-target-x86.c
@@ -1,80 +1,115 @@
 // RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu i686 
-emit-llvm %s -o - | FileCheck %s
 
-int baz(int a) { return 4; }
+// CHECK: define {{.*}}@f_default({{.*}} [[f_default:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx_sse4_2_ivybridge({{.*}} 
[[f_avx_sse4_2_ivybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_fpmath_387({{.*}} [[f_default]]
+// CHECK: define {{.*}}@f_no_sse2({{.*}} [[f_no_sse2:#[0-9]+]]
+// CHECK: define {{.*}}@f_sse4({{.*}} [[f_sse4:#[0-9]+]]
+// CHECK: define {{.*}}@f_no_sse4({{.*}} [[f_no_sse4:#[0-9]+]]
+// CHECK: define {{.*}}@f_default2({{.*}} [[f_default]]
+// CHECK: define {{.*}}@f_avx_sse4_2_ivybridge_2({{.*}} 
[[f_avx_sse4_2_ivybridge]]
+// CHECK: define {{.*}}@f_no_aes_ivybridge({{.*}} 
[[f_no_aes_ivybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_no_mmx({{.*}} [[f_no_mmx:#[0-9]+]]
+// CHECK: define {{.*}}@f_lakemont_mmx({{.*}} [[f_lakemont_mmx:#[0-9]+]]
+// CHECK: define {{.*}}@f_use_before_def({{.*}} [[f_lakemont_mmx]]
+// CHECK: define {{.*}}@f_tune_sandybridge({{.*}} 
[[f_tune_sandybridge:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v2({{.*}} [[f_x86_64_v2:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v3({{.*}} [[f_x86_64_v3:#[0-9]+]]
+// CHECK: define {{.*}}@f_x86_64_v4({{.*}} [[f_x86_64_v4:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx10_1_256{{.*}} [[f_avx10_1_256:#[0-9]+]]
+// CHECK: define {{.*}}@f_avx10_1_512{{.*}} [[f_avx10_1_512:#[0-9]+]]
+// CHECK: define {{.*}}@f_prefer_256_bit({{.*}} [[f_prefer_256_bit:#[0-9]+]]
+// CHECK: define {{.*}}@f_no_prefer_256_bit({{.*}} 
[[f_no_prefer_256_bit:#[0-9]+]]
+
+// CHECK: [[f_default]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87" "tune-cpu"="i686"
+void f_default(void) {}
+
+// CHECK: [[f_avx_sse4_2_ivybridge]] = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+__attribute__((target("avx,sse4.2,arch=ivybridge")))
+void f_avx_sse4_2_ivybridge(void) {}
+
+// We're currently ignoring the fpmath attribute. So checked above that
+// attributes are identical to f_default.
+__attribute__((target("fpmath=387")))
+void f_fpmath_387(void) {}
 
-int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(int a) { return 
4; }
-
-int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
-
-int __attribute__((target("no-sse2"))) echidna(int a) { return 4; }
-
-int __attribute__((target("sse4"))) panda(int a) { return 4; }
-int __attribute__((target("no-sse4"))) narwhal(int a) { return 4; }
+// CHECK-NOT: tune-cpu
+// CHECK: [[f_no_sse2]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87,-aes,-amx-avx512,-avx,-avx10.1-256,-avx10.1-512,-avx10.2-256,-avx10.2-512,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxifma,-avxneconvert,-avxvnni,-avxvnniint16,-avxvnniint8,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sha512,-sm3,-sm4,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop"
 "tune-cpu"="i686"
+__attribute__((target("no-sse2")))
+void f_no_sse2(void) {}
+
+// CHECK: [[f_sse4]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
 "tune-cpu"="i686"
+__attribute__((target("sse4")))
+void f_sse4(void) {}
+
+// CHECK: [[f_no_sse4]] = {{.*}}"target-cpu"="i686" 
"target-features"="+cmov,+cx8,+x87,-amx-avx512,-avx,-avx10.1-256,-avx10.1-512,-avx10.2-256,-avx10.2-512,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512fp16,-avx512ifma,-avx512vbmi,-av

[clang] allow prefer 256 bit attribute target (PR #117092)

2024-11-20 Thread Matthias Braun via cfe-commits

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


[clang] [clang] constexpr built-in reduce `or` and `xor` function. (PR #116976)

2024-11-20 Thread via cfe-commits

https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/116976

>From 4d13a8267dd5d0e99063bb088a85406af5266c80 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Wed, 20 Nov 2024 22:07:35 +0800
Subject: [PATCH 1/2] constexpr reduce or/xor

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/include/clang/Basic/Builtins.td|  4 ++--
 clang/lib/AST/ExprConstant.cpp   | 12 +++-
 clang/test/Sema/constant_builtins_vector.cpp | 20 
 4 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 999c88455b64a5..98ed21d09305b2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -358,6 +358,7 @@ Non-comprehensive list of changes in this release
 - ``__builtin_reduce_add`` function can now be used in constant expressions.
 - ``__builtin_reduce_mul`` function can now be used in constant expressions.
 - ``__builtin_reduce_and`` function can now be used in constant expressions.
+- ``__builtin_reduce_or`` and ``__builtin_reduce_xor`` functions can now be 
used in constant expressions.
 
 New Compiler Flags
 --
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index aa65f94e68f9c3..daf90b9570160e 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -1486,13 +1486,13 @@ def ReduceMinimum : Builtin {
 
 def ReduceXor : Builtin {
   let Spellings = ["__builtin_reduce_xor"];
-  let Attributes = [NoThrow, Const, CustomTypeChecking];
+  let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
   let Prototype = "void(...)";
 }
 
 def ReduceOr : Builtin {
   let Spellings = ["__builtin_reduce_or"];
-  let Attributes = [NoThrow, Const, CustomTypeChecking];
+  let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
   let Prototype = "void(...)";
 }
 
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 33206f5cda2021..261de141637020 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -13529,7 +13529,9 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 
   case Builtin::BI__builtin_reduce_add:
   case Builtin::BI__builtin_reduce_mul:
-  case Builtin::BI__builtin_reduce_and: {
+  case Builtin::BI__builtin_reduce_and:
+  case Builtin::BI__builtin_reduce_or:
+  case Builtin::BI__builtin_reduce_xor: {
 APValue Source;
 if (!EvaluateAsRValue(Info, E->getArg(0), Source))
   return false;
@@ -13558,6 +13560,14 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 Reduced &= Source.getVectorElt(EltNum).getInt();
 break;
   }
+  case Builtin::BI__builtin_reduce_or: {
+Reduced |= Source.getVectorElt(EltNum).getInt();
+break;
+  }
+  case Builtin::BI__builtin_reduce_xor: {
+Reduced ^= Source.getVectorElt(EltNum).getInt();
+break;
+  }
   }
 }
 
diff --git a/clang/test/Sema/constant_builtins_vector.cpp 
b/clang/test/Sema/constant_builtins_vector.cpp
index 7063c290479f6c..e84d09b24672b4 100644
--- a/clang/test/Sema/constant_builtins_vector.cpp
+++ b/clang/test/Sema/constant_builtins_vector.cpp
@@ -777,3 +777,23 @@ 
static_assert(__builtin_reduce_and((vector4int){(int)~0x, (int)~0x22
 static_assert(__builtin_reduce_and((vector4long){(long 
long)~0xL, (long long)~0xL, (long 
long)~0xL, (long long)-1}) == 0xL);
 static_assert(__builtin_reduce_and((vector4uint){0xU, 0xU, 
0xU, 0xU}) == 0U);
 static_assert(__builtin_reduce_and((vector4ulong){0xUL, 
0xUL, 0xUL, 0xUL}) == 0L);
+
+static_assert(__builtin_reduce_or((vector4char){}) == 0);
+static_assert(__builtin_reduce_or((vector4char){(char)0x11, (char)0x22, 
(char)0x44, (char)0x88}) == (char)0xFF);
+static_assert(__builtin_reduce_or((vector4short){(short)0x, (short)0x, 
(short)0x, (short)0x}) == (short)0x);
+static_assert(__builtin_reduce_or((vector4int){(int)0x, 
(int)0x, (int)0x, (int)0x}) == (int)0x);
+static_assert(__builtin_reduce_or((vector4long){(long 
long)0xL, (long long)0xL, (long 
long)0xL, (long long)0xL}) == (long 
long)0xL);
+static_assert(__builtin_reduce_or((vector4char){(char)0, (char)0x22, 
(char)0x44, (char)0x88}) == ~0x11);
+static_assert(__builtin_reduce_or((vector4short){(short)0x, (short)0, 
(short)0x, (short)0x}) == ~0x);
+static_assert(__builtin_reduce_or((vector4int){(int)0x, 
(int)0x, (int)0, (int)0x}) == ~0x);
+static_assert(__builtin_reduce_or((vector4long){(long 
long)0xL, (long long)0xL, (long 
long)0xL, (long lo

[clang] [clang] constexpr built-in reduce `or` and `xor` function. (PR #116976)

2024-11-20 Thread via cfe-commits


@@ -732,6 +732,10 @@ at the end to the next power of 2.
 
 These reductions support both fixed-sized and scalable vector types.
 
+The reduction intrinsics, including ``__builtin_reduce_add``,

c8ef wrote:

Added.

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


[clang-tools-extra] [clang-tidy] ignore consteval function in `ExceptionAnalyzer` (PR #116643)

2024-11-20 Thread Julian Schmidt via cfe-commits


@@ -320,6 +320,11 @@ bool isQualificationConvertiblePointer(QualType From, 
QualType To,
 } // namespace
 
 static bool canThrow(const FunctionDecl *Func) {
+  // consteval specifies every call to the function must produce a compile-time
+  // constant. compile-time constant cannot be evaluate a throw expression.

5chmidti wrote:

> // consteval specifies that every call to the function must produce a 
> compile-time
// constant, which cannot evaluate a throw expression without producing a 
compilation error.

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


[clang] 668f2c7 - [clang][UBSan] Make sure that the implicit-conversion group is compatible with minimal runtime (#114865)

2024-11-20 Thread via cfe-commits

Author: Axel Lundberg
Date: 2024-11-20T14:57:23-08:00
New Revision: 668f2c7fab288db90d474a7f6f72b11e5a120328

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

LOG: [clang][UBSan] Make sure that the implicit-conversion group is compatible 
with minimal runtime (#114865)

We are currently getting:

`clang: error: invalid argument '-fsanitize-minimal-runtime' not allowed
with '-fsanitize=implicit-conversion'`

when running

`-fsanitize=implicit-conversion -fsanitize-minimal-runtime`

because `implicit-conversion` now includes
`implicit-bitfield-conversion` which is not included in the `integer`
check. The `integer` check includes the `implicit-integer-conversion`
checks and is supported by the trapping option and because of that
compatible with the minimal runtime. It is thus reasonable to make
`implicit-bitfield-conversion` compatible with the minimal runtime.

Added: 


Modified: 
clang/lib/Driver/SanitizerArgs.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index b91233ee2c50a1..1abfe8fd92807e 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -65,9 +65,9 @@ static const SanitizerMask AlwaysRecoverable = 
SanitizerKind::KernelAddress |
 static const SanitizerMask NeedsLTO = SanitizerKind::CFI;
 static const SanitizerMask TrappingSupported =
 (SanitizerKind::Undefined & ~SanitizerKind::Vptr) | SanitizerKind::Integer 
|
-SanitizerKind::Nullability | SanitizerKind::LocalBounds |
-SanitizerKind::CFI | SanitizerKind::FloatDivideByZero |
-SanitizerKind::ObjCCast;
+SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |
+SanitizerKind::LocalBounds | SanitizerKind::CFI |
+SanitizerKind::FloatDivideByZero | SanitizerKind::ObjCCast;
 static const SanitizerMask TrappingDefault = SanitizerKind::CFI;
 static const SanitizerMask CFIClasses =
 SanitizerKind::CFIVCall | SanitizerKind::CFINVCall |

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 6ecf0b57bee5c0..15f190165a7d73 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -866,6 +866,13 @@
 // CHECK-INTSAN-MINIMAL: 
"-fsanitize=integer-divide-by-zero,shift-base,shift-exponent,signed-integer-overflow,unsigned-integer-overflow,unsigned-shift-base,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change"
 // CHECK-INTSAN-MINIMAL: "-fsanitize-minimal-runtime"
 
+// RUN: %clang --target=x86_64-linux-gnu -fsanitize=implicit-conversion 
-fsanitize-trap=implicit-conversion %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-IMPL-CONV-TRAP
+// CHECK-IMPL-CONV-TRAP: 
"-fsanitize-trap=implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,implicit-bitfield-conversion"
+
+// RUN: %clang --target=x86_64-linux-gnu -fsanitize=implicit-conversion 
-fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-IMPL-CONV-MINIMAL
+// CHECK-IMPL-CONV-MINIMAL: 
"-fsanitize=implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,implicit-bitfield-conversion"
+// CHECK-IMPL-CONV-MINIMAL: "-fsanitize-minimal-runtime"
+
 // RUN: %clang --target=aarch64-linux-android -march=armv8-a+memtag 
-fsanitize=memtag -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-MEMTAG-MINIMAL
 // CHECK-MEMTAG-MINIMAL: "-fsanitize=memtag-stack,memtag-heap,memtag-globals"
 // CHECK-MEMTAG-MINIMAL: "-fsanitize-minimal-runtime"



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


[clang] [Clang] Fix constexpr-ness on implicitly deleted destructors (PR #116359)

2024-11-20 Thread Aaron Ballman via cfe-commits

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


[clang] [llvm] [ARM] Emit an error when the hard-float ABI is enabled but can't be used. (PR #111334)

2024-11-20 Thread Peter Smith via cfe-commits

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


[clang] [clang][SME] Ignore flatten for callees with mismatched streaming attributes (PR #116391)

2024-11-20 Thread Eli Friedman via cfe-commits

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

Oh, right, we have isInlineViable(), but attributes aren't part of it for... 
reasons.  (I haven't tried to dig into 
https://discourse.llvm.org/t/rfc-avoid-inlining-alwaysinline-functions-when-they-cannot-be-inlined
 ; I'll believe you that it's non-trivial to fix.)  Hence, shoving this into 
the frontend.

I guess this is fine, then.  But please add a note describing the current 
situation, so the next person looking at this has context.  (Put it in 
TargetInfo.h, maybe?) 

LGTM with the note.

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


[clang] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-20 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/114684

>From d95d0fdb22ae2ad162f89cb211f313cea6c6474a Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sat, 2 Nov 2024 23:54:35 +0200
Subject: [PATCH 1/6] [Clang] enhance error recovery with RecoveryExpr for
 trailing commas in call arguments

---
 clang/lib/Parse/ParseExpr.cpp|  3 +++
 clang/test/AST/ast-dump-recovery.cpp | 17 -
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 4570a18bc0d5e5..5fccd2ae106015 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -3705,6 +3705,9 @@ bool Parser::ParseExpressionList(SmallVectorImpl 
&Exprs,
 Token Comma = Tok;
 ConsumeToken();
 checkPotentialAngleBracketDelimiter(Comma);
+
+if (Tok.is(tok::r_paren))
+  break;
   }
   if (SawError) {
 // Ensure typos get diagnosed when errors were encountered while parsing 
the
diff --git a/clang/test/AST/ast-dump-recovery.cpp 
b/clang/test/AST/ast-dump-recovery.cpp
index a88dff471d9f04..1876f4ace32a5a 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -9,7 +9,7 @@ int some_func(int *);
 // CHECK-NEXT:`-IntegerLiteral {{.*}} 123
 // DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
 int invalid_call = some_func(123);
-void test_invalid_call(int s) {
+void test_invalid_call_1(int s) {
   // CHECK:  CallExpr {{.*}} '' contains-errors
   // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} 'some_func'
   // CHECK-NEXT: |-RecoveryExpr {{.*}} 
@@ -32,6 +32,21 @@ void test_invalid_call(int s) {
   int var = some_func(undef1);
 }
 
+int some_func2(int a, int b);
+void test_invalid_call_2() {
+  // CHECK:   `-RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' 
lvalue (ADL) = 'some_func2'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  some_func2(1, );
+}
+
+void test_invalid_call_3() {
+  // CHECK:   `-RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' 
lvalue (ADL) = 'some_func2'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  some_func2(1);
+}
+
 int ambig_func(double);
 int ambig_func(float);
 

>From 2b45d342c7e2327c525b681a0e4069132dcd430d Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 20 Nov 2024 11:47:13 +0200
Subject: [PATCH 2/6] explicity handle of trailing commas to improve recovery
 and ensure proper processing of prior erroneous expressions

---
 clang/include/clang/Parse/Parser.h   |  3 ++-
 clang/lib/Parse/ParseDecl.cpp|  5 +++--
 clang/lib/Parse/ParseExpr.cpp| 19 +++
 clang/test/AST/ast-dump-recovery.cpp | 11 ---
 4 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 045ee754a242b3..d3838a4cc8418c 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1934,7 +1934,8 @@ class Parser : public CodeCompletionHandler {
llvm::function_ref ExpressionStarts =
llvm::function_ref(),
bool FailImmediatelyOnInvalidExpr = false,
-   bool EarlyTypoCorrection = false);
+   bool EarlyTypoCorrection = false,
+   bool *HasTrailingComma = nullptr);
 
   /// ParseSimpleExpressionList - A simple comma-separated list of expressions,
   /// used for misc language extensions.
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index aa5c2d28d429ac..ae8611207b2609 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2890,8 +2890,9 @@ Decl 
*Parser::ParseDeclarationAfterDeclaratorAndAttributes(
   // ProduceConstructorSignatureHelp only on VarDecls.
   ExpressionStarts = SetPreferredType;
 }
-
-bool SawError = ParseExpressionList(Exprs, ExpressionStarts);
+bool HasTrailingComma = false;
+bool SawError =
+ParseExpressionList(Exprs, ExpressionStarts, HasTrailingComma);
 
 if (SawError) {
   if (ThisVarDecl && PP.isCodeCompletionReached() && !CalledSignatureHelp) 
{
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 5fccd2ae106015..736484ded8383c 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -2199,10 +2199,17 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
   };
   if (OpKind == tok::l_paren || !LHS.isInvalid()) {
 if (Tok.isNot(tok::r_paren)) {
-  if (ParseExpressionList(ArgExprs, [&] {
+  bool HasTrailingComma = false;
+  bool HasError = ParseExpressionList(
+  ArgExprs,
+  [&] {
 PreferredType.enterFunctionArgument(Tok.getLocation(),
 RunSignature

[clang] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-20 Thread Oleksandr T. via cfe-commits


@@ -32,6 +32,26 @@ void test_invalid_call(int s) {
   int var = some_func(undef1);
 }
 
+int some_func2(int a, int b);
+void test_invalid_call_2() {
+  // CHECK:   `-RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' 
lvalue (ADL) = 'some_func2'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  some_func2(1, );
+}
+
+void test_invalid_call_3() {
+  // CHECK:   `-RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: -UnresolvedLookupExpr {{.*}} '' 
lvalue (ADL) = 'some_func2'
+  some_func2(,);
+}
+
+void test_invalid_call_4() {
+  // CHECK:   `-RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: -UnresolvedLookupExpr {{.*}} '' 
lvalue (ADL) = 'some_func2'
+  some_func2(,,);

a-tarasyuk wrote:

@hokein Thanks for the clarification! I've updated the tests

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


[clang] Remove Linux search paths on Windows (PR #113628)

2024-11-20 Thread David Salinas via cfe-commits

david-salinas wrote:

> Is there an issue with simply using the `HostTC` for everything? I feel like 
> that's the solution to this mess, since the `HostTC` would always know 
> whether or not the target is Windows without us needing to forward a bunch of 
> stuff.

Yes, that would work too.  But currently the HostTC is only 
available/accessible in HIPAMDToolChain.  With the way we instantiate the RID, 
we need to tell the RID ctor to hold off on creating the Search Paths if the 
HostTC is Windows.  And the RID ctor is called all the way up in the 
Generic_GCC ctor.  We would still have to pass the HostTC all the way through 
class hierarchy (HIPAMDToolChain -> ROCMToolChin -> AMDGPUToolChain -> 
Generic_ELF).  My thinking was that passing a bool would be a little less 
intrusive/heavy of a change. Though, we would only be passing a reference to 
the HostTC.  

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


[clang] [lld] [llvm] [WebAssembly] Support the new "Lime1" CPU (PR #112035)

2024-11-20 Thread Dan Gohman via cfe-commits

https://github.com/sunfishcode updated 
https://github.com/llvm/llvm-project/pull/112035

>From 22c34e6c92a6fe384e409a083584c00954521861 Mon Sep 17 00:00:00 2001
From: Dan Gohman 
Date: Fri, 11 Oct 2024 04:30:32 -0700
Subject: [PATCH] [WebAssembly] Support the new "Lime1" CPU

This adds WebAssembly support for the new [Lime1 CPU].

First, this defines some new target features. These are subsets of existing
features that reflect implementation concerns:

 - "call-indirect-overlong" - implied by "reference-types"; just the overlong
   encoding for the `call_indirect` immediate, and not the actual reference
   types.

 - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and
   `memory.fill`, and not the other instructions in the bulk-memory
proposal.

Next, this defines a new target CPU, "lime1", which enables mutable-globals,
bulk-memory-opt, multivalue, sign-ext, nontrapping-fptoint, extended-const,
and call-indirect-overlong. Unlike the default "generic" CPU, "lime1" is meant
to be frozen, and followed up by "lime2" and so on when new features are
desired.

[Lime1 CPU]: 
https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1
---
 clang/docs/ReleaseNotes.rst   |  6 +++
 clang/lib/Basic/Targets/WebAssembly.cpp   | 47 
 clang/lib/Basic/Targets/WebAssembly.h |  2 +
 lld/test/wasm/compress-relocs.ll  |  2 +-
 lld/test/wasm/import-table-explicit.s |  2 +-
 lld/test/wasm/invalid-mvp-table-use.s |  2 +-
 lld/test/wasm/lto/Inputs/libcall-archive.ll   |  2 +-
 lld/test/wasm/lto/libcall-archive.ll  |  2 +-
 lld/test/wasm/lto/stub-library-libcall.s  |  4 +-
 lld/test/wasm/multi-table.s   |  2 +-
 lld/wasm/InputFiles.cpp   | 11 ++--
 lld/wasm/SyntheticSections.cpp|  2 +-
 llvm/docs/ReleaseNotes.md |  6 +++
 .../AsmParser/WebAssemblyAsmParser.cpp| 28 +++---
 llvm/lib/Target/WebAssembly/WebAssembly.td| 28 +++---
 .../WebAssembly/WebAssemblyFastISel.cpp   |  2 +-
 .../WebAssembly/WebAssemblyISelLowering.cpp   |  2 +-
 .../WebAssembly/WebAssemblyInstrBulkMemory.td |  8 +--
 .../WebAssembly/WebAssemblyInstrInfo.td   |  8 +++
 .../WebAssemblySelectionDAGInfo.cpp   |  4 +-
 .../WebAssembly/WebAssemblySubtarget.cpp  |  9 
 .../Target/WebAssembly/WebAssemblySubtarget.h |  4 ++
 .../WebAssembly/WebAssemblyUtilities.cpp  |  4 +-
 llvm/test/CodeGen/WebAssembly/bulk-memory.ll  |  6 +--
 .../test/CodeGen/WebAssembly/bulk-memory64.ll |  6 +--
 .../test/CodeGen/WebAssembly/call-indirect.ll |  4 +-
 .../WebAssembly/cfg-stackify-eh-legacy.ll |  6 +--
 .../CodeGen/WebAssembly/disable-feature.ll|  4 +-
 .../CodeGen/WebAssembly/function-pointer64.ll |  4 +-
 .../WebAssembly/target-features-cpus.ll   | 54 ---
 .../WebAssembly/extern-functype-intrinsic.ll  |  4 +-
 llvm/test/MC/WebAssembly/function-alias.ll|  4 +-
 llvm/test/MC/WebAssembly/libcall.ll   |  2 +-
 33 files changed, 217 insertions(+), 64 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 999c88455b64a5..b333251fd08c8d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -854,9 +854,15 @@ and `-mbulk-memory` flags, which correspond to the [Bulk 
Memory Operations]
 and [Non-trapping float-to-int Conversions] language features, which are
 [widely implemented in engines].
 
+A new Lime1 target CPU is added, -mcpu=lime1. This CPU follows the definition 
of
+the Lime1 CPU [here], and enables -mmultivalue, -mmutable-globals,
+-mcall-indirect-overlong, -msign-ext, -mbulk-memory-opt, -mnontrapping-fptoint,
+and -mextended-const.
+
 [Bulk Memory Operations]: 
https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
 [Non-trapping float-to-int Conversions]: 
https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
 [widely implemented in engines]: https://webassembly.org/features/
+[here]: https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1
 
 AVR Support
 ^^^
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 0b380bdf835ffb..1a13cd4070a88d 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -47,6 +47,8 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   return llvm::StringSwitch(Feature)
   .Case("atomics", HasAtomics)
   .Case("bulk-memory", HasBulkMemory)
+  .Case("bulk-memory-opt", HasBulkMemoryOpt)
+  .Case("call-indirect-overlong", HasCallIndirectOverlong)
   .Case("exception-handling", HasExceptionHandling)
   .Case("extended-const", HasExtendedConst)
   .Case("fp16", HasFP16)
@@ -79,6 +81,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const 
LangOptions &Opts,
  

[clang] [lld] [llvm] [WebAssembly] Define a new "Lime1" CPU (PR #112035)

2024-11-20 Thread Dan Gohman via cfe-commits

https://github.com/sunfishcode updated 
https://github.com/llvm/llvm-project/pull/112035

>From 329d30a551639f6aeccdb805358c1b661d73d97c Mon Sep 17 00:00:00 2001
From: Dan Gohman 
Date: Fri, 11 Oct 2024 04:30:32 -0700
Subject: [PATCH] [WebAssembly] Support the new "Lime1" CPU

This adds WebAssembly support for the new [Lime1 CPU].

First, this defines some new target features. These are subsets of existing
features that reflect implementation concerns:

 - "call-indirect-overlong" - implied by "reference-types"; just the overlong
   encoding for the `call_indirect` immediate, and not the actual reference
   types.

 - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and
   `memory.fill`, and not the other instructions in the bulk-memory
proposal.

Next, this defines a new target CPU, "lime1", which enables mutable-globals,
bulk-memory-opt, multivalue, sign-ext, nontrapping-fptoint, extended-const,
and call-indirect-overlong. Unlike the default "generic" CPU, "lime1" is meant
to be frozen, and followed up by "lime2" and so on when new features are
desired.

[Lime1 CPU]: 
https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1
---
 clang/docs/ReleaseNotes.rst   |  6 +++
 clang/lib/Basic/Targets/WebAssembly.cpp   | 46 
 clang/lib/Basic/Targets/WebAssembly.h |  2 +
 lld/test/wasm/compress-relocs.ll  |  2 +-
 lld/test/wasm/import-table-explicit.s |  2 +-
 lld/test/wasm/invalid-mvp-table-use.s |  2 +-
 lld/test/wasm/lto/Inputs/libcall-archive.ll   |  2 +-
 lld/test/wasm/lto/libcall-archive.ll  |  2 +-
 lld/test/wasm/lto/stub-library-libcall.s  |  4 +-
 lld/test/wasm/multi-table.s   |  2 +-
 lld/wasm/InputFiles.cpp   | 11 ++--
 lld/wasm/SyntheticSections.cpp|  2 +-
 llvm/docs/ReleaseNotes.md |  6 +++
 .../AsmParser/WebAssemblyAsmParser.cpp| 28 +++---
 llvm/lib/Target/WebAssembly/WebAssembly.td| 28 +++---
 .../WebAssembly/WebAssemblyFastISel.cpp   |  2 +-
 .../WebAssembly/WebAssemblyISelLowering.cpp   |  2 +-
 .../WebAssembly/WebAssemblyInstrBulkMemory.td |  8 +--
 .../WebAssembly/WebAssemblyInstrInfo.td   |  8 +++
 .../WebAssemblySelectionDAGInfo.cpp   |  4 +-
 .../WebAssembly/WebAssemblySubtarget.cpp  |  9 
 .../Target/WebAssembly/WebAssemblySubtarget.h |  4 ++
 .../WebAssembly/WebAssemblyUtilities.cpp  |  4 +-
 llvm/test/CodeGen/WebAssembly/bulk-memory.ll  |  6 +--
 .../test/CodeGen/WebAssembly/bulk-memory64.ll |  6 +--
 .../test/CodeGen/WebAssembly/call-indirect.ll |  4 +-
 .../WebAssembly/cfg-stackify-eh-legacy.ll |  6 +--
 .../CodeGen/WebAssembly/disable-feature.ll|  4 +-
 .../CodeGen/WebAssembly/function-pointer64.ll |  4 +-
 .../WebAssembly/target-features-cpus.ll   | 54 ---
 .../WebAssembly/extern-functype-intrinsic.ll  |  4 +-
 llvm/test/MC/WebAssembly/function-alias.ll|  4 +-
 llvm/test/MC/WebAssembly/libcall.ll   |  2 +-
 33 files changed, 216 insertions(+), 64 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 999c88455b64a5..b333251fd08c8d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -854,9 +854,15 @@ and `-mbulk-memory` flags, which correspond to the [Bulk 
Memory Operations]
 and [Non-trapping float-to-int Conversions] language features, which are
 [widely implemented in engines].
 
+A new Lime1 target CPU is added, -mcpu=lime1. This CPU follows the definition 
of
+the Lime1 CPU [here], and enables -mmultivalue, -mmutable-globals,
+-mcall-indirect-overlong, -msign-ext, -mbulk-memory-opt, -mnontrapping-fptoint,
+and -mextended-const.
+
 [Bulk Memory Operations]: 
https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
 [Non-trapping float-to-int Conversions]: 
https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
 [widely implemented in engines]: https://webassembly.org/features/
+[here]: https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1
 
 AVR Support
 ^^^
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 0b380bdf835ffb..751a0ab69a3961 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -47,6 +47,8 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   return llvm::StringSwitch(Feature)
   .Case("atomics", HasAtomics)
   .Case("bulk-memory", HasBulkMemory)
+  .Case("bulk-memory-opt", HasBulkMemoryOpt)
+  .Case("call-indirect-overlong", HasCallIndirectOverlong)
   .Case("exception-handling", HasExceptionHandling)
   .Case("extended-const", HasExtendedConst)
   .Case("fp16", HasFP16)
@@ -79,6 +81,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const 
LangOptions &Opts,
  

[clang] Add a testcase for riscv64-linux-android triple (PR #116892)

2024-11-20 Thread via cfe-commits


@@ -311,3 +311,19 @@
 // CHECK-X86_64-GCC: Found candidate GCC installation: 
{{.*}}i686-linux-android{{[/\\]}}4.9
 // CHECK-X86_64-GCC-NEXT: Found candidate GCC installation: 
{{.*}}x86_64-linux-android{{[/\\]}}4.9
 // CHECK-X86_64-GCC-NEXT: Selected GCC installation: 
{{.*}}x86_64-linux-android{{[/\\]}}4.9
+//
+// RUN: %clang -### %s 2>&1 \
+// RUN: --target=riscv64-linux-android \
+// RUN: -march=rv64i \

hiraditya wrote:

ah seems like this wasn't needed.

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


[clang] Add a testcase for riscv64-linux-android triple (PR #116892)

2024-11-20 Thread via cfe-commits

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


[clang] [clang] hexagon: fix link order for libc/builtins (PR #117057)

2024-11-20 Thread Brian Cain via cfe-commits

https://github.com/androm3da created 
https://github.com/llvm/llvm-project/pull/117057

When linking programs with qcld, we get a link error like below:

Error: 
/inst/clang+llvm-19.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/../target/hexagon-unknown-linux-musl//usr/lib/libc.a(scalbn.lo)(.text.scalbn+0x3c):
 undefined reference to `__hexagon_muldf3'

libc has references to the clang_rt builtins library, so the order of the 
libraries should be reversed.

>From 8160738a7cce18bcc10ff25ccf670a8808c67467 Mon Sep 17 00:00:00 2001
From: Brian Cain 
Date: Wed, 20 Nov 2024 13:23:39 -0800
Subject: [PATCH] [clang] hexagon: fix link order for libc/builtins

When linking programs with qcld, we get a link error like below:

Error: 
/inst/clang+llvm-19.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/../target/hexagon-unknown-linux-musl//usr/lib/libc.a(scalbn.lo)(.text.scalbn+0x3c):
 undefined reference to `__hexagon_muldf3'

libc has references to the clang_rt builtins library, so the order of the
libraries should be reversed.
---
 clang/lib/Driver/ToolChains/Hexagon.cpp |  2 +-
 clang/test/Driver/hexagon-toolchain-linux.c | 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 29781399cbab44..383dc8387e75e7 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -378,9 +378,9 @@ constructHexagonLinkArgs(Compilation &C, const JobAction 
&JA,
   if (NeedsXRayDeps)
 linkXRayRuntimeDeps(HTC, Args, CmdArgs);
 
-  CmdArgs.push_back("-lclang_rt.builtins-hexagon");
   if (!Args.hasArg(options::OPT_nolibc))
 CmdArgs.push_back("-lc");
+  CmdArgs.push_back("-lclang_rt.builtins-hexagon");
 }
 if (D.CCCIsCXX()) {
   if (HTC.ShouldLinkCXXStdlib(Args))
diff --git a/clang/test/Driver/hexagon-toolchain-linux.c 
b/clang/test/Driver/hexagon-toolchain-linux.c
index 86cc9a30e932c6..6f7f3b20f9141f 100644
--- a/clang/test/Driver/hexagon-toolchain-linux.c
+++ b/clang/test/Driver/hexagon-toolchain-linux.c
@@ -11,7 +11,7 @@
 // CHECK000-NOT:  
{{.*}}basic_linux_libcxx_tree{{/|}}usr{{/|}}lib{{/|}}crti.o
 // CHECK000:  "-dynamic-linker={{/|}}lib{{/|}}ld-musl-hexagon.so.1"
 // CHECK000:  
"{{.*}}basic_linux_libcxx_tree{{/|}}usr{{/|}}lib{{/|}}crt1.o"
-// CHECK000:  "-lclang_rt.builtins-hexagon" "-lc"
+// CHECK000:  "-lc" "-lclang_rt.builtins-hexagon"
 // 
-
 // Passing --musl --shared
 // 
-
@@ -21,7 +21,7 @@
 // RUN:   --sysroot=%S/Inputs/basic_linux_libcxx_tree -shared %s 2>&1 | 
FileCheck -check-prefix=CHECK001 %s
 // CHECK001-NOT:-dynamic-linker={{/|}}lib{{/|}}ld-musl-hexagon.so.1
 // CHECK001:
"{{.*}}basic_linux_libcxx_tree{{/|}}usr{{/|}}lib{{/|}}crti.o"
-// CHECK001:"-lclang_rt.builtins-hexagon" "-lc"
+// CHECK001:"-lc" "-lclang_rt.builtins-hexagon"
 // CHECK001-NOT:
{{.*}}basic_linux_libcxx_tree{{/|}}usr{{/|}}lib{{/|}}crt1.o
 // 
-
 // Passing --musl -nostdlib
@@ -33,8 +33,8 @@
 // CHECK002:   
"-dynamic-linker={{/|}}lib{{/|}}ld-musl-hexagon.so.1"
 // CHECK002-NOT:   
{{.*}}basic_linux_libcxx_tree{{/|}}usr{{/|}}lib{{/|}}crti.o
 // CHECK002-NOT:   
{{.*}}basic_linux_libcxx_tree{{/|}}usr{{/|}}lib{{/|}}crt1.o
-// CHECK002-NOT:   "-lclang_rt.builtins-hexagon"
 // CHECK002-NOT:   "-lc"
+// CHECK002-NOT:   "-lclang_rt.builtins-hexagon"
 // 
-
 // Passing --musl -nostartfiles
 // 
-
@@ -45,7 +45,7 @@
 // CHECK003:   
"-dynamic-linker={{/|}}lib{{/|}}ld-musl-hexagon.so.1"
 // CHECK003-NOT:   
{{.*}}basic_linux_libcxx_tree{{/|}}usr{{/|}}lib{{/|}}Scrt1.o
 // CHECK003-NOT:   
{{.*}}basic_linux_libcxx_tree{{/|}}usr{{/|}}lib{{/|}}crt1.o
-// CHECK003:   "-lclang_rt.builtins-hexagon" "-lc"
+// CHECK003:   "-lc" "-lclang_rt.builtins-hexagon"
 // 
-
 // Passing --musl -nodefaultlibs
 // 
-
@@ -55,8 +55,8 @@
 // RUN:   --sysroot=%S/Inputs/basic_linux_libcxx_tree -nodefaultlibs %s 2>&1 | 
FileCheck -check-prefix=CHECK004 %s
 // CHECK004:   
"-dynamic-linker={{/|}}lib{{/|}}ld-musl-hexagon.so.1"
 // CHECK004:   
"{{.*}}basic_linux_libcxx_tree{{/|}}usr{{/|}}lib{{/|}}crt1.o"
-// CHECK004-NOT:   "-lclang_rt.builtins-hexagon"
 // CHECK004-NOT:   "-lc"
+// CHECK004-NOT:   "-lclang_rt.builtins-h

[clang] [ASTMatchers] AST matcher support for ObjC pointers (PR #117021)

2024-11-20 Thread Ziqing Luo via cfe-commits

https://github.com/ziqingluo-90 approved this pull request.

Neat!

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


[clang] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-20 Thread Haojian Wu via cfe-commits


@@ -32,6 +32,26 @@ void test_invalid_call(int s) {
   int var = some_func(undef1);
 }
 
+int some_func2(int a, int b);
+void test_invalid_call_2() {
+  // CHECK:   `-RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' 
lvalue (ADL) = 'some_func2'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  some_func2(1, );
+}
+
+void test_invalid_call_3() {
+  // CHECK:   `-RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: -UnresolvedLookupExpr {{.*}} '' 
lvalue (ADL) = 'some_func2'
+  some_func2(,);
+}
+
+void test_invalid_call_4() {
+  // CHECK:   `-RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: -UnresolvedLookupExpr {{.*}} '' 
lvalue (ADL) = 'some_func2'
+  some_func2(,,);

hokein wrote:

I should have been clearer earlier. I think it’s fine that clang doesn’t handle 
recovery well in this case. I’m just curious about it and not suggesting you 
address it.







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


[clang] [clang] Fix a crash issue that caused by handling of fields with initializers in nested anonymous unions (PR #113049)

2024-11-20 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

We could maybe look at setting hadError less aggressively in InitListChecker, 
for cases where the error is unlikely to impact the overall parse.  If a member 
has a RecoveryExpr as its initializer, it's probably reasonable to continue 
producing error messages.

That said, I don't really care if we suppress the second error message in your 
FibTree example.  It's not a situation I'd expect people to trip over regularly.

--

When I first looked at the pass, I didn't realize the error messages were 
coming out of delayed C++ field parsing.  I don't think the current version of 
the patch is viable: modifying RecordDecl::hasInClassInitializer() after it's 
already been queried is likely to lead to strange results.

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


[clang] [lld] [llvm] [WebAssembly] Define call-indirect-overlong and bulk-memory-opt features (PR #117087)

2024-11-20 Thread Sam Clegg via cfe-commits

sbc100 wrote:

Can you explain why you want `call-indirect-overlong` in lime1?  Is it because 
you want to be able to link files compiles with multi-table?  i.e. do you 
want/expect type relocations at every call_indirect site?   If so then perhaps 
a better name might be `call-indirect-relocatable`?   Or maybe even 
`multi-table-compatible`?  Sorry for the bikesheding and this late stage..

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


[clang] [Clang] Fix -Wunused-private-field false negative with defaulted comparison operators (PR #116871)

2024-11-20 Thread Chris White via cfe-commits


@@ -20,6 +20,17 @@ class SpaceShipDefaultCompare {
   int operator<=>(const SpaceShipDefaultCompare &) const = default;
 };
 
+class UnusedConstPrivateField {
+ public:
+  UnusedConstPrivateField() : unused_(0) {}
+ private:
+  const int unused_; // expected-warning{{private field 'unused_' is not used}}
+};
+
+class FriendEqDefaultCompare {
+  friend auto operator==(FriendEqDefaultCompare, FriendEqDefaultCompare) -> 
bool = default;

whiteio wrote:

I've updated the tests, hopefully I didn't misinterpret your comments. I added 
a non-friend method to the unrelated class and added a case where the 
comparison is defined as a friend function.

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


[clang] [Clang/AMDGPU] Zero sized arrays not allowed in HIP device code. (PR #113470)

2024-11-20 Thread Vigneshwar Jayakumar via cfe-commits


@@ -8714,6 +8714,21 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
 }
   }
 
+  // zero sized static arrays are not allowed in HIP device functions
+  if (LangOpts.CUDAIsDevice && LangOpts.HIP) {
+if (FunctionDecl *FD = getCurFunctionDecl();
+FD &&
+(FD->hasAttr() || FD->hasAttr())) {

VigneshwarJ wrote:

The reuse of that DeclAttrsMatchCUDAMode with some rechecks doesn't make sense 
because that function returns true if decl is not defined. So, inturn I have to 
check if its inside a functionDecl again else it will wrongly diagnose host 
global zero array as not permitted.

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


  1   2   3   4   5   6   >