[clang] [CodeGen][SystemZ] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126280)

2025-02-08 Thread Nikita Popov via cfe-commits

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


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


[clang] [CodeGen][XCore] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126279)

2025-02-08 Thread Nikita Popov via cfe-commits

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


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


[clang-tools-extra] [clang-tidy] Replace /* ... */ single-line comments with // ... comments (PR #124319)

2025-02-08 Thread via cfe-commits


@@ -0,0 +1,127 @@
+//===--- UseCppStyleCommentsCheck.cpp - 
clang-tidy-===//
+
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UseCppStyleCommentsCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
+#include 
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+class UseCppStyleCommentsCheck::CStyleCommentHandler : public CommentHandler {
+public:
+  CStyleCommentHandler(UseCppStyleCommentsCheck &Check)
+  : Check(Check),
+CStyleCommentMatch(
+"^[ \t]*/\\*+[ \t\r\n]*(.*[ \t\r\n]*)*[ \t\r\n]*\\*+/[ \t\r\n]*$") 
{
+  }
+
+  std::string convertToCppStyleComment(const SourceManager &SM,
+   const SourceRange &Range) {
+StringRef CommentText = Lexer::getSourceText(
+CharSourceRange::getTokenRange(Range), SM, LangOptions());
+
+std::string InnerText = CommentText.str();
+InnerText.erase(0, 2);
+InnerText.erase(InnerText.size() - 2, 2);
+
+std::string Result;
+std::istringstream Stream(InnerText);
+std::string Line;
+
+if (std::getline(Stream, Line)) {
+  size_t startPos = Line.find_first_not_of(" \t");
+  if (startPos != std::string::npos) {
+Line = Line.substr(startPos);
+  } else {
+Line.clear();
+  }
+  Result += "// " + Line;
+}
+
+while (std::getline(Stream, Line)) {
+  size_t startPos = Line.find_first_not_of(" \t");
+  if (startPos != std::string::npos) {
+Line = Line.substr(startPos);
+  } else {
+Line.clear();
+  }
+  Result += "\n// " + Line;
+}
+return Result;
+  }
+
+  bool HandleComment(Preprocessor &PP, SourceRange Range) override {
+const SourceManager &SM = PP.getSourceManager();
+
+if (Range.getBegin().isMacroID() || SM.isInSystemHeader(Range.getBegin())) 
{
+  return false;
+}
+
+const StringRef Text = Lexer::getSourceText(
+CharSourceRange::getCharRange(Range), SM, PP.getLangOpts());
+
+SmallVector Matches;
+if (!CStyleCommentMatch.match(Text, &Matches)) {
+  return false;
+}
+
+SourceLocation CommentStart = Range.getBegin();
+SourceLocation CommentEnd = Range.getEnd();
+
+unsigned StartLine = SM.getSpellingLineNumber(CommentStart);
+unsigned EndLine = SM.getSpellingLineNumber(CommentEnd);
+
+if (StartLine == EndLine) {
+  SourceLocation LineBegin =
+  SM.translateLineCol(SM.getFileID(CommentStart), StartLine, 1);
+  SourceLocation LineEnd =
+  SM.translateLineCol(SM.getFileID(CommentEnd), EndLine,
+  std::numeric_limits::max());
+  StringRef LineContent = Lexer::getSourceText(
+  CharSourceRange::getCharRange(LineBegin, LineEnd), SM,
+  PP.getLangOpts());
+  size_t CommentStartOffset = SM.getSpellingColumnNumber(CommentStart) - 1;
+  StringRef AfterComment =
+  LineContent.drop_front(CommentStartOffset + Text.size());
+
+  if (!AfterComment.trim().empty()) {
+return false;
+  }
+}
+
+Check.diag(

4m4n-x-B4w4ne wrote:

I think ignoring this type of comments will be the best option, so I am working 
on it.

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-02-08 Thread Nikita Popov via cfe-commits


@@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() {
   if (BlockDescriptorType)
 return BlockDescriptorType;
 
-  llvm::Type *UnsignedLongTy =
-getTypes().ConvertType(getContext().UnsignedLongTy);
-
-  // struct __block_descriptor {
-  //   unsigned long reserved;
-  //   unsigned long block_size;
-  //
-  //   // later, the following will be added
-  //
-  //   struct {
-  // void (*copyHelper)();
-  // void (*copyHelper)();
-  //   } helpers;// !!! optional
-  //
-  //   const char *signature;   // the block signature
-  //   const char *layout;  // reserved
-  // };

nikic wrote:

I think it's okay to drop it, essentially the same comment also exists on 
buildBlockDescriptor.

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-02-08 Thread Nikita Popov via cfe-commits


@@ -347,7 +347,7 @@ void 
CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) {
   // extern "C" int atexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidTy, false),
+ CGM.getLLVMContext(),
  dtorStub->getType()->getPointerAddressSpace()) &&
  "Argument to atexit has a wrong type.");

nikic wrote:

Should just assert `->isPointerTy()` here and below.

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-02-08 Thread Nikita Popov via cfe-commits


@@ -197,10 +198,9 @@ class Address {
 
   /// Return the type of the pointer value.
   llvm::PointerType *getType() const {
-return llvm::PointerType::get(
-ElementType,
-llvm::cast(Pointer.getPointer()->getType())
-->getAddressSpace());
+auto AS = llvm::cast(Pointer.getPointer()->getType())
+  ->getAddressSpace();
+return llvm::PointerType::get(ElementType->getContext(), AS);

nikic wrote:

Can't you directly return `Pointer.getPointer()->getType()`? No need to 
reconstruct it via addrspace.

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


[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)

2025-02-08 Thread Nikita Popov via cfe-commits


@@ -388,22 +385,16 @@ Address 
HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
   CGF.Builder.CreateStore(__new_overflow_area_pointer,
   __current_saved_reg_area_pointer_p);
 
-  // Bitcast the overflow area pointer to the type of argument.
-  llvm::Type *OverflowPTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Value *__overflow_area_p = CGF.Builder.CreateBitCast(
-  __overflow_area_pointer, llvm::PointerType::getUnqual(OverflowPTy));
-
   CGF.EmitBranch(ContBlock);
-
   // Get the correct pointer to load the variable argument
   // Implement the ContBlock
   CGF.EmitBlock(ContBlock);
 
   llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Type *MemPTy = llvm::PointerType::getUnqual(MemTy);
-  llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(MemPTy, 2, "vaarg.addr");
-  ArgAddr->addIncoming(__saved_reg_area_p, InRegBlock);
-  ArgAddr->addIncoming(__overflow_area_p, OnStackBlock);
+  llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(
+  llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr");
+  ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock);

nikic wrote:

```suggestion
  ArgAddr->addIncoming(__current_saved_reg_area_pointer, InRegBlock);
```
I think?

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


[clang] [C++20][Modules][Serialization] Add an additional test case for #120277. (PR #126349)

2025-02-08 Thread Chuanqi Xu via cfe-commits


@@ -0,0 +1,67 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t

ChuanqiXu9 wrote:

```suggestion

```

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


[clang] [C++20][Modules][Serialization] Add an additional test case for #120277. (PR #126349)

2025-02-08 Thread Chuanqi Xu via cfe-commits

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


[clang] [C++20][Modules][Serialization] Add an additional test case for #120277. (PR #126349)

2025-02-08 Thread Chuanqi Xu via cfe-commits

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

It is easier to debug without `cd %t` generally.

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


[clang] [CodeGen][AArch64] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126278)

2025-02-08 Thread Nikita Popov via cfe-commits

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


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


[clang] [clang-format] Handle C-style cast of member function pointer type (PR #126340)

2025-02-08 Thread Björn Schäpers via cfe-commits

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


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


[clang] [CodeGen][AArch64] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126278)

2025-02-08 Thread David Green via cfe-commits

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


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


[clang] [clang-cl] Accept `cl`-style output arguments (`/Fo`, `-Fo`) for `--fmodule-output` (PR #121046)

2025-02-08 Thread Sharadh Rajaraman via cfe-commits

https://github.com/sharadhr updated 
https://github.com/llvm/llvm-project/pull/121046

>From b6bda7bd5980f3ff9bb9bd680846eb1bb05ac7c7 Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman 
Date: Fri, 7 Feb 2025 21:24:12 +
Subject: [PATCH 1/2] Accept /Fo and -Fo in `-fmodule-output` when running
 under CL mode

---
 clang/lib/Driver/Driver.cpp | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 4d9492ea08f6479..36749a90750010a 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6097,10 +6097,29 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   }
 
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
+
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
-if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+bool IsCLNonPCH =
+IsCLMode() && !C.getArgs().hasArg(options::OPT__SLASH_Yc) &&
+(isa(JA) || isa(JA));
+bool HasAnyOutputArg = C.getArgs().hasArg(
+options::OPT_o, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON);
+
+Arg *FinalOutput = nullptr;
+if (IsCLNonPCH && HasAnyOutputArg) {
+  FinalOutput = C.getArgs().getLastArg(
+  options::OPT_o, options::OPT__SLASH_Fo, 
options::OPT__SLASH_Fo_COLON);
+} else if (IsCLNonPCH) {
+  FinalOutput = C.getArgs().getLastArg(options::OPT__SLASH_Fo,
+   options::OPT__SLASH_Fo_COLON);
+} else {
+  FinalOutput = C.getArgs().getLastArg(options::OPT_o);
+}
+
+if (FinalOutput) {
   return C.addResultFile(FinalOutput->getValue(), &JA);
+}
   }
 
   // For /P, preprocess to file named after BaseInput.

>From acad422d098855251252c0c5925f571f1b38631d Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman 
Date: Sat, 8 Feb 2025 21:24:53 +
Subject: [PATCH 2/2] Add a test for the -fmodule-output BMI output file

---
 clang/test/Driver/cl-cxx20-modules.cppm | 8 
 1 file changed, 8 insertions(+)

diff --git a/clang/test/Driver/cl-cxx20-modules.cppm 
b/clang/test/Driver/cl-cxx20-modules.cppm
index 43dbf517485a058..8744745019d15eb 100644
--- a/clang/test/Driver/cl-cxx20-modules.cppm
+++ b/clang/test/Driver/cl-cxx20-modules.cppm
@@ -14,3 +14,11 @@
 
 //--- test.pcm
 // CPP20WARNING-NOT: clang-cl: warning: argument unused during compilation: 
'/std:c++20' [-Wunused-command-line-argument]
+
+// test whether the following outputs %Hello.bmi
+// RUN: %clang_cl /std:c++20 --precompile -x c++-module 
-fmodule-output=%t/Hello.bmi -Fo"%t/Hello.bmi" -c %t/Hello.cppm -### 2>&1 | 
FileCheck %s
+// CHECK: "-emit-module-interface"
+// CHECK: "-o" "{{.*}}Hello.bmi"
+
+//--- Hello.cppm
+export module Hello;
\ No newline at end of file

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


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/8] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f783..1e5099067339977 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c1..bbaf8b183222e98 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc554..5a7e64d5b5a96f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497ccac..afafa8af585c712 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
- 

[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-02-08 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated 
https://github.com/llvm/llvm-project/pull/124133

>From cec28dbf72a389b80bead9e1184d2bc8b1c1e894 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Fri, 7 Feb 2025 17:08:56 +
Subject: [PATCH] CFG-based lifetime analysis using existing annotations

---
 .../Analysis/Analyses/DanglingReference.h |  27 +
 clang/include/clang/Basic/DiagnosticGroups.td |   7 +
 .../clang/Basic/DiagnosticSemaKinds.td|  19 +
 clang/lib/Analysis/CMakeLists.txt |   1 +
 clang/lib/Analysis/DanglingReference.cpp  | 878 ++
 clang/lib/Sema/AnalysisBasedWarnings.cpp  |  49 +
 clang/test/Sema/Inputs/lifetime-analysis.h|   1 +
 .../test/Sema/warn-lifetime-analysis-cfg.cpp  | 480 ++
 .../Sema/warn-lifetime-analysis-nocfg.cpp | 104 ++-
 9 files changed, 1534 insertions(+), 32 deletions(-)
 create mode 100644 clang/include/clang/Analysis/Analyses/DanglingReference.h
 create mode 100644 clang/lib/Analysis/DanglingReference.cpp
 create mode 100644 clang/test/Sema/warn-lifetime-analysis-cfg.cpp

diff --git a/clang/include/clang/Analysis/Analyses/DanglingReference.h 
b/clang/include/clang/Analysis/Analyses/DanglingReference.h
new file mode 100644
index 000..2a6f5c88ed7341f
--- /dev/null
+++ b/clang/include/clang/Analysis/Analyses/DanglingReference.h
@@ -0,0 +1,27 @@
+#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_DANGLING_REFERENCE_H
+#define LLVM_CLANG_ANALYSIS_ANALYSES_DANGLING_REFERENCE_H
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/Analysis/AnalysisDeclContext.h"
+#include "clang/Analysis/CFG.h"
+namespace clang {
+class DanglingReferenceReporter {
+public:
+  DanglingReferenceReporter() = default;
+  virtual ~DanglingReferenceReporter() = default;
+
+  virtual void ReportReturnLocalVar(const Expr *RetExpr,
+const Decl *LocalDecl) {}
+  virtual void ReportReturnTemporaryExpr(const Expr *TemporaryExpr) {}
+  virtual void ReportDanglingReference(const VarDecl *VD) {}
+  virtual void SuggestLifetimebound(const ParmVarDecl *PVD,
+const Expr *RetExpr) {}
+};
+
+void runDanglingReferenceAnalysis(const DeclContext &dc, const CFG &cfg,
+  AnalysisDeclContext &ac,
+  DanglingReferenceReporter *reporter);
+
+} // namespace clang
+
+#endif // LLVM_CLANG_ANALYSIS_ANALYSES_DANGLING_REFERENCE_H
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 594e99a19b64d61..600dca0e4a96441 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -472,6 +472,13 @@ def Dangling : DiagGroup<"dangling", [DanglingAssignment,
   DanglingInitializerList,
   DanglingGsl,
   ReturnStackAddress]>;
+def ReturnStackAddressCFG : DiagGroup<"return-stack-address-cfg">;
+def SuggestLifetimeboundCFG : DiagGroup<"suggest-lifetimebound-cfg">;
+def DanglingReferenceCFG : DiagGroup<"dangling-reference-cfg">;
+def DanglingCFG
+: DiagGroup<"dangling-cfg", [ReturnStackAddressCFG, DanglingReferenceCFG,
+ SuggestLifetimeboundCFG]>;
+
 def DistributedObjectModifiers : DiagGroup<"distributed-object-modifiers">;
 def DllexportExplicitInstantiationDecl : 
DiagGroup<"dllexport-explicit-instantiation-decl">;
 def ExcessInitializers : DiagGroup<"excess-initializers">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8be4f946dce1ccb..62da2db4a1c66eb 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10169,6 +10169,25 @@ def 
err_lifetimebound_implicit_object_parameter_void_return_type : Error<
   "parameter of a function that returns void; "
   "did you mean 'lifetime_capture_by(X)'">;
 
+// CFG based lifetime analysis.
+def warn_ret_stack_variable_ref_cfg
+: Warning<"returning reference to a stack variable">,
+  InGroup,
+  DefaultIgnore;
+def note_local_variable_declared_here
+: Note<"reference to this stack variable is returned">;
+def warn_ret_stack_temporary_ref_cfg
+: Warning<"returning reference to a temporary object">,
+  InGroup,
+  DefaultIgnore;
+def warn_dangling_reference_cfg : Warning<"reference to local object dangles">,
+  InGroup,
+  DefaultIgnore; // TODO: add note on loc of
+def warn_suggest_lifetimebound_cfg
+: Warning<"param should be marked lifetimebound">,
+  InGroup,
+  DefaultIgnore;
+
 // CHECK: returning address/reference of stack memory
 def warn_ret_stack_addr_ref : Warning<
   "%select{address of|reference to}0 stack memory associated with "
diff --git a/clang/lib/Analysis/CMakeLists.txt 
b/clang/lib/

[clang] [experimental] Detect return-stack-addr using CFG (PR #124133)

2025-02-08 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated 
https://github.com/llvm/llvm-project/pull/124133

>From 9076d28fbf8d7ee7042b9301b8b6fc7dc80c0a7b Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Fri, 7 Feb 2025 17:08:56 +
Subject: [PATCH] CFG-based lifetime analysis using existing annotations

---
 .../Analysis/Analyses/DanglingReference.h |  27 +
 clang/include/clang/Basic/DiagnosticGroups.td |   7 +
 .../clang/Basic/DiagnosticSemaKinds.td|  20 +
 clang/lib/Analysis/CMakeLists.txt |   1 +
 clang/lib/Analysis/DanglingReference.cpp  | 878 ++
 clang/lib/Sema/AnalysisBasedWarnings.cpp  |  49 +
 clang/test/Sema/Inputs/lifetime-analysis.h|   1 +
 .../test/Sema/warn-lifetime-analysis-cfg.cpp  |  17 +
 .../Sema/warn-lifetime-analysis-nocfg.cpp | 104 ++-
 9 files changed, 1072 insertions(+), 32 deletions(-)
 create mode 100644 clang/include/clang/Analysis/Analyses/DanglingReference.h
 create mode 100644 clang/lib/Analysis/DanglingReference.cpp
 create mode 100644 clang/test/Sema/warn-lifetime-analysis-cfg.cpp

diff --git a/clang/include/clang/Analysis/Analyses/DanglingReference.h 
b/clang/include/clang/Analysis/Analyses/DanglingReference.h
new file mode 100644
index 000..2a6f5c88ed7341f
--- /dev/null
+++ b/clang/include/clang/Analysis/Analyses/DanglingReference.h
@@ -0,0 +1,27 @@
+#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_DANGLING_REFERENCE_H
+#define LLVM_CLANG_ANALYSIS_ANALYSES_DANGLING_REFERENCE_H
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/Analysis/AnalysisDeclContext.h"
+#include "clang/Analysis/CFG.h"
+namespace clang {
+class DanglingReferenceReporter {
+public:
+  DanglingReferenceReporter() = default;
+  virtual ~DanglingReferenceReporter() = default;
+
+  virtual void ReportReturnLocalVar(const Expr *RetExpr,
+const Decl *LocalDecl) {}
+  virtual void ReportReturnTemporaryExpr(const Expr *TemporaryExpr) {}
+  virtual void ReportDanglingReference(const VarDecl *VD) {}
+  virtual void SuggestLifetimebound(const ParmVarDecl *PVD,
+const Expr *RetExpr) {}
+};
+
+void runDanglingReferenceAnalysis(const DeclContext &dc, const CFG &cfg,
+  AnalysisDeclContext &ac,
+  DanglingReferenceReporter *reporter);
+
+} // namespace clang
+
+#endif // LLVM_CLANG_ANALYSIS_ANALYSES_DANGLING_REFERENCE_H
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 594e99a19b64d61..a097167486ac5f5 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -472,6 +472,13 @@ def Dangling : DiagGroup<"dangling", [DanglingAssignment,
   DanglingInitializerList,
   DanglingGsl,
   ReturnStackAddress]>;
+def ReturnStackAddressCFG : DiagGroup<"return-stack-address-cfg">;
+def SuggestLifetimeboundCFG : DiagGroup<"suggest-lifetimebound-cfg">;
+def DanglingReferenceCFG : DiagGroup<"dangling-reference-cfg">;
+def DanglingCFG : DiagGroup<"dangling-cfg", [ReturnStackAddressCFG,
+ DanglingReferenceCFG,
+ SuggestLifetimeboundCFG]>;
+
 def DistributedObjectModifiers : DiagGroup<"distributed-object-modifiers">;
 def DllexportExplicitInstantiationDecl : 
DiagGroup<"dllexport-explicit-instantiation-decl">;
 def ExcessInitializers : DiagGroup<"excess-initializers">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8be4f946dce1ccb..5ea6a69f9507599 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10169,6 +10169,26 @@ def 
err_lifetimebound_implicit_object_parameter_void_return_type : Error<
   "parameter of a function that returns void; "
   "did you mean 'lifetime_capture_by(X)'">;
 
+// CFG based lifetime analysis.
+def warn_ret_stack_variable_ref_cfg
+: Warning<"returning reference to a stack variable">,
+  InGroup,
+  DefaultIgnore;
+def note_local_variable_declared_here
+: Note<"reference to this stack variable is returned">;
+def warn_ret_stack_temporary_ref_cfg
+: Warning<"returning reference to a temporary object">,
+  InGroup,
+  DefaultIgnore;
+def warn_dangling_reference_cfg
+: Warning<"reference to local object dangles">,
+  InGroup,
+  DefaultIgnore; // TODO: add note on loc of 
+def warn_suggest_lifetimebound_cfg
+: Warning<"param should be marked lifetimebound">,
+  InGroup,
+  DefaultIgnore;
+
 // CHECK: returning address/reference of stack memory
 def warn_ret_stack_addr_ref : Warning<
   "%select{address of|reference to}0 stack memory associated with "
diff --git a/clang/lib/Analysis/CMakeLists.txt 
b/clang/lib/Analys

[clang] [AVX10.2] Fix wrong intrinsic names after rename (PR #126390)

2025-02-08 Thread Mikołaj Piróg via cfe-commits

https://github.com/mikolaj-pirog created 
https://github.com/llvm/llvm-project/pull/126390

In my previous PR (#123656) to update the names of AVX10.2 intrinsics and 
mnemonics, I have erroneously deleted `_ph` from few intrinsics. This PR 
corrects this.

From c684a0a31ff8bc870991f1efb9a1a672cc6f0042 Mon Sep 17 00:00:00 2001
From: "Pirog, Mikolaj Maciej" 
Date: Sat, 8 Feb 2025 16:12:36 -0800
Subject: [PATCH] Add missing _ph to intrinsics names

---
 clang/lib/Headers/avx10_2_512convertintrin.h  |  6 ++--
 clang/lib/Headers/avx10_2convertintrin.h  | 12 +++
 .../CodeGen/X86/avx10_2_512convert-builtins.c | 18 +-
 .../CodeGen/X86/avx10_2convert-builtins.c | 36 +--
 4 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/clang/lib/Headers/avx10_2_512convertintrin.h 
b/clang/lib/Headers/avx10_2_512convertintrin.h
index 0b5fca5cda5228f..516ccc68672d636 100644
--- a/clang/lib/Headers/avx10_2_512convertintrin.h
+++ b/clang/lib/Headers/avx10_2_512convertintrin.h
@@ -213,19 +213,19 @@ _mm512_maskz_cvts2ph_hf8(__mmask64 __U, __m512h __A, 
__m512h __B) {
   (__v64qi)(__m512i)_mm512_setzero_si512());
 }
 
-static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_cvthf8(__m256i __A) {
+static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_cvthf8_ph(__m256i __A) {
   return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask(
   (__v32qi)__A, (__v32hf)(__m512h)_mm512_undefined_ph(), (__mmask32)-1);
 }
 
 static __inline__ __m512h __DEFAULT_FN_ATTRS512
-_mm512_mask_cvthf8(__m512h __W, __mmask32 __U, __m256i __A) {
+_mm512_mask_cvthf8_ph(__m512h __W, __mmask32 __U, __m256i __A) {
   return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask(
   (__v32qi)__A, (__v32hf)(__m512h)__W, (__mmask32)__U);
 }
 
 static __inline__ __m512h __DEFAULT_FN_ATTRS512
-_mm512_maskz_cvthf8(__mmask32 __U, __m256i __A) {
+_mm512_maskz_cvthf8_ph(__mmask32 __U, __m256i __A) {
   return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask(
   (__v32qi)__A, (__v32hf)(__m512h)_mm512_setzero_ph(), (__mmask32)__U);
 }
diff --git a/clang/lib/Headers/avx10_2convertintrin.h 
b/clang/lib/Headers/avx10_2convertintrin.h
index c67a5b890f1957d..cbc02e37b0cc245 100644
--- a/clang/lib/Headers/avx10_2convertintrin.h
+++ b/clang/lib/Headers/avx10_2convertintrin.h
@@ -381,37 +381,37 @@ _mm256_maskz_cvts2ph_hf8(__mmask32 __U, __m256h __A, 
__m256h __B) {
   (__v32qi)(__m256i)_mm256_setzero_si256());
 }
 
-static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvthf8(__m128i __A) {
+static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvthf8_ph(__m128i __A) {
   return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask(
   (__v16qi)__A, (__v8hf)(__m128h)_mm_undefined_ph(), (__mmask8)-1);
 }
 
-static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_cvthf8(__m128h __W,
+static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_cvthf8_ph(__m128h __W,
 __mmask8 __U,
 __m128i __A) {
   return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask(
   (__v16qi)__A, (__v8hf)(__m128h)__W, (__mmask8)__U);
 }
 
-static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_cvthf8(__mmask8 __U,
+static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_cvthf8_ph(__mmask8 
__U,
  __m128i __A) {
   return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask(
   (__v16qi)__A, (__v8hf)(__m128h)_mm_setzero_ph(), (__mmask8)__U);
 }
 
-static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_cvthf8(__m128i __A) {
+static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_cvthf8_ph(__m128i __A) {
   return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask(
   (__v16qi)__A, (__v16hf)(__m256h)_mm256_undefined_ph(), (__mmask16)-1);
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_mask_cvthf8(__m256h __W, __mmask16 __U, __m128i __A) {
+_mm256_mask_cvthf8_ph(__m256h __W, __mmask16 __U, __m128i __A) {
   return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask(
   (__v16qi)__A, (__v16hf)(__m256h)__W, (__mmask16)__U);
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_maskz_cvthf8(__mmask16 __U, __m128i __A) {
+_mm256_maskz_cvthf8_ph(__mmask16 __U, __m128i __A) {
   return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask(
   (__v16qi)__A, (__v16hf)(__m256h)_mm256_setzero_ph(), (__mmask16)__U);
 }
diff --git a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c 
b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
index 22503c640a727f2..dcf7bbc005a7c6c 100644
--- a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
+++ b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
@@ -201,22 +201,22 @@ __m512i test_mm512_maskz_cvts2ph_hf8(__mmask64 __U, 
__m512h __A, __m512h __B) {
   return _mm512_maskz_cvts2ph_hf8(__U, __A, __B);
 }
 
-__m512h test_mm512_cvthf8(__m256i __A) {
-  // CHECK-LABEL: @test_mm512_cvthf8(
+__m512h test_mm512_cvthf8_ph(__m256i __A) {
+  // CHECK-LA

[clang] [AVX10.2] Fix wrong intrinsic names after rename (PR #126390)

2025-02-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Mikołaj Piróg (mikolaj-pirog)


Changes

In my previous PR (#123656) to update the names of AVX10.2 intrinsics 
and mnemonics, I have erroneously deleted `_ph` from few intrinsics. This PR 
corrects this.

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


4 Files Affected:

- (modified) clang/lib/Headers/avx10_2_512convertintrin.h (+3-3) 
- (modified) clang/lib/Headers/avx10_2convertintrin.h (+6-6) 
- (modified) clang/test/CodeGen/X86/avx10_2_512convert-builtins.c (+9-9) 
- (modified) clang/test/CodeGen/X86/avx10_2convert-builtins.c (+18-18) 


``diff
diff --git a/clang/lib/Headers/avx10_2_512convertintrin.h 
b/clang/lib/Headers/avx10_2_512convertintrin.h
index 0b5fca5cda5228f..516ccc68672d636 100644
--- a/clang/lib/Headers/avx10_2_512convertintrin.h
+++ b/clang/lib/Headers/avx10_2_512convertintrin.h
@@ -213,19 +213,19 @@ _mm512_maskz_cvts2ph_hf8(__mmask64 __U, __m512h __A, 
__m512h __B) {
   (__v64qi)(__m512i)_mm512_setzero_si512());
 }
 
-static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_cvthf8(__m256i __A) {
+static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_cvthf8_ph(__m256i __A) {
   return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask(
   (__v32qi)__A, (__v32hf)(__m512h)_mm512_undefined_ph(), (__mmask32)-1);
 }
 
 static __inline__ __m512h __DEFAULT_FN_ATTRS512
-_mm512_mask_cvthf8(__m512h __W, __mmask32 __U, __m256i __A) {
+_mm512_mask_cvthf8_ph(__m512h __W, __mmask32 __U, __m256i __A) {
   return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask(
   (__v32qi)__A, (__v32hf)(__m512h)__W, (__mmask32)__U);
 }
 
 static __inline__ __m512h __DEFAULT_FN_ATTRS512
-_mm512_maskz_cvthf8(__mmask32 __U, __m256i __A) {
+_mm512_maskz_cvthf8_ph(__mmask32 __U, __m256i __A) {
   return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask(
   (__v32qi)__A, (__v32hf)(__m512h)_mm512_setzero_ph(), (__mmask32)__U);
 }
diff --git a/clang/lib/Headers/avx10_2convertintrin.h 
b/clang/lib/Headers/avx10_2convertintrin.h
index c67a5b890f1957d..cbc02e37b0cc245 100644
--- a/clang/lib/Headers/avx10_2convertintrin.h
+++ b/clang/lib/Headers/avx10_2convertintrin.h
@@ -381,37 +381,37 @@ _mm256_maskz_cvts2ph_hf8(__mmask32 __U, __m256h __A, 
__m256h __B) {
   (__v32qi)(__m256i)_mm256_setzero_si256());
 }
 
-static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvthf8(__m128i __A) {
+static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvthf8_ph(__m128i __A) {
   return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask(
   (__v16qi)__A, (__v8hf)(__m128h)_mm_undefined_ph(), (__mmask8)-1);
 }
 
-static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_cvthf8(__m128h __W,
+static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_cvthf8_ph(__m128h __W,
 __mmask8 __U,
 __m128i __A) {
   return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask(
   (__v16qi)__A, (__v8hf)(__m128h)__W, (__mmask8)__U);
 }
 
-static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_cvthf8(__mmask8 __U,
+static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_cvthf8_ph(__mmask8 
__U,
  __m128i __A) {
   return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask(
   (__v16qi)__A, (__v8hf)(__m128h)_mm_setzero_ph(), (__mmask8)__U);
 }
 
-static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_cvthf8(__m128i __A) {
+static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_cvthf8_ph(__m128i __A) {
   return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask(
   (__v16qi)__A, (__v16hf)(__m256h)_mm256_undefined_ph(), (__mmask16)-1);
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_mask_cvthf8(__m256h __W, __mmask16 __U, __m128i __A) {
+_mm256_mask_cvthf8_ph(__m256h __W, __mmask16 __U, __m128i __A) {
   return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask(
   (__v16qi)__A, (__v16hf)(__m256h)__W, (__mmask16)__U);
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_maskz_cvthf8(__mmask16 __U, __m128i __A) {
+_mm256_maskz_cvthf8_ph(__mmask16 __U, __m128i __A) {
   return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask(
   (__v16qi)__A, (__v16hf)(__m256h)_mm256_setzero_ph(), (__mmask16)__U);
 }
diff --git a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c 
b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
index 22503c640a727f2..dcf7bbc005a7c6c 100644
--- a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
+++ b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
@@ -201,22 +201,22 @@ __m512i test_mm512_maskz_cvts2ph_hf8(__mmask64 __U, 
__m512h __A, __m512h __B) {
   return _mm512_maskz_cvts2ph_hf8(__U, __A, __B);
 }
 
-__m512h test_mm512_cvthf8(__m256i __A) {
-  // CHECK-LABEL: @test_mm512_cvthf8(
+__m512h test_mm512_cvthf8_ph(__m256i __A) {
+  // CHECK-LABEL: @test_mm512_cvthf8_ph(
   // CHECK: call <32 x half> @llvm.x86.avx10.mask.vcvthf82ph512(
-  return _mm512_

[clang] [AVX10.2] Fix wrong intrinsic names after rename (PR #126390)

2025-02-08 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 8e61aae4a8ce938f42604b10123c3b21d4adc0b8 
c684a0a31ff8bc870991f1efb9a1a672cc6f0042 --extensions c,h -- 
clang/lib/Headers/avx10_2_512convertintrin.h 
clang/lib/Headers/avx10_2convertintrin.h 
clang/test/CodeGen/X86/avx10_2_512convert-builtins.c 
clang/test/CodeGen/X86/avx10_2convert-builtins.c
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Headers/avx10_2convertintrin.h 
b/clang/lib/Headers/avx10_2convertintrin.h
index cbc02e37b0..c419323910 100644
--- a/clang/lib/Headers/avx10_2convertintrin.h
+++ b/clang/lib/Headers/avx10_2convertintrin.h
@@ -386,15 +386,14 @@ static __inline__ __m128h __DEFAULT_FN_ATTRS128 
_mm_cvthf8_ph(__m128i __A) {
   (__v16qi)__A, (__v8hf)(__m128h)_mm_undefined_ph(), (__mmask8)-1);
 }
 
-static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_cvthf8_ph(__m128h __W,
-__mmask8 __U,
-__m128i __A) {
+static __inline__ __m128h __DEFAULT_FN_ATTRS128
+_mm_mask_cvthf8_ph(__m128h __W, __mmask8 __U, __m128i __A) {
   return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask(
   (__v16qi)__A, (__v8hf)(__m128h)__W, (__mmask8)__U);
 }
 
-static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_cvthf8_ph(__mmask8 
__U,
- __m128i __A) {
+static __inline__ __m128h __DEFAULT_FN_ATTRS128
+_mm_maskz_cvthf8_ph(__mmask8 __U, __m128i __A) {
   return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask(
   (__v16qi)__A, (__v8hf)(__m128h)_mm_setzero_ph(), (__mmask8)__U);
 }

``




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


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/8] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f783..1e5099067339977 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c1..bbaf8b183222e98 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc554..5a7e64d5b5a96f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497ccac..afafa8af585c712 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
- 

[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/8] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f783..1e5099067339977 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c1..bbaf8b183222e98 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc554..5a7e64d5b5a96f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497ccac..afafa8af585c712 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
- 

[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

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


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-02-08 Thread Wael Yehia via cfe-commits

https://github.com/w2yehia updated 
https://github.com/llvm/llvm-project/pull/124353

>From abef90fe8f46431a5fb8b7fe717c9fb65eb30266 Mon Sep 17 00:00:00 2001
From: Wael Yehia 
Date: Thu, 23 Jan 2025 00:03:15 +
Subject: [PATCH 1/8] [PGO] Add a clang option -fprofile-continuous that
 enables PGO continuous mode

---
 clang/docs/UsersManual.rst   |  8 
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  5 +++
 clang/lib/CodeGen/BackendUtil.cpp| 42 +++-
 clang/lib/Driver/ToolChains/Clang.cpp| 29 ++
 clang/test/CodeGen/profile-continuous.c  | 16 
 6 files changed, 83 insertions(+), 18 deletions(-)
 create mode 100644 clang/test/CodeGen/profile-continuous.c

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f783..1e5099067339977 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3033,6 +3033,14 @@ indexed format, regardeless whether it is produced by 
frontend or the IR pass.
   overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported
   by the target, or ``single`` otherwise.
 
+.. option:: -fprofile-continuous
+
+  Enables continuous PGO mode where profile counter updates are continuously
+  synced to a file. This option sets any neccessary modifiers (currently 
``%c``)
+  in the default profile filename and passes any necessary flags to the
+  middle-end to support this mode. Value profiling is not supported in
+  continuous mode.
+
 .. option:: -ftemporal-profile
 
   Enables the temporal profiling extension for IRPGO to improve startup time by
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c1..bbaf8b183222e98 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< 
The -O[0-3] option spec
 AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) 
is specified.
 
 CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic
+CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous PGO mode
 /// Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2721c1b5d8dc554..5a7e64d5b5a96f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], 
"fprofile-update=">,
 Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
 MarshallingInfoFlag>;
+def fprofile_continuous : Flag<["-"], "fprofile-continuous">,
+Group, Visibility<[ClangOption, CC1Option]>,
+HelpText<"Enable Continuous PGO mode">,
+MarshallingInfoFlag>;
+
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3951ad01497ccac..afafa8af585c712 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -133,6 +133,16 @@ std::string getDefaultProfileGenName() {
  : "default_%m.profraw";
 }
 
+// Path and name of file used for profile generation
+std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) {
+  std::string FileName = CodeGenOpts.InstrProfileOutput.empty()
+ ? getDefaultProfileGenName()
+ : CodeGenOpts.InstrProfileOutput;
+  if (CodeGenOpts.ContinuousProfileSync)
+FileName = "%c" + FileName;
+  return FileName;
+}
+
 class EmitAssemblyHelper {
   CompilerInstance &CI;
   DiagnosticsEngine &Diags;
@@ -550,7 +560,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
-  Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+  Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync
+   ? ("%c" + CodeGenOpts.InstrProfileOutput)
+   : CodeGenOpts.InstrProfileOutput;
   Options.Atomic = CodeGenOpts.AtomicProfileUpdate;
   return Options;
 }
@@ -811,13 +823,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
   if (CodeGenOpts.hasProfileIRInstr())
 // -fprofile-generate.
-PGOOpt = PGOOptions(
-CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
-   : 
CodeGenOpts.InstrProfileOutput,
-"", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
- 

[clang] [libc] [libcxx] [lldb] [llvm] [doc] Add Discord invite link alongside channel links (PR #126352)

2025-02-08 Thread Philip Reames via cfe-commits


@@ -149,7 +149,7 @@ Open Clang Projects
 If you hit a bug with Clang, it is very useful for us if you reduce the code
 that demonstrates the problem down to something small. There are many ways to
 do this; ask on https://discourse.llvm.org/c/clang";>Discourse,
-https://discord.com/channels/636084430946959380/636725486533345280";>Discord
+https://discord.gg/xS7Z362";>Discord

preames wrote:

Can you keep the channel link for this one, and add the invite?  

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


[clang] [libc] [libcxx] [lldb] [llvm] [doc] Add Discord invite link alongside channel links (PR #126352)

2025-02-08 Thread Philip Reames via cfe-commits

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

LGTM w/requested change.

Another option would be to expand a section on joining discord somewhere, and 
then scatter links to that in the docs instead of the invite link itself. 

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


[clang] [libc] [libcxx] [lldb] [llvm] [doc] Add Discord invite link alongside channel links (PR #126352)

2025-02-08 Thread Philip Reames via cfe-commits

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


[clang] [C++20][Modules][Serialization] Add an additional test case for #120277. (PR #126349)

2025-02-08 Thread Michael Park via cfe-commits

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


[clang] [Clang] Forward `-Xarch_ -Wl,foo` for GPU toolchains (PR #126248)

2025-02-08 Thread via cfe-commits

dyung wrote:

@jhuber6 I've seen 2 seemingly random failures of the offload-Xarch.c test on 
my mac buildbots lately. Any idea why this might be happening?

https://lab.llvm.org/buildbot/#/builders/190/builds/14302
https://lab.llvm.org/buildbot/#/builders/23/builds/7414

The test generally seems to pass, but two of the bots hit the same failure in 
this test.

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


[clang] 59cbe2f - [C++20][Modules][Serialization] Add an additional test case for #120277. (#126349)

2025-02-08 Thread via cfe-commits

Author: Michael Park
Date: 2025-02-08T22:29:23-08:00
New Revision: 59cbe2ff591d91e8375cfb4f4ba59dff49a82f4f

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

LOG: [C++20][Modules][Serialization] Add an additional test case for #120277. 
(#126349)

https://github.com/llvm/llvm-project/commit/4b35dd57b88a59b169c3471cbc398113d3bf98e8
was shipped to address https://github.com/llvm/llvm-project/issues/120277 .

It was thought to be a regression in 19.x according to this comment:
https://github.com/llvm/llvm-project/issues/120277#issuecomment-2558991129

This is a test case that fails even in 17.x but nevertheless is also
fixed by: 
https://github.com/llvm/llvm-project/commit/4b35dd57b88a59b169c3471cbc398113d3bf98e8

Added: 
clang/test/Modules/pr120277-2.cpp

Modified: 


Removed: 




diff  --git a/clang/test/Modules/pr120277-2.cpp 
b/clang/test/Modules/pr120277-2.cpp
new file mode 100644
index 000..f3a7e4743184864
--- /dev/null
+++ b/clang/test/Modules/pr120277-2.cpp
@@ -0,0 +1,66 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \
+// RUN:  -o %t/hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-02.h \
+// RUN:  -Wno-experimental-header-units -fmodule-file=%t/hu-01.pcm -o 
%t/hu-02.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-03.h \
+// RUN:  -Wno-experimental-header-units \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-04.h \
+// RUN:  -Wno-experimental-header-units -fmodule-file=%t/hu-02.pcm \
+// RUN:  -fmodule-file=%t/hu-03.pcm -o %t/hu-04.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-obj %t/main.cpp \
+// RUN:  -Wno-experimental-header-units -fmodule-file=%t/hu-04.pcm
+//--- hu-01.h
+template 
+struct A {
+  ~A() { f(); }
+  auto f() const { return 0; }
+};
+
+template 
+struct B {
+  int g() const { return a.f(); }
+  A a;
+};
+
+//--- hu-02.h
+import "hu-01.h";
+
+template 
+struct C {
+  void h() {
+B().g();
+  }
+};
+
+template struct A;
+
+//--- hu-03.h
+import "hu-01.h";
+
+inline B b() {
+  return {};
+}
+
+//--- hu-04.h
+import "hu-02.h";
+import "hu-03.h";
+
+inline void f4() {
+  C{}.h();
+}
+
+//--- main.cpp
+import "hu-04.h";
+
+int main() {
+  f4();
+}



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


[clang] [clang-format] Add null-terminated path option (#123921) (PR #123926)

2025-02-08 Thread Nikolaos Chatzikonstantinou via cfe-commits


@@ -260,15 +265,13 @@ def main():
 "Ignoring the following files (wrong extension, symlink, or "
 "ignored by clang-format):"
 )
-for filename in ignored_files:
-print("%s" % filename)
+print_filenames(ignored_files, opts.print0)

createyourpersonalaccount wrote:

@HazardyKnusperkeks Do you have an input on this? Right now it's just ignoring 
`--verbose`.

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


[clang] [clang-format] Add null-terminated path option (#123921) (PR #123926)

2025-02-08 Thread Nikolaos Chatzikonstantinou via cfe-commits

createyourpersonalaccount wrote:

@owenca ping

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


[clang] [C++20][Modules][Serialization] Add an additional test case for #120277. (PR #126349)

2025-02-08 Thread Michael Park via cfe-commits

https://github.com/mpark updated 
https://github.com/llvm/llvm-project/pull/126349

>From eac633d78359245f1ce478b5f3cff26c6f5c858f Mon Sep 17 00:00:00 2001
From: Michael Park 
Date: Fri, 7 Feb 2025 21:23:26 -0800
Subject: [PATCH 1/2] [C++20][Modules][Serialization] Add an additional test
 case for #120277.

https://github.com/llvm/llvm-project/commit/4b35dd57b88a59b169c3471cbc398113d3bf98e8
was shipped to address https://github.com/llvm/llvm-project/issues/120277 .

It was thought to be a regression in 19.x according to this comment:
https://github.com/llvm/llvm-project/issues/120277#issuecomment-2558991129

This is a test case that fails even in 17.x but nevertheless is also fixed by:
https://github.com/llvm/llvm-project/commit/4b35dd57b88a59b169c3471cbc398113d3bf98e8
 .
---
 clang/test/Modules/pr120277-2.cpp | 67 +++
 1 file changed, 67 insertions(+)
 create mode 100644 clang/test/Modules/pr120277-2.cpp

diff --git a/clang/test/Modules/pr120277-2.cpp 
b/clang/test/Modules/pr120277-2.cpp
new file mode 100644
index 000..21d24207c920dac
--- /dev/null
+++ b/clang/test/Modules/pr120277-2.cpp
@@ -0,0 +1,67 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \
+// RUN:  -o %t/hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-02.h \
+// RUN:  -Wno-experimental-header-units -fmodule-file=%t/hu-01.pcm -o 
%t/hu-02.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-03.h \
+// RUN:  -Wno-experimental-header-units \
+// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-04.h \
+// RUN:  -Wno-experimental-header-units -fmodule-file=%t/hu-02.pcm \
+// RUN:  -fmodule-file=%t/hu-03.pcm -o %t/hu-04.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-obj %t/main.cpp \
+// RUN:  -Wno-experimental-header-units -fmodule-file=%t/hu-04.pcm
+//--- hu-01.h
+template 
+struct A {
+  ~A() { f(); }
+  auto f() const { return 0; }
+};
+
+template 
+struct B {
+  int g() const { return a.f(); }
+  A a;
+};
+
+//--- hu-02.h
+import "hu-01.h";
+
+template 
+struct C {
+  void h() {
+B().g();
+  }
+};
+
+template struct A;
+
+//--- hu-03.h
+import "hu-01.h";
+
+inline B b() {
+  return {};
+}
+
+//--- hu-04.h
+import "hu-02.h";
+import "hu-03.h";
+
+inline void f4() {
+  C{}.h();
+}
+
+//--- main.cpp
+import "hu-04.h";
+
+int main() {
+  f4();
+}

>From 8fd10c5268bcd4732cf1b69eaed23694f8bf69d9 Mon Sep 17 00:00:00 2001
From: Michael Park 
Date: Sat, 8 Feb 2025 22:28:06 -0800
Subject: [PATCH 2/2] Update clang/test/Modules/pr120277-2.cpp

Co-authored-by: Chuanqi Xu 
---
 clang/test/Modules/pr120277-2.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/test/Modules/pr120277-2.cpp 
b/clang/test/Modules/pr120277-2.cpp
index 21d24207c920dac..f3a7e4743184864 100644
--- a/clang/test/Modules/pr120277-2.cpp
+++ b/clang/test/Modules/pr120277-2.cpp
@@ -1,7 +1,6 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
 // RUN: split-file %s %t
-// RUN: cd %t
 
 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \
 // RUN:  -o %t/hu-01.pcm

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


[clang] [C++20][Modules][Serialization] Add an additional test case for #120277. (PR #126349)

2025-02-08 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` 
running on `doug-worker-5` while building `clang` at step 6 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/190/builds/14342


Here is the relevant piece of the build log for the reference

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: Driver/offload-Xarch.c' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
--target=x86_64-unknown-linux-gnu -x cuda 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
 -Xarch_nvptx64 -O3 -S -nogpulib -nogpuinc -### 2>&1 | 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=O3ONCE 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
--target=x86_64-unknown-linux-gnu -x cuda 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
 -Xarch_nvptx64 -O3 -S -nogpulib -nogpuinc -###
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=O3ONCE 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
RUN: at line 2: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -x 
cuda 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
 -Xarch_device -O3 -S -nogpulib -nogpuinc -### 2>&1 | 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=O3ONCE 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -x cuda 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
 -Xarch_device -O3 -S -nogpulib -nogpuinc -###
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=O3ONCE 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
RUN: at line 3: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -x 
hip 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
 -Xarch_amdgcn -O3 -S -nogpulib -nogpuinc -### 2>&1 | 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=O3ONCE 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -x hip 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
 -Xarch_amdgcn -O3 -S -nogpulib -nogpuinc -###
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=O3ONCE 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
RUN: at line 4: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
-fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -nogpulib -nogpuinc
-Xarch_amdgcn -march=gfx90a -Xarch_amdgcn -O3 -S -### 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
 2>&1  | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=O3ONCE 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -fopenmp=libomp 
-fopenmp-targets=amdgcn-amd-amdhsa -nogpulib -nogpuinc -Xarch_amdgcn 
-march=gfx90a -Xarch_amdgcn -O3 -S -### 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=O3ONCE 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
RUN: at line 7: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
-fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -nogpulib -nogpuinc
-Xarch_nvptx64 -march=sm_52 -Xarch_nvptx64 -O3 -S -### 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
 2>&1  | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=O3ONCE 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -nogpulib -nogpuinc -Xarch_nvptx64 
-march=sm_52 -Xarch_nvptx64 -O3 -S -### 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=O3ONCE 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Driver/offload-Xarch.c
RUN: at line 13: /Users/buildbot/buildbot

[clang] [C++20][Modules][Serialization] Add an additional test case for #120277. (PR #126349)

2025-02-08 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-android` running on `sanitizer-buildbot-android` while 
building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/186/builds/6367


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[ DISABLED ] AddressSanitizer.DISABLED_TSDTest
[ RUN  ] AddressSanitizer.IgnoreTest
[   OK ] AddressSanitizer.IgnoreTest (0 ms)
[ RUN  ] AddressSanitizer.SignalTest
[   OK ] AddressSanitizer.SignalTest (175 ms)
[ RUN  ] AddressSanitizer.ReallocTest
[   OK ] AddressSanitizer.ReallocTest (45 ms)
[ RUN  ] AddressSanitizer.WrongFreeTest
[   OK ] AddressSanitizer.WrongFreeTest (122 ms)
[ RUN  ] AddressSanitizer.LongJmpTest
[   OK ] AddressSanitizer.LongJmpTest (0 ms)
[ RUN  ] AddressSanitizer.ThreadStackReuseTest
[   OK ] AddressSanitizer.ThreadStackReuseTest (10 ms)
[ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest
[ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest
[ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest
[ RUN  ] AddressSanitizer.UseThenFreeThenUseTest
[   OK ] AddressSanitizer.UseThenFreeThenUseTest (131 ms)
[ RUN  ] AddressSanitizer.FileNameInGlobalReportTest
[   OK ] AddressSanitizer.FileNameInGlobalReportTest (124 ms)
[ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest
[ RUN  ] AddressSanitizer.MlockTest
[   OK ] AddressSanitizer.MlockTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFHigh
[ DISABLED ] AddressSanitizer.DISABLED_DemoOOM
[ DISABLED ] AddressSanitizer.DISABLED_DemoDoubleFreeTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoNullDerefTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoFunctionStaticTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoTooMuchMemoryTest
[ RUN  ] AddressSanitizer.LongDoubleNegativeTest
[   OK ] AddressSanitizer.LongDoubleNegativeTest (0 ms)
[--] 19 tests from AddressSanitizer (25635 ms total)

[--] Global test environment tear-down
[==] 22 tests from 2 test suites ran. (25640 ms total)
[  PASSED  ] 22 tests.

  YOU HAVE 1 DISABLED TEST

skipping tests on aarch64

How to reproduce locally: 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild

@@@STEP_FAILURE@@@
Step 9 (run cmake) failure: run cmake (failure)
...
-- Compiling and running to test HAVE_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Compiling and running to test HAVE_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Compiling and running to test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- compiled but failed to run
-- Compiling and running to test HAVE_STEADY_CLOCK
CMake Warning at 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/third-party/benchmark/CMakeLists.txt:319
 (message):
  Using std::regex with exceptions disabled is not fully supported
-- Performing Test HAVE_POSIX_REGEX -- compiled but failed to run
CMake Warning at 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/third-party/benchmark/CMakeLists.txt:319
 (message):
  Using std::regex with exceptions disabled is not fully supported
-- Compiling and running to test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- compiled but failed to run
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test HAVE_POSIX_REGEX -- compiled but failed to run
CMake Warning at 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/third-party/benchmark/CMakeLists.txt:319
 (message):
  Using std::regex with exceptions disabled is not fully supported
-- Compiling and running to test HAVE_STEADY_CLOCK
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Compiling and running to test HAVE_PTHREAD_AFFINITY
-- Performing Test HAVE_STEADY_CLOCK -- compiled but failed to run
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test HAVE_STEADY_CLOCK -- compiled but failed to run
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Performing Test HAVE_PTHREAD_AFFINITY -- failed to compile
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- 

[clang] [C++20][Modules][Serialization] Add an additional test case for #120277. (PR #126349)

2025-02-08 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-remote-linux-ubuntu` 
running on `as-builder-9` while building `clang` at step 16 
"test-check-lldb-api".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/195/builds/4650


Here is the relevant piece of the build log for the reference

```
Step 16 (test-check-lldb-api) failure: Test just built components: 
check-lldb-api completed (failure)
...
PASS: lldb-api :: types/TestCharTypeExpr.py (1219 of 1228)
PASS: lldb-api :: types/TestIntegerType.py (1220 of 1228)
PASS: lldb-api :: types/TestRecursiveTypes.py (1221 of 1228)
PASS: lldb-api :: python_api/watchpoint/watchlocation/TestTargetWatchAddress.py 
(1222 of 1228)
PASS: lldb-api :: types/TestIntegerTypeExpr.py (1223 of 1228)
PASS: lldb-api :: types/TestShortType.py (1224 of 1228)
PASS: lldb-api :: types/TestLongTypes.py (1225 of 1228)
PASS: lldb-api :: types/TestShortTypeExpr.py (1226 of 1228)
PASS: lldb-api :: types/TestLongTypesExpr.py (1227 of 1228)
TIMEOUT: lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py (1228 
of 1228)
 TEST 'lldb-api :: 
python_api/process/cancel_attach/TestCancelAttach.py' FAILED 

Script:
--
/usr/bin/python3.12 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib
 --env 
LLVM_INCLUDE_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include
 --env 
LLVM_TOOLS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin
 --libcxx-include-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/c++/v1
 --libcxx-include-target-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/aarch64-unknown-linux-gnu/c++/v1
 --libcxx-library-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib/aarch64-unknown-linux-gnu
 --arch aarch64 --build-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex
 --lldb-module-cache-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/lldb 
--compiler 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang 
--dsymutil 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/dsymutil
 --make /usr/bin/gmake --llvm-tools-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin 
--lldb-obj-root 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb 
--lldb-libs-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib 
--platform-url connect://jetson-agx-2198.lab.llvm.org:1234 
--platform-working-dir /home/ubuntu/lldb-tests --sysroot 
/mnt/fs/jetson-agx-ubuntu --env ARCH_CFLAGS=-mcpu=cortex-a78 --platform-name 
remote-linux --skip-category=lldb-server 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/python_api/process/cancel_attach
 -p TestCancelAttach.py
--
Exit Code: -9
Timeout: Reached timeout of 600 seconds

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
59cbe2ff591d91e8375cfb4f4ba59dff49a82f4f)
  clang revision 59cbe2ff591d91e8375cfb4f4ba59dff49a82f4f
  llvm revision 59cbe2ff591d91e8375cfb4f4ba59dff49a82f4f

--
Command Output (stderr):
--
WARNING:root:Custom libc++ is not supported for remote runs: ignoring --libcxx 
arguments
FAIL: LLDB 
(/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64)
 :: test_scripted_implementation 
(TestCancelAttach.AttachCancelTestCase.test_scripted_implementation)

--


Slowest Tests:
--
600.04s: lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py
180.95s: lldb-api :: commands/command/script_alias/TestCommandScriptAlias.py
70.34s: lldb-api :: commands/process/attach/TestProcessAttach.py
40.59s: lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
34.76s: lldb-api :: functionalities/completion/TestCompletion.py
34.26s: lldb-api :: 
functionalities/single-thread-step/TestSingleThreadStepTimeout.py
24.74s: lldb-api :: 
python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
20.83s: lldb-api :: commands/statistics/basic/TestStats.py
20.67s: lldb-api :: functionalities/gdb_remote_client/TestPlatformClient.py
19.08s: lldb-api :: functionalities/thread/state/TestThreadStates.py
18.16s: lldb-api :: commands/dwim-print/TestDWIMPrint.py

[clang] [Clang] Forward `-Xarch_ -Wl,foo` for GPU toolchains (PR #126248)

2025-02-08 Thread via cfe-commits

dyung wrote:

And just now another failure: 
https://lab.llvm.org/buildbot/#/builders/190/builds/14342

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


[clang] 8d373ce - [clang-format] Handle C-style cast of member function pointer type (#126340)

2025-02-08 Thread via cfe-commits

Author: Owen Pan
Date: 2025-02-08T23:22:33-08:00
New Revision: 8d373ceaec1f1b27c9e682cfaf71aae19ea48d98

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

LOG: [clang-format] Handle C-style cast of member function pointer type 
(#126340)

Fixes #125012.

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 94fd7ba9c0e79e3..b3540f39e6f69fc 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -477,8 +477,9 @@ class AnnotatingParser {
 FormatToken *PossibleObjCForInToken = nullptr;
 while (CurrentToken) {
   const auto &Prev = *CurrentToken->Previous;
+  const auto *PrevPrev = Prev.Previous;
   if (Prev.is(TT_PointerOrReference) &&
-  Prev.Previous->isOneOf(tok::l_paren, tok::coloncolon)) {
+  PrevPrev->isOneOf(tok::l_paren, tok::coloncolon)) {
 ProbablyFunctionType = true;
   }
   if (CurrentToken->is(tok::comma))
@@ -486,8 +487,10 @@ class AnnotatingParser {
   if (Prev.is(TT_BinaryOperator))
 Contexts.back().IsExpression = true;
   if (CurrentToken->is(tok::r_paren)) {
-if (Prev.is(TT_PointerOrReference) && Prev.Previous == &OpeningParen)
+if (Prev.is(TT_PointerOrReference) &&
+(PrevPrev == &OpeningParen || PrevPrev->is(tok::coloncolon))) {
   MightBeFunctionType = true;
+}
 if (OpeningParen.isNot(TT_CppCastLParen) && MightBeFunctionType &&
 ProbablyFunctionType && CurrentToken->Next &&
 (CurrentToken->Next->is(tok::l_paren) ||

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 1b09c4570345622..54d8ff0571ca686 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -874,6 +874,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsCasts) {
   EXPECT_TOKEN(Tokens[14], tok::r_paren, TT_CastRParen);
   EXPECT_TOKEN(Tokens[15], tok::amp, TT_UnaryOperator);
 
+  Tokens = annotate("return (Foo (Bar::*)())&Bar::foo;");
+  ASSERT_EQ(Tokens.size(), 17u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::l_paren, TT_FunctionTypeLParen);
+  EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_CastRParen);
+  EXPECT_TOKEN(Tokens[11], tok::amp, TT_UnaryOperator);
+
   auto Style = getLLVMStyle();
   Style.TypeNames.push_back("Foo");
   Tokens = annotate("#define FOO(bar) foo((Foo)&bar)", Style);



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


[clang] [clang-format] Handle C-style cast of member function pointer type (PR #126340)

2025-02-08 Thread Owen Pan via cfe-commits

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


[clang] [clang] Force AttributedStmtClass to not be scope parents (PR #125370)

2025-02-08 Thread Yutong Zhu via cfe-commits

YutongZhuu wrote:

> Could you add a test case - check in clang/test to see if other tests for the 
> diagnostic text in the original bug, and add a test case for that nearby 
> (maybe the same file the diagnostic is already tested in)?

Done

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


[clang] [clang-format] Support BraceWrapping.AfterNamespace with AllowShortNamespacesOnASingleLine (PR #123010)

2025-02-08 Thread Owen Pan via cfe-commits


@@ -28430,6 +28430,36 @@ TEST_F(FormatTest, ShortNamespacesOption) {
   "}}} // namespace foo::bar::baz",
   "namespace foo { namespace bar { namespace baz { class qux; } } }",
   Style);
+  Style.FixNamespaceComments = false;
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterNamespace = true;
+  verifyFormat("namespace foo { class bar; }", Style);
+  verifyFormat("namespace foo { namespace bar { class baz; } }", Style);
+  verifyFormat("namespace foo\n"
+   "{ // comment\n"
+   "class bar;\n"
+   "}",
+   Style);
+  verifyFormat("namespace foo { class bar; }",
+   "namespace foo {\n"
+   "class bar;\n"
+   "}",
+   Style);
+
+  verifyFormat("namespace foo\n"
+   "{\n"
+   "namespace bar\n"
+   "{ // comment\n"
+   "class baz;\n"
+   "}\n"
+   "}\n",

owenca wrote:

```suggestion
   "}",
```

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


[clang] [clang-format] Support BraceWrapping.AfterNamespace with AllowShortNamespacesOnASingleLine (PR #123010)

2025-02-08 Thread Owen Pan via cfe-commits


@@ -367,8 +367,12 @@ class LineJoiner {
 
 if (Style.AllowShortNamespacesOnASingleLine &&
 TheLine->First->is(tok::kw_namespace) &&
-TheLine->Last->is(tok::l_brace)) {
-  const auto result = tryMergeNamespace(I, E, Limit);
+((Style.BraceWrapping.AfterNamespace &&
+  NextLine.First->is(tok::l_brace)) ||
+ (!Style.BraceWrapping.AfterNamespace &&
+  TheLine->Last->is(tok::l_brace {

owenca wrote:

I would move this into `tryMergeNamespace()`.

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


[clang] [clang-format] Support BraceWrapping.AfterNamespace with AllowShortNamespacesOnASingleLine (PR #123010)

2025-02-08 Thread Owen Pan via cfe-commits


@@ -28430,6 +28430,36 @@ TEST_F(FormatTest, ShortNamespacesOption) {
   "}}} // namespace foo::bar::baz",
   "namespace foo { namespace bar { namespace baz { class qux; } } }",
   Style);
+  Style.FixNamespaceComments = false;
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterNamespace = true;
+  verifyFormat("namespace foo { class bar; }", Style);
+  verifyFormat("namespace foo { namespace bar { class baz; } }", Style);
+  verifyFormat("namespace foo\n"
+   "{ // comment\n"

owenca wrote:

Changing this line to:
```c++
//
{
```
would result in:
```
With diff:
@@ -1,5 +1,3 @@
 namespace foo
 //
-{
-class bar;
-}
+{ class bar; }
```

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


[clang] [clang-format] Support BraceWrapping.AfterNamespace with AllowShortNamespacesOnASingleLine (PR #123010)

2025-02-08 Thread Owen Pan via cfe-commits


@@ -28430,6 +28430,36 @@ TEST_F(FormatTest, ShortNamespacesOption) {
   "}}} // namespace foo::bar::baz",
   "namespace foo { namespace bar { namespace baz { class qux; } } }",
   Style);
+  Style.FixNamespaceComments = false;
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterNamespace = true;
+  verifyFormat("namespace foo { class bar; }", Style);
+  verifyFormat("namespace foo { namespace bar { class baz; } }", Style);
+  verifyFormat("namespace foo\n"
+   "{ // comment\n"
+   "class bar;\n"
+   "}",
+   Style);
+  verifyFormat("namespace foo { class bar; }",
+   "namespace foo {\n"
+   "class bar;\n"
+   "}",
+   Style);
+
+  verifyFormat("namespace foo\n"
+   "{\n"
+   "namespace bar\n"
+   "{ // comment\n"
+   "class baz;\n"
+   "}\n"
+   "}\n",
+   Style);
+  verifyFormat("namespace foo // comment\n"
+   "{\n"
+   "class baz;\n"
+   "}\n",

owenca wrote:

Ditto.

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


[clang] [CSKY] Default to unsigned char (PR #115961)

2025-02-08 Thread Alexander Richardson via cfe-commits

arichardson wrote:

> LGTM. But I think commit msg should be refined(this PR is not for 
> upstreaming?)

Thanks for reviewing!
Sorry what do you mean by commit message needs to be refined? I created this 
using the spr tool and when merging the description of the PR will be used. Is 
there something wrong with the description?

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


[clang] [clang-format] Improve function pointer CastRParen detection. (PR #126019)

2025-02-08 Thread via cfe-commits


@@ -874,6 +874,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsCasts) {
   EXPECT_TOKEN(Tokens[14], tok::r_paren, TT_CastRParen);
   EXPECT_TOKEN(Tokens[15], tok::amp, TT_UnaryOperator);
 
+  Tokens = annotate("func((foo(bar::*)(void))&a);");

rmarker wrote:

Ah, I was so focused on the behaviour from 19, that I didn't realise about the 
space after the return type.
Yeah, it seems like even with missing the annotation of the left paren 
clang-format 19, managed to get lucky with the right cast paren. With the extra 
fix in 20 revealing the underlying issue.
Nice work.

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


[clang] [RFC][clang][BPF] Make trivial uninit var value to be 0 (PR #125601)

2025-02-08 Thread via cfe-commits

yonghong-song wrote:

> what veristat says before/after?

I tried with latest bpf-next and latest llvm trunk. The following is the 
difference
with/without this patch:
```
[~/work/bpf-next/tools/testing/selftests/bpf (master)]$ ./veristat *.bpf.o -o 
csv > old.csv
[~/work/bpf-next/tools/testing/selftests/bpf (master)]$ ./veristat *.bpf.o -o 
csv > new.csv
[~/work/bpf-next/tools/testing/selftests/bpf (master)]$ ./veristat -e 
file,prog,insns -C old.csv new.csv -f 'insns_diff!=0'
File Program Insns (A)  
Insns (B)  Insns  (DIFF)
---  --  -  
-  -
cgroup_skb_sk_lookup_kern.bpf.o  ingress_lookup 96  
  106  +10 (+10.42%)
cgroup_tcp_skb.bpf.o client_egress  94  
  104  +10 (+10.64%)
cgroup_tcp_skb.bpf.o client_egress_srv 115  
  125   +10 (+8.70%)
cgroup_tcp_skb.bpf.o client_ingress115  
  125   +10 (+8.70%)
cgroup_tcp_skb.bpf.o client_ingress_srv 94  
  104  +10 (+10.64%)
cgroup_tcp_skb.bpf.o server_egress 115  
  125   +10 (+8.70%)
cgroup_tcp_skb.bpf.o server_egress_srv  94  
  104  +10 (+10.64%)
cgroup_tcp_skb.bpf.o server_ingress129  
  139   +10 (+7.75%)
cgroup_tcp_skb.bpf.o server_ingress_srv137  
  147   +10 (+7.30%)
verifier_array_access.bpf.o  an_array_with_a_constant_too_small  7  
9   +2 (+28.57%)
[~/work/bpf-next/tools/testing/selftests/bpf (master)]$
```
For cgroup_tcp_skb.c, e.g.,
```
SEC("cgroup_skb/egress")
int server_egress_srv(struct __sk_buff *skb)
{
struct tcphdr tcph;

if (!needed_tcp_pkt(skb, &tcph))
return 1;
...
```
the tcphdr is larger so it costs more with initializing to 0.
The same for cgroup_skb_sk_lookup_kern.c.

For verifier_array_access.c,
```
SEC("socket")
__description("invalid map access into an array using constant smaller than 
key_size")
__failure __msg("R0 invalid mem access 'map_value_or_null'")
unsigned int an_array_with_a_constant_too_small(void)
{   
__u32 __attribute__((aligned(8))) key;
struct test_val *val;

/* Mark entire key as STACK_MISC */
bpf_probe_read_user(&key, sizeof(key), NULL);
...
}
```
the 'key' is initialized.

> 
> re: selftests
> 
> there should be a flag to disable this, so the tests can remain as-is (with 
> only Makefile change).

Will do.

> 
> There is also -ftrivial-auto-var-init-max-size= flag. What is the default? 
> Looks like: char buf[64]; will be zero inited as well? 

The default is 0 (-ftrivial-auto-var-init-max-size=0) which means there is no 
limitation.
yes, char buf[64] and all buf[64] will be initialized to 0 if the compiler does 
not know whehter any buf[i](i = 0...63) is used or not.

>That will probably hurt performance/verification for cases like: char 
>comm[16]; bpf_get_current_comm(comm, ...) ?
I checked. In almost all cases in bpf selftest progs, comm[16] is a field in a 
map, so it is not impacted.



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


[clang] [clang-format] Support BraceWrapping.AfterNamespace with AllowShortNamespacesOnASingleLine (PR #123010)

2025-02-08 Thread Owen Pan via cfe-commits


@@ -628,28 +632,36 @@ class LineJoiner {
 
   unsigned tryMergeNamespace(ArrayRef::const_iterator I,
  ArrayRef::const_iterator E,
- unsigned Limit) {
+ unsigned Limit, bool OpenBraceWrapped) {

owenca wrote:

You don't need the new parameter as `Style` is visible in this function.

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


[clang] [flang] [lld] [Flang] Rename libFortranRuntime.a to libflang_rt.runtime.a (PR #122341)

2025-02-08 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lld-x86_64-win` running on 
`as-worker-93` while building `clang,flang,lld` at step 7 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/146/builds/2255


Here is the relevant piece of the build log for the reference

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM-Unit :: Support/./SupportTests.exe/38/87' 
FAILED 
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-16244-38-87.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=87 GTEST_SHARD_INDEX=38 
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe 
--gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): 
error: Expected equality of these values:
  0
  RC
Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): 
error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied







```



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


[clang] [clang-format] Improve function pointer CastRParen detection. (PR #126019)

2025-02-08 Thread via cfe-commits

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


[clang] [AST] Avoid repeated hash lookups (NFC) (PR #126400)

2025-02-08 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/126400

None

>From b070c73dc8c47453ff3cc803d55ebdb79e38172d Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 8 Feb 2025 13:34:44 -0800
Subject: [PATCH] [AST] Avoid repeated hash lookups (NFC)

---
 clang/lib/AST/VTableBuilder.cpp | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index fa3055dd1206f41..19d76df99dbe310 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -1169,12 +1169,13 @@ void ItaniumVTableBuilder::ComputeThisAdjustments() {
   //
   // Do not set ThunkInfo::Method if Idx is already in VTableThunks. This
   // can happen when covariant return adjustment is required too.
-  if (!VTableThunks.count(Idx)) {
+  auto [It, Inserted] = VTableThunks.try_emplace(Idx);
+  if (Inserted) {
 const CXXMethodDecl *Method = VTables.findOriginalMethodInMap(MD);
-VTableThunks[Idx].Method = Method;
-VTableThunks[Idx].ThisType = Method->getThisType().getTypePtr();
+It->second.Method = Method;
+It->second.ThisType = Method->getThisType().getTypePtr();
   }
-  VTableThunks[Idx].This = ThisAdjustment;
+  It->second.This = ThisAdjustment;
 };
 
 SetThisAdjustmentThunk(VTableIndex);
@@ -1653,8 +1654,9 @@ void ItaniumVTableBuilder::AddMethods(
 // findOriginalMethod to find the method that created the entry if the
 // method in the entry requires adjustment.
 if (!ReturnAdjustment.isEmpty()) {
-  VTableThunks[Components.size()].Method = MD;
-  VTableThunks[Components.size()].ThisType = 
MD->getThisType().getTypePtr();
+  auto &VTT = VTableThunks[Components.size()];
+  VTT.Method = MD;
+  VTT.ThisType = MD->getThisType().getTypePtr();
 }
 
 AddMethod(Overrider.Method, ReturnAdjustment);

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


[clang] [AST] Avoid repeated hash lookups (NFC) (PR #126400)

2025-02-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes



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


1 Files Affected:

- (modified) clang/lib/AST/VTableBuilder.cpp (+8-6) 


``diff
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index fa3055dd1206f41..19d76df99dbe310 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -1169,12 +1169,13 @@ void ItaniumVTableBuilder::ComputeThisAdjustments() {
   //
   // Do not set ThunkInfo::Method if Idx is already in VTableThunks. This
   // can happen when covariant return adjustment is required too.
-  if (!VTableThunks.count(Idx)) {
+  auto [It, Inserted] = VTableThunks.try_emplace(Idx);
+  if (Inserted) {
 const CXXMethodDecl *Method = VTables.findOriginalMethodInMap(MD);
-VTableThunks[Idx].Method = Method;
-VTableThunks[Idx].ThisType = Method->getThisType().getTypePtr();
+It->second.Method = Method;
+It->second.ThisType = Method->getThisType().getTypePtr();
   }
-  VTableThunks[Idx].This = ThisAdjustment;
+  It->second.This = ThisAdjustment;
 };
 
 SetThisAdjustmentThunk(VTableIndex);
@@ -1653,8 +1654,9 @@ void ItaniumVTableBuilder::AddMethods(
 // findOriginalMethod to find the method that created the entry if the
 // method in the entry requires adjustment.
 if (!ReturnAdjustment.isEmpty()) {
-  VTableThunks[Components.size()].Method = MD;
-  VTableThunks[Components.size()].ThisType = 
MD->getThisType().getTypePtr();
+  auto &VTT = VTableThunks[Components.size()];
+  VTT.Method = MD;
+  VTT.ThisType = MD->getThisType().getTypePtr();
 }
 
 AddMethod(Overrider.Method, ReturnAdjustment);

``




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


[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)

2025-02-08 Thread Mats Jun Larsen via cfe-commits


@@ -388,22 +385,16 @@ Address 
HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
   CGF.Builder.CreateStore(__new_overflow_area_pointer,
   __current_saved_reg_area_pointer_p);
 
-  // Bitcast the overflow area pointer to the type of argument.
-  llvm::Type *OverflowPTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Value *__overflow_area_p = CGF.Builder.CreateBitCast(
-  __overflow_area_pointer, llvm::PointerType::getUnqual(OverflowPTy));
-
   CGF.EmitBranch(ContBlock);
-
   // Get the correct pointer to load the variable argument
   // Implement the ContBlock
   CGF.EmitBlock(ContBlock);
 
   llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Type *MemPTy = llvm::PointerType::getUnqual(MemTy);
-  llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(MemPTy, 2, "vaarg.addr");
-  ArgAddr->addIncoming(__saved_reg_area_p, InRegBlock);
-  ArgAddr->addIncoming(__overflow_area_p, OnStackBlock);
+  llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(
+  llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr");
+  ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock);

junlarsen wrote:

Yeah, slight oversight on my end. Just noticed it showed up on the tests too :)

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


[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)

2025-02-08 Thread Mats Jun Larsen via cfe-commits

https://github.com/junlarsen updated 
https://github.com/llvm/llvm-project/pull/126274

>From d0613ac62099faefab887605422cba95116ce12a Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen 
Date: Sat, 8 Feb 2025 02:35:31 +0900
Subject: [PATCH 1/2] [CodeGen][Hexagon] Replace of PointerType::get(Type) with
 opaque version (NFC)

---
 clang/lib/CodeGen/Targets/Hexagon.cpp | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp 
b/clang/lib/CodeGen/Targets/Hexagon.cpp
index 8fd2a81494d998c..6ad247a5056d376 100644
--- a/clang/lib/CodeGen/Targets/Hexagon.cpp
+++ b/clang/lib/CodeGen/Targets/Hexagon.cpp
@@ -8,6 +8,7 @@
 
 #include "ABIInfoImpl.h"
 #include "TargetInfo.h"
+#include "llvm/IR/DerivedTypes.h"
 
 using namespace clang;
 using namespace clang::CodeGen;
@@ -336,10 +337,6 @@ Address 
HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
   // Implement the block where argument is in register saved area
   CGF.EmitBlock(InRegBlock);
 
-  llvm::Type *PTy = CGF.ConvertType(Ty);
-  llvm::Value *__saved_reg_area_p = CGF.Builder.CreateBitCast(
-  __current_saved_reg_area_pointer, llvm::PointerType::getUnqual(PTy));
-
   CGF.Builder.CreateStore(__new_saved_reg_area_pointer,
   __current_saved_reg_area_pointer_p);
 
@@ -388,22 +385,16 @@ Address 
HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
   CGF.Builder.CreateStore(__new_overflow_area_pointer,
   __current_saved_reg_area_pointer_p);
 
-  // Bitcast the overflow area pointer to the type of argument.
-  llvm::Type *OverflowPTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Value *__overflow_area_p = CGF.Builder.CreateBitCast(
-  __overflow_area_pointer, llvm::PointerType::getUnqual(OverflowPTy));
-
   CGF.EmitBranch(ContBlock);
-
   // Get the correct pointer to load the variable argument
   // Implement the ContBlock
   CGF.EmitBlock(ContBlock);
 
   llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Type *MemPTy = llvm::PointerType::getUnqual(MemTy);
-  llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(MemPTy, 2, "vaarg.addr");
-  ArgAddr->addIncoming(__saved_reg_area_p, InRegBlock);
-  ArgAddr->addIncoming(__overflow_area_p, OnStackBlock);
+  llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(
+  llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr");
+  ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock);
+  ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock);
 
   return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign));
 }

>From 5c5c8c4e1b6482552fb3c02624543ec6ff60f844 Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen 
Date: Sat, 8 Feb 2025 22:22:15 +0900
Subject: [PATCH 2/2] Use correct saved_reg_area_pointer

---
 clang/lib/CodeGen/Targets/Hexagon.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp 
b/clang/lib/CodeGen/Targets/Hexagon.cpp
index 6ad247a5056d376..3e6ab74ff7ed7f9 100644
--- a/clang/lib/CodeGen/Targets/Hexagon.cpp
+++ b/clang/lib/CodeGen/Targets/Hexagon.cpp
@@ -393,7 +393,7 @@ Address 
HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
   llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty);
   llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(
   llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr");
-  ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock);
+  ArgAddr->addIncoming(__current_saved_reg_area_pointer, InRegBlock);
   ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock);
 
   return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign));

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


[clang] 4e29148 - [CodeGen][XCore] Replace PointerType::getUnqual(Type) with opaque version (NFC) (#126279)

2025-02-08 Thread via cfe-commits

Author: Mats Jun Larsen
Date: 2025-02-08T13:22:42Z
New Revision: 4e29148cca3fac0f1ffb1fbfbe3bbbd489859897

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

LOG: [CodeGen][XCore] Replace PointerType::getUnqual(Type) with opaque version 
(NFC) (#126279)

Follow-up to #123569

Added: 


Modified: 
clang/lib/CodeGen/Targets/XCore.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/Targets/XCore.cpp 
b/clang/lib/CodeGen/Targets/XCore.cpp
index ced4981fd124f6a..b7824bde5f55a4b 100644
--- a/clang/lib/CodeGen/Targets/XCore.cpp
+++ b/clang/lib/CodeGen/Targets/XCore.cpp
@@ -149,7 +149,7 @@ RValue XCoreABIInfo::EmitVAArg(CodeGenFunction &CGF, 
Address VAListAddr,
   llvm::Type *ArgTy = CGT.ConvertType(Ty);
   if (AI.canHaveCoerceToType() && !AI.getCoerceToType())
 AI.setCoerceToType(ArgTy);
-  llvm::Type *ArgPtrTy = llvm::PointerType::getUnqual(ArgTy);
+  llvm::Type *ArgPtrTy = llvm::PointerType::getUnqual(ArgTy->getContext());
 
   Address Val = Address::invalid();
   CharUnits ArgSize = CharUnits::Zero();



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


[clang] 54e0c2b - [CodeGen][SystemZ] Replace PointerType::getUnqual(Type) with opaque version (NFC) (#126280)

2025-02-08 Thread via cfe-commits

Author: Mats Jun Larsen
Date: 2025-02-08T13:22:53Z
New Revision: 54e0c2bbe2b36b08772ca6e5e3f176d7caf116bd

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

LOG: [CodeGen][SystemZ] Replace PointerType::getUnqual(Type) with opaque 
version (NFC) (#126280)

Follow-up to #126278

Added: 


Modified: 
clang/lib/CodeGen/Targets/SystemZ.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/Targets/SystemZ.cpp 
b/clang/lib/CodeGen/Targets/SystemZ.cpp
index 23c96fa5cf98cb..9bb8ddbc548d2d 100644
--- a/clang/lib/CodeGen/Targets/SystemZ.cpp
+++ b/clang/lib/CodeGen/Targets/SystemZ.cpp
@@ -272,7 +272,7 @@ RValue SystemZABIInfo::EmitVAArg(CodeGenFunction &CGF, 
Address VAListAddr,
   SZCGI.handleExternallyVisibleObjABI(Ty.getTypePtr(), CGT.getCGM(),
   /*IsParam*/true);
   if (IsIndirect) {
-DirectTy = llvm::PointerType::getUnqual(DirectTy);
+DirectTy = llvm::PointerType::getUnqual(DirectTy->getContext());
 UnpaddedSize = DirectAlign = CharUnits::fromQuantity(8);
   } else {
 if (AI.getCoerceToType())



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


[clang] [CodeGen][SystemZ] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126280)

2025-02-08 Thread Mats Jun Larsen via cfe-commits

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


[clang] df2e8ee - [CodeGen][AArch64] Replace PointerType::getUnqual(Type) with opaque version (NFC) (#126278)

2025-02-08 Thread via cfe-commits

Author: Mats Jun Larsen
Date: 2025-02-08T13:23:08Z
New Revision: df2e8ee7ae349364967a1a2d09f17b249a38c04d

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

LOG: [CodeGen][AArch64] Replace PointerType::getUnqual(Type) with opaque 
version (NFC) (#126278)

Follow-up to #123569

Added: 


Modified: 
clang/lib/CodeGen/Targets/AArch64.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/Targets/AArch64.cpp 
b/clang/lib/CodeGen/Targets/AArch64.cpp
index 4922b082cf09ca..dc3a1d4287be17 100644
--- a/clang/lib/CodeGen/Targets/AArch64.cpp
+++ b/clang/lib/CodeGen/Targets/AArch64.cpp
@@ -843,7 +843,7 @@ RValue AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, 
QualType Ty,
 
   llvm::Type *BaseTy = CGF.ConvertType(Ty);
   if (IsIndirect)
-BaseTy = llvm::PointerType::getUnqual(BaseTy);
+BaseTy = llvm::PointerType::getUnqual(BaseTy->getContext());
   else if (AI.getCoerceToType())
 BaseTy = AI.getCoerceToType();
 
@@ -961,7 +961,7 @@ RValue AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, 
QualType Ty,
   if (IsIndirect) {
 // If it's been passed indirectly (actually a struct), whatever we find 
from
 // stored registers or on the stack will actually be a struct **.
-MemTy = llvm::PointerType::getUnqual(MemTy);
+MemTy = llvm::PointerType::getUnqual(MemTy->getContext());
   }
 
   const Type *Base = nullptr;



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


[clang] [CodeGen][AArch64] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126278)

2025-02-08 Thread Mats Jun Larsen via cfe-commits

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


[clang] [CodeGen][XCore] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126279)

2025-02-08 Thread Mats Jun Larsen via cfe-commits

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-02-08 Thread Mats Jun Larsen via cfe-commits

https://github.com/junlarsen updated 
https://github.com/llvm/llvm-project/pull/124771

>From 13d65a0cc95fe53f959db343e5be07773ee53f28 Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen 
Date: Wed, 29 Jan 2025 00:31:32 +0900
Subject: [PATCH 1/4] [CodeGen] Replace of PointerType::get(Type) with opaque
 version (NFC)

Follow-up to https://github.com/llvm/llvm-project/issues/123569
---
 clang/lib/CodeGen/Address.h |  8 
 clang/lib/CodeGen/CGBlocks.cpp  | 23 +--
 clang/lib/CodeGen/CGDecl.cpp|  5 +
 clang/lib/CodeGen/CGDeclCXX.cpp |  4 ++--
 clang/lib/CodeGen/CGExpr.cpp|  4 ++--
 clang/lib/CodeGen/CGObjCMac.cpp |  2 +-
 clang/lib/CodeGen/CodeGenModule.cpp |  6 +++---
 7 files changed, 14 insertions(+), 38 deletions(-)

diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h
index a18c7169af1eb96..852aa0e686fe3c6 100644
--- a/clang/lib/CodeGen/Address.h
+++ b/clang/lib/CodeGen/Address.h
@@ -19,6 +19,7 @@
 #include "clang/AST/Type.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
 #include "llvm/Support/MathExtras.h"
 
 namespace clang {
@@ -197,10 +198,9 @@ class Address {
 
   /// Return the type of the pointer value.
   llvm::PointerType *getType() const {
-return llvm::PointerType::get(
-ElementType,
-llvm::cast(Pointer.getPointer()->getType())
-->getAddressSpace());
+auto AS = llvm::cast(Pointer.getPointer()->getType())
+  ->getAddressSpace();
+return llvm::PointerType::get(ElementType->getContext(), AS);
   }
 
   /// Return the type of the values stored in this address.
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index aaba354c08547d4..faef6a5fbe1f5b6 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() {
   if (BlockDescriptorType)
 return BlockDescriptorType;
 
-  llvm::Type *UnsignedLongTy =
-getTypes().ConvertType(getContext().UnsignedLongTy);
-
-  // struct __block_descriptor {
-  //   unsigned long reserved;
-  //   unsigned long block_size;
-  //
-  //   // later, the following will be added
-  //
-  //   struct {
-  // void (*copyHelper)();
-  // void (*copyHelper)();
-  //   } helpers;// !!! optional
-  //
-  //   const char *signature;   // the block signature
-  //   const char *layout;  // reserved
-  // };
-  BlockDescriptorType = llvm::StructType::create(
-  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
-
-  // Now form a pointer to that.
   unsigned AddrSpace = 0;
   if (getLangOpts().OpenCL)
 AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant);
-  BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace);
+  BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace);
   return BlockDescriptorType;
 }
 
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index cc6815db4d20f62..572175d9969a097 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2870,15 +2870,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const 
OMPAllocateDecl *D) {
 
 // We can also keep the existing global if the address space is what we
 // expect it to be, if not, it is replaced.
-QualType ASTTy = VD->getType();
 clang::LangAS GVAS = GetGlobalVarAddressSpace(VD);
 auto TargetAS = getContext().getTargetAddressSpace(GVAS);
 if (Entry->getType()->getAddressSpace() == TargetAS)
   continue;
 
-// Make a new global with the correct type / address space.
-llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy);
-llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS);
+llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), 
TargetAS);
 
 // Replace all uses of the old global with a cast. Since we mutate the type
 // in place we neeed an intermediate that takes the spot of the old entry
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 1c2fecea1a6ac25..5005f6b3cbd2d1a 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -347,7 +347,7 @@ void 
CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) {
   // extern "C" int atexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidTy, false),
+ CGM.getLLVMContext(),
  dtorStub->getType()->getPointerAddressSpace()) &&
  "Argument to atexit has a wrong type.");
 
@@ -374,7 +374,7 @@ 
CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) {
   // extern "C" int unatexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidT

[clang] [clang-tools-extra] [flang] [lldb] [llvm] [mlir] [polly] Add static to command line option (cl::opt) (PR #126243)

2025-02-08 Thread Mehdi Amini via cfe-commits

joker-eph wrote:

> The linked bug seems to explain it, I think? 

I don't actually see a description of what is the problem to solve really.

> It seems to be the usual "if something isn't/doesn't need to be declared in a 
> header, then it should be file-local static, so as to not conflict with other 
> local names in other files"?

All of the files are `main()`  file, not library files. Not clear to me what 
they would conflict with?

> Right, though I think @joker-eph comment is that for lot of the MLIR changes, 
> these option variables are function local and they need not be changed to 
> static. This issue is only applicable to file scoped variables.

That too :)



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


[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)

2025-02-08 Thread Nikita Popov via cfe-commits


@@ -8,6 +8,7 @@
 
 #include "ABIInfoImpl.h"
 #include "TargetInfo.h"
+#include "llvm/IR/DerivedTypes.h"

nikic wrote:

I don't think the extra include is needed?

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


[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)

2025-02-08 Thread Nikita Popov via cfe-commits

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


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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-02-08 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-02-08 Thread Nikita Popov via cfe-commits

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-02-08 Thread Nikita Popov via cfe-commits


@@ -19,6 +19,8 @@
 #include "clang/AST/Type.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/Support/Casting.h"

nikic wrote:

Shouldn't need the extra includes.

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


[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)

2025-02-08 Thread Mats Jun Larsen via cfe-commits


@@ -8,6 +8,7 @@
 
 #include "ABIInfoImpl.h"
 #include "TargetInfo.h"
+#include "llvm/IR/DerivedTypes.h"

junlarsen wrote:

Likely not, I think my LSP automatically inserts them when it completes stuff 
like PointerType::get. I'll remove it and the ones in the other PR too

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-02-08 Thread Mats Jun Larsen via cfe-commits

https://github.com/junlarsen updated 
https://github.com/llvm/llvm-project/pull/124771

>From 13d65a0cc95fe53f959db343e5be07773ee53f28 Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen 
Date: Wed, 29 Jan 2025 00:31:32 +0900
Subject: [PATCH 1/5] [CodeGen] Replace of PointerType::get(Type) with opaque
 version (NFC)

Follow-up to https://github.com/llvm/llvm-project/issues/123569
---
 clang/lib/CodeGen/Address.h |  8 
 clang/lib/CodeGen/CGBlocks.cpp  | 23 +--
 clang/lib/CodeGen/CGDecl.cpp|  5 +
 clang/lib/CodeGen/CGDeclCXX.cpp |  4 ++--
 clang/lib/CodeGen/CGExpr.cpp|  4 ++--
 clang/lib/CodeGen/CGObjCMac.cpp |  2 +-
 clang/lib/CodeGen/CodeGenModule.cpp |  6 +++---
 7 files changed, 14 insertions(+), 38 deletions(-)

diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h
index a18c7169af1eb96..852aa0e686fe3c6 100644
--- a/clang/lib/CodeGen/Address.h
+++ b/clang/lib/CodeGen/Address.h
@@ -19,6 +19,7 @@
 #include "clang/AST/Type.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
 #include "llvm/Support/MathExtras.h"
 
 namespace clang {
@@ -197,10 +198,9 @@ class Address {
 
   /// Return the type of the pointer value.
   llvm::PointerType *getType() const {
-return llvm::PointerType::get(
-ElementType,
-llvm::cast(Pointer.getPointer()->getType())
-->getAddressSpace());
+auto AS = llvm::cast(Pointer.getPointer()->getType())
+  ->getAddressSpace();
+return llvm::PointerType::get(ElementType->getContext(), AS);
   }
 
   /// Return the type of the values stored in this address.
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index aaba354c08547d4..faef6a5fbe1f5b6 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() {
   if (BlockDescriptorType)
 return BlockDescriptorType;
 
-  llvm::Type *UnsignedLongTy =
-getTypes().ConvertType(getContext().UnsignedLongTy);
-
-  // struct __block_descriptor {
-  //   unsigned long reserved;
-  //   unsigned long block_size;
-  //
-  //   // later, the following will be added
-  //
-  //   struct {
-  // void (*copyHelper)();
-  // void (*copyHelper)();
-  //   } helpers;// !!! optional
-  //
-  //   const char *signature;   // the block signature
-  //   const char *layout;  // reserved
-  // };
-  BlockDescriptorType = llvm::StructType::create(
-  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
-
-  // Now form a pointer to that.
   unsigned AddrSpace = 0;
   if (getLangOpts().OpenCL)
 AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant);
-  BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace);
+  BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace);
   return BlockDescriptorType;
 }
 
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index cc6815db4d20f62..572175d9969a097 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2870,15 +2870,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const 
OMPAllocateDecl *D) {
 
 // We can also keep the existing global if the address space is what we
 // expect it to be, if not, it is replaced.
-QualType ASTTy = VD->getType();
 clang::LangAS GVAS = GetGlobalVarAddressSpace(VD);
 auto TargetAS = getContext().getTargetAddressSpace(GVAS);
 if (Entry->getType()->getAddressSpace() == TargetAS)
   continue;
 
-// Make a new global with the correct type / address space.
-llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy);
-llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS);
+llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), 
TargetAS);
 
 // Replace all uses of the old global with a cast. Since we mutate the type
 // in place we neeed an intermediate that takes the spot of the old entry
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 1c2fecea1a6ac25..5005f6b3cbd2d1a 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -347,7 +347,7 @@ void 
CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) {
   // extern "C" int atexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidTy, false),
+ CGM.getLLVMContext(),
  dtorStub->getType()->getPointerAddressSpace()) &&
  "Argument to atexit has a wrong type.");
 
@@ -374,7 +374,7 @@ 
CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) {
   // extern "C" int unatexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidT

[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-02-08 Thread Mats Jun Larsen via cfe-commits

https://github.com/junlarsen updated 
https://github.com/llvm/llvm-project/pull/124771

>From 13d65a0cc95fe53f959db343e5be07773ee53f28 Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen 
Date: Wed, 29 Jan 2025 00:31:32 +0900
Subject: [PATCH 1/5] [CodeGen] Replace of PointerType::get(Type) with opaque
 version (NFC)

Follow-up to https://github.com/llvm/llvm-project/issues/123569
---
 clang/lib/CodeGen/Address.h |  8 
 clang/lib/CodeGen/CGBlocks.cpp  | 23 +--
 clang/lib/CodeGen/CGDecl.cpp|  5 +
 clang/lib/CodeGen/CGDeclCXX.cpp |  4 ++--
 clang/lib/CodeGen/CGExpr.cpp|  4 ++--
 clang/lib/CodeGen/CGObjCMac.cpp |  2 +-
 clang/lib/CodeGen/CodeGenModule.cpp |  6 +++---
 7 files changed, 14 insertions(+), 38 deletions(-)

diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h
index a18c7169af1eb96..852aa0e686fe3c6 100644
--- a/clang/lib/CodeGen/Address.h
+++ b/clang/lib/CodeGen/Address.h
@@ -19,6 +19,7 @@
 #include "clang/AST/Type.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
 #include "llvm/Support/MathExtras.h"
 
 namespace clang {
@@ -197,10 +198,9 @@ class Address {
 
   /// Return the type of the pointer value.
   llvm::PointerType *getType() const {
-return llvm::PointerType::get(
-ElementType,
-llvm::cast(Pointer.getPointer()->getType())
-->getAddressSpace());
+auto AS = llvm::cast(Pointer.getPointer()->getType())
+  ->getAddressSpace();
+return llvm::PointerType::get(ElementType->getContext(), AS);
   }
 
   /// Return the type of the values stored in this address.
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index aaba354c08547d4..faef6a5fbe1f5b6 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() {
   if (BlockDescriptorType)
 return BlockDescriptorType;
 
-  llvm::Type *UnsignedLongTy =
-getTypes().ConvertType(getContext().UnsignedLongTy);
-
-  // struct __block_descriptor {
-  //   unsigned long reserved;
-  //   unsigned long block_size;
-  //
-  //   // later, the following will be added
-  //
-  //   struct {
-  // void (*copyHelper)();
-  // void (*copyHelper)();
-  //   } helpers;// !!! optional
-  //
-  //   const char *signature;   // the block signature
-  //   const char *layout;  // reserved
-  // };
-  BlockDescriptorType = llvm::StructType::create(
-  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
-
-  // Now form a pointer to that.
   unsigned AddrSpace = 0;
   if (getLangOpts().OpenCL)
 AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant);
-  BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace);
+  BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace);
   return BlockDescriptorType;
 }
 
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index cc6815db4d20f62..572175d9969a097 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2870,15 +2870,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const 
OMPAllocateDecl *D) {
 
 // We can also keep the existing global if the address space is what we
 // expect it to be, if not, it is replaced.
-QualType ASTTy = VD->getType();
 clang::LangAS GVAS = GetGlobalVarAddressSpace(VD);
 auto TargetAS = getContext().getTargetAddressSpace(GVAS);
 if (Entry->getType()->getAddressSpace() == TargetAS)
   continue;
 
-// Make a new global with the correct type / address space.
-llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy);
-llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS);
+llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), 
TargetAS);
 
 // Replace all uses of the old global with a cast. Since we mutate the type
 // in place we neeed an intermediate that takes the spot of the old entry
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 1c2fecea1a6ac25..5005f6b3cbd2d1a 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -347,7 +347,7 @@ void 
CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) {
   // extern "C" int atexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidTy, false),
+ CGM.getLLVMContext(),
  dtorStub->getType()->getPointerAddressSpace()) &&
  "Argument to atexit has a wrong type.");
 
@@ -374,7 +374,7 @@ 
CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) {
   // extern "C" int unatexit(void (*f)(void));
   assert(dtorStub->getType() ==
  llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidT

[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)

2025-02-08 Thread Mats Jun Larsen via cfe-commits

https://github.com/junlarsen updated 
https://github.com/llvm/llvm-project/pull/126274

>From d0613ac62099faefab887605422cba95116ce12a Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen 
Date: Sat, 8 Feb 2025 02:35:31 +0900
Subject: [PATCH 1/3] [CodeGen][Hexagon] Replace of PointerType::get(Type) with
 opaque version (NFC)

---
 clang/lib/CodeGen/Targets/Hexagon.cpp | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp 
b/clang/lib/CodeGen/Targets/Hexagon.cpp
index 8fd2a81494d998c..6ad247a5056d376 100644
--- a/clang/lib/CodeGen/Targets/Hexagon.cpp
+++ b/clang/lib/CodeGen/Targets/Hexagon.cpp
@@ -8,6 +8,7 @@
 
 #include "ABIInfoImpl.h"
 #include "TargetInfo.h"
+#include "llvm/IR/DerivedTypes.h"
 
 using namespace clang;
 using namespace clang::CodeGen;
@@ -336,10 +337,6 @@ Address 
HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
   // Implement the block where argument is in register saved area
   CGF.EmitBlock(InRegBlock);
 
-  llvm::Type *PTy = CGF.ConvertType(Ty);
-  llvm::Value *__saved_reg_area_p = CGF.Builder.CreateBitCast(
-  __current_saved_reg_area_pointer, llvm::PointerType::getUnqual(PTy));
-
   CGF.Builder.CreateStore(__new_saved_reg_area_pointer,
   __current_saved_reg_area_pointer_p);
 
@@ -388,22 +385,16 @@ Address 
HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
   CGF.Builder.CreateStore(__new_overflow_area_pointer,
   __current_saved_reg_area_pointer_p);
 
-  // Bitcast the overflow area pointer to the type of argument.
-  llvm::Type *OverflowPTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Value *__overflow_area_p = CGF.Builder.CreateBitCast(
-  __overflow_area_pointer, llvm::PointerType::getUnqual(OverflowPTy));
-
   CGF.EmitBranch(ContBlock);
-
   // Get the correct pointer to load the variable argument
   // Implement the ContBlock
   CGF.EmitBlock(ContBlock);
 
   llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Type *MemPTy = llvm::PointerType::getUnqual(MemTy);
-  llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(MemPTy, 2, "vaarg.addr");
-  ArgAddr->addIncoming(__saved_reg_area_p, InRegBlock);
-  ArgAddr->addIncoming(__overflow_area_p, OnStackBlock);
+  llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(
+  llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr");
+  ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock);
+  ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock);
 
   return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign));
 }

>From 5c5c8c4e1b6482552fb3c02624543ec6ff60f844 Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen 
Date: Sat, 8 Feb 2025 22:22:15 +0900
Subject: [PATCH 2/3] Use correct saved_reg_area_pointer

---
 clang/lib/CodeGen/Targets/Hexagon.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp 
b/clang/lib/CodeGen/Targets/Hexagon.cpp
index 6ad247a5056d376..3e6ab74ff7ed7f9 100644
--- a/clang/lib/CodeGen/Targets/Hexagon.cpp
+++ b/clang/lib/CodeGen/Targets/Hexagon.cpp
@@ -393,7 +393,7 @@ Address 
HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
   llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty);
   llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(
   llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr");
-  ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock);
+  ArgAddr->addIncoming(__current_saved_reg_area_pointer, InRegBlock);
   ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock);
 
   return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign));

>From eec0d490cd021d5bc03de01c179bc701fc2f6e14 Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen 
Date: Sun, 9 Feb 2025 00:01:48 +0900
Subject: [PATCH 3/3] Remove inserted includes

---
 clang/lib/CodeGen/Targets/Hexagon.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp 
b/clang/lib/CodeGen/Targets/Hexagon.cpp
index 3e6ab74ff7ed7f9..aada8d0d61303be 100644
--- a/clang/lib/CodeGen/Targets/Hexagon.cpp
+++ b/clang/lib/CodeGen/Targets/Hexagon.cpp
@@ -8,7 +8,6 @@
 
 #include "ABIInfoImpl.h"
 #include "TargetInfo.h"
-#include "llvm/IR/DerivedTypes.h"
 
 using namespace clang;
 using namespace clang::CodeGen;

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


[clang] [clang][docs] Fix example in likely/unlikely attr documentation (PR #126372)

2025-02-08 Thread Marc Auberer via cfe-commits

https://github.com/marcauberer created 
https://github.com/llvm/llvm-project/pull/126372

Fixes #126362

>From 3a8b503f851a7b0b610797e5eaad4bd27397cb70 Mon Sep 17 00:00:00 2001
From: Marc Auberer 
Date: Sat, 8 Feb 2025 16:04:21 +0100
Subject: [PATCH] [clang][docs] Fix example in likely/unlikely attr
 documentation

---
 clang/include/clang/Basic/AttrDocs.td | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 0ad4c958d098303..2a0354a3222eba8 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2450,9 +2450,9 @@ path of execution, but that can be confusing:
 
 .. code-block:: c++
 
-  if (b) {
-[[unlikely]] --b; // In the path of execution,
-  // this branch is considered unlikely.
+  if (b) [[unlikely]] {
+--b; // In the path of execution,
+ // this branch is considered unlikely.
   }
 
   if (b) {

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


[clang] [clang][docs] Fix example in likely/unlikely attr documentation (PR #126372)

2025-02-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Marc Auberer (marcauberer)


Changes

Fixes #126362

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


1 Files Affected:

- (modified) clang/include/clang/Basic/AttrDocs.td (+3-3) 


``diff
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 0ad4c958d09830..2a0354a3222eba 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2450,9 +2450,9 @@ path of execution, but that can be confusing:
 
 .. code-block:: c++
 
-  if (b) {
-[[unlikely]] --b; // In the path of execution,
-  // this branch is considered unlikely.
+  if (b) [[unlikely]] {
+--b; // In the path of execution,
+ // this branch is considered unlikely.
   }
 
   if (b) {

``




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


[clang] e0fee55 - [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (#124771)

2025-02-08 Thread via cfe-commits

Author: Mats Jun Larsen
Date: 2025-02-08T15:13:02Z
New Revision: e0fee55a5549e04bb14d45fba6267bd69285ce77

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

LOG: [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) 
(#124771)

Follow-up to https://github.com/llvm/llvm-project/issues/123569

Added: 


Modified: 
clang/lib/CodeGen/Address.h
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h
index a18c7169af1eb9..a748ddaa110a5b 100644
--- a/clang/lib/CodeGen/Address.h
+++ b/clang/lib/CodeGen/Address.h
@@ -197,10 +197,7 @@ class Address {
 
   /// Return the type of the pointer value.
   llvm::PointerType *getType() const {
-return llvm::PointerType::get(
-ElementType,
-llvm::cast(Pointer.getPointer()->getType())
-->getAddressSpace());
+return llvm::cast(Pointer.getPointer()->getType());
   }
 
   /// Return the type of the values stored in this address.

diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index aaba354c08547d..faef6a5fbe1f5b 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() {
   if (BlockDescriptorType)
 return BlockDescriptorType;
 
-  llvm::Type *UnsignedLongTy =
-getTypes().ConvertType(getContext().UnsignedLongTy);
-
-  // struct __block_descriptor {
-  //   unsigned long reserved;
-  //   unsigned long block_size;
-  //
-  //   // later, the following will be added
-  //
-  //   struct {
-  // void (*copyHelper)();
-  // void (*copyHelper)();
-  //   } helpers;// !!! optional
-  //
-  //   const char *signature;   // the block signature
-  //   const char *layout;  // reserved
-  // };
-  BlockDescriptorType = llvm::StructType::create(
-  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
-
-  // Now form a pointer to that.
   unsigned AddrSpace = 0;
   if (getLangOpts().OpenCL)
 AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant);
-  BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace);
+  BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace);
   return BlockDescriptorType;
 }
 

diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index cc6815db4d20f6..668282a6ab1a88 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2870,15 +2870,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const 
OMPAllocateDecl *D) {
 
 // We can also keep the existing global if the address space is what we
 // expect it to be, if not, it is replaced.
-QualType ASTTy = VD->getType();
 clang::LangAS GVAS = GetGlobalVarAddressSpace(VD);
 auto TargetAS = getContext().getTargetAddressSpace(GVAS);
 if (Entry->getType()->getAddressSpace() == TargetAS)
   continue;
 
-// Make a new global with the correct type / address space.
-llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy);
-llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS);
+llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), 
TargetAS);
 
 // Replace all uses of the old global with a cast. Since we mutate the type
 // in place we neeed an intermediate that takes the spot of the old entry
@@ -2891,8 +2888,7 @@ void CodeGenModule::EmitOMPAllocateDecl(const 
OMPAllocateDecl *D) {
 
 Entry->mutateType(PTy);
 llvm::Constant *NewPtrForOldDecl =
-llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
-Entry, DummyGV->getType());
+llvm::ConstantExpr::getAddrSpaceCast(Entry, DummyGV->getType());
 
 // Now we have a casted version of the changed global, the dummy can be
 // replaced and deleted.

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 1c2fecea1a6ac2..f5950f03673a12 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -345,10 +345,7 @@ void CodeGenFunction::registerGlobalDtorWithLLVM(const 
VarDecl &VD,
 
 void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) {
   // extern "C" int atexit(void (*f)(void));
-  assert(dtorStub->getType() ==
- llvm::PointerType::get(
- llvm::FunctionType::get(CGM.VoidTy, false),
- dtorStub->getType()->getPointerAddressSpace()) &&
+  assert(dtorStub->getType()->isPointerTy() &&
  "Argument to atexit has a wrong type.");
 
   llvm::FunctionType *atexitTy 

[clang] a07928c - [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (#126274)

2025-02-08 Thread via cfe-commits

Author: Mats Jun Larsen
Date: 2025-02-08T15:13:23Z
New Revision: a07928c3ce9da62b82a796ef26f5f7aaa0311d37

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

LOG: [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque 
version (NFC) (#126274)

Follow-up to https://github.com/llvm/llvm-project/issues/123569

The obsolete bitcasts on the LoadInsts are also removed.

Added: 


Modified: 
clang/lib/CodeGen/Targets/Hexagon.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/Targets/Hexagon.cpp 
b/clang/lib/CodeGen/Targets/Hexagon.cpp
index 8fd2a81494d998..aada8d0d61303b 100644
--- a/clang/lib/CodeGen/Targets/Hexagon.cpp
+++ b/clang/lib/CodeGen/Targets/Hexagon.cpp
@@ -336,10 +336,6 @@ Address 
HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
   // Implement the block where argument is in register saved area
   CGF.EmitBlock(InRegBlock);
 
-  llvm::Type *PTy = CGF.ConvertType(Ty);
-  llvm::Value *__saved_reg_area_p = CGF.Builder.CreateBitCast(
-  __current_saved_reg_area_pointer, llvm::PointerType::getUnqual(PTy));
-
   CGF.Builder.CreateStore(__new_saved_reg_area_pointer,
   __current_saved_reg_area_pointer_p);
 
@@ -388,22 +384,16 @@ Address 
HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF,
   CGF.Builder.CreateStore(__new_overflow_area_pointer,
   __current_saved_reg_area_pointer_p);
 
-  // Bitcast the overflow area pointer to the type of argument.
-  llvm::Type *OverflowPTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Value *__overflow_area_p = CGF.Builder.CreateBitCast(
-  __overflow_area_pointer, llvm::PointerType::getUnqual(OverflowPTy));
-
   CGF.EmitBranch(ContBlock);
-
   // Get the correct pointer to load the variable argument
   // Implement the ContBlock
   CGF.EmitBlock(ContBlock);
 
   llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Type *MemPTy = llvm::PointerType::getUnqual(MemTy);
-  llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(MemPTy, 2, "vaarg.addr");
-  ArgAddr->addIncoming(__saved_reg_area_p, InRegBlock);
-  ArgAddr->addIncoming(__overflow_area_p, OnStackBlock);
+  llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(
+  llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr");
+  ArgAddr->addIncoming(__current_saved_reg_area_pointer, InRegBlock);
+  ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock);
 
   return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign));
 }



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


[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)

2025-02-08 Thread Mats Jun Larsen via cfe-commits

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


[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)

2025-02-08 Thread Mats Jun Larsen via cfe-commits

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


[clang] [flang] [lld] [Flang] Rename libFortranRuntime.a to libflang_rt.runtime.a (PR #122341)

2025-02-08 Thread Michael Kruse via cfe-commits

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


[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-02-08 Thread Ilia Kuklin via cfe-commits

https://github.com/kuilpd updated 
https://github.com/llvm/llvm-project/pull/115005

>From 4d797371598960baf7729d05590aa1a8c7077694 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin 
Date: Mon, 4 Nov 2024 14:33:45 +0500
Subject: [PATCH 01/13] [lldb] Analyze enum promotion type during parsing

---
 clang/include/clang/AST/Decl.h|  2 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 95 ++-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 26 +
 3 files changed, 98 insertions(+), 25 deletions(-)

diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 16403774e72b31c..41cb47516f58033 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -3903,6 +3903,7 @@ class EnumDecl : public TagDecl {
   void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED,
 TemplateSpecializationKind TSK);
 
+public:
   /// Sets the width in bits required to store all the
   /// non-negative enumerators of this enum.
   void setNumPositiveBits(unsigned Num) {
@@ -3914,7 +3915,6 @@ class EnumDecl : public TagDecl {
   /// negative enumerators of this enum. (see getNumNegativeBits)
   void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; }
 
-public:
   /// True if this tag declaration is a scoped enumeration. Only
   /// possible in C++11 mode.
   void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index e77188bfbd2e4a5..bb9c35a235c1ff4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2316,6 +2316,8 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
 return 0;
 
   size_t enumerators_added = 0;
+  unsigned NumNegativeBits = 0;
+  unsigned NumPositiveBits = 0;
 
   for (DWARFDIE die : parent_die.children()) {
 const dw_tag_t tag = die.Tag();
@@ -2367,11 +2369,102 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
 }
 
 if (name && name[0] && got_value) {
-  m_ast.AddEnumerationValueToEnumerationType(
+  auto ECD = m_ast.AddEnumerationValueToEnumerationType(
   clang_type, decl, name, enum_value, enumerator_byte_size * 8);
   ++enumerators_added;
+
+  llvm::APSInt InitVal = ECD->getInitVal();
+  // Keep track of the size of positive and negative values.
+  if (InitVal.isUnsigned() || InitVal.isNonNegative()) {
+// If the enumerator is zero that should still be counted as a positive
+// bit since we need a bit to store the value zero.
+unsigned ActiveBits = InitVal.getActiveBits();
+NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u});
+  } else {
+NumNegativeBits =
+std::max(NumNegativeBits, (unsigned)InitVal.getSignificantBits());
+  }
 }
   }
+
+  /// The following code follows the same logic as in Sema::ActOnEnumBody
+  /// clang/lib/Sema/SemaDecl.cpp
+  // If we have an empty set of enumerators we still need one bit.
+  // From [dcl.enum]p8
+  // If the enumerator-list is empty, the values of the enumeration are as if
+  // the enumeration had a single enumerator with value 0
+  if (!NumPositiveBits && !NumNegativeBits)
+NumPositiveBits = 1;
+
+  clang::QualType qual_type(ClangUtil::GetQualType(clang_type));
+  clang::EnumDecl *enum_decl = qual_type->getAs()->getDecl();
+  enum_decl->setNumPositiveBits(NumPositiveBits);
+  enum_decl->setNumNegativeBits(NumNegativeBits);
+
+  // C++0x N3000 [conv.prom]p3:
+  //   An rvalue of an unscoped enumeration type whose underlying
+  //   type is not fixed can be converted to an rvalue of the first
+  //   of the following types that can represent all the values of
+  //   the enumeration: int, unsigned int, long int, unsigned long
+  //   int, long long int, or unsigned long long int.
+  // C99 6.4.4.3p2:
+  //   An identifier declared as an enumeration constant has type int.
+  // The C99 rule is modified by C23.
+  clang::QualType BestPromotionType;
+  unsigned BestWidth;
+
+  auto &Context = m_ast.getASTContext();
+  unsigned LongWidth = Context.getTargetInfo().getLongWidth();
+  unsigned IntWidth = Context.getTargetInfo().getIntWidth();
+  unsigned CharWidth = Context.getTargetInfo().getCharWidth();
+  unsigned ShortWidth = Context.getTargetInfo().getShortWidth();
+
+  bool is_cpp = Language::LanguageIsCPlusPlus(
+  SymbolFileDWARF::GetLanguage(*parent_die.GetCU()));
+
+  if (NumNegativeBits) {
+// If there is a negative value, figure out the smallest integer type (of
+// int/long/longlong) that fits.
+if (NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
+  BestWidth = CharWidth;
+} else if (NumNegativeBits <= ShortWidth && NumPositiveBits < ShortWidth) {
+  BestWidth = ShortWidth;
+} else if (NumNegativeBits <= IntWid

[clang-tools-extra] [clang-tidy] Add performance-redundant-lookup check (PR #125420)

2025-02-08 Thread Balazs Benics via cfe-commits

steakhal wrote:

I revisited the check using `ExprSequence`.
It became more actionable from what I can tell, but exposes weaknesses of 
`ExprSequence` too, which I'll later demonstrate.

My approach with my prototype using `ExprSequence` was:
 1) Collect lookups just like before.
 2) Take the cross product of the lookups, and build a graph using the 
`inSequence` relationship among the lookups.
 3) Take the nodes that has no parents, aka. roots of the `inSequence` graph, 
because I'll report a separate "bug" for the reachable lookups from each Root.
 4) Pick the last lookup of the group as the diagnostic location, and add notes 
for the rest.
 
 This got fairly involved, and likely scales really poorly with the number of 
lookups using the same key and container.
 The results are mixed, and I think it's caused by `ExprSequence`, and 
hallucinates `inSequence` relationship for Stmt pairs where it actually 
shouldn't.
 
Here are a couple of examples:
![image](https://github.com/user-attachments/assets/78f6a662-4b54-4145-ad73-8221ad48218e)
![image](https://github.com/user-attachments/assets/a53cd473-8601-4339-9548-dd351e9b1b7b)
![image](https://github.com/user-attachments/assets/f723cc13-40b7-4e2b-a060-377d5b2c7f44)


So, if `ExprSequence` would honor `return` statements and if blocks, then it 
would be a viable direction to move forward.

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


[clang] [clang-tools-extra] [llvm] [clang-tidy] Replace /* ... */ single-line comments with // ... comments (PR #124319)

2025-02-08 Thread via cfe-commits

EugeneZelenko wrote:

Please do rebase instead of merge, otherwise unrelated changes (a lot of them) 
appear in pull request.

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


[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)

2025-02-08 Thread Ilia Kuklin via cfe-commits

kuilpd wrote:

@Michael137 
Changed the first argument of `computeEnumBits` to an `ArrayRef` to avoid the 
template and so it can be still seamlessly used from Sema.
On LLDB side, I had to create a `SmallVector` and put enum constants there at 
the point of their creation (`AddEnumerationValueToEnumerationType` returns a 
pointer anyway) so that it can be passed to `computeEnumBits` as is. It's only 
a vector of pointers, and it's discarded after, so if it's not a problem here, 
I'll make the same changes in the Sema PR.

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


[clang] [Clang] Silently ignore unknown warnings in `--warning-suppression-mappings` (PR #124141)

2025-02-08 Thread James Y Knight via cfe-commits

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


[clang] [Clang] Silently ignore unknown warnings in `--warning-suppression-mappings` (PR #124141)

2025-02-08 Thread James Y Knight via cfe-commits

jyknight wrote:

Abandoning in favor of kadircet's #125722 and #125714.

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


[clang] 5c8c2b3 - [Flang] Rename libFortranRuntime.a to libflang_rt.runtime.a (#122341)

2025-02-08 Thread via cfe-commits

Author: Michael Kruse
Date: 2025-02-08T18:02:54+01:00
New Revision: 5c8c2b3db54395073e3183f89167156df29dff61

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

LOG: [Flang] Rename libFortranRuntime.a to libflang_rt.runtime.a (#122341)

Following the conclusion of the
[RFC](https://discourse.llvm.org/t/rfc-names-for-flang-rt-libraries/84321),
rename Flang's runtime libraries as follows:

 * libFortranRuntime.(a|so) to libflang_rt.runtime.(a|so)
 * libFortranFloat128Math.a to libflang_rt.quadmath.a
* libCufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}.(a|so) to
libflang_rt.cuda_${CUDAToolkit_VERSION_MAJOR}.(a|so)

This follows the same naming scheme as Compiler-RT libraries
(`libclang_rt.${component}.(a|so)`). It provides some consistency
between Flang's runtime libraries for current and potential future
library components.

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Flang.cpp
flang/CMakeLists.txt
flang/cmake/modules/AddFlang.cmake
flang/docs/FlangDriver.md
flang/docs/GettingStarted.md
flang/docs/OpenACC-descriptor-management.md
flang/docs/Real16MathSupport.md
flang/docs/ReleaseNotes.md
flang/examples/ExternalHelloWorld/CMakeLists.txt
flang/lib/Optimizer/Builder/IntrinsicCall.cpp
flang/runtime/CMakeLists.txt
flang/runtime/CUDA/CMakeLists.txt
flang/runtime/Float128Math/CMakeLists.txt
flang/runtime/time-intrinsic.cpp
flang/runtime/tools.h
flang/test/CMakeLists.txt
flang/test/Driver/gcc-toolchain-install-dir.f90
flang/test/Driver/linker-flags.f90
flang/test/Driver/msvc-dependent-lib-flags.f90
flang/test/Driver/nostdlib.f90
flang/test/Runtime/no-cpp-dep.c
flang/test/lit.cfg.py
flang/tools/f18/CMakeLists.txt
flang/unittests/CMakeLists.txt
flang/unittests/Evaluate/CMakeLists.txt
flang/unittests/Runtime/CMakeLists.txt
flang/unittests/Runtime/CUDA/CMakeLists.txt
lld/COFF/MinGW.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index e0b5d003ebb13fd..61917db4d780d50 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1321,7 +1321,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation 
&C,
 /// Add Fortran runtime libs
 void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
-  // Link FortranRuntime
+  // Link flang_rt.runtime
   // These are handled earlier on Windows by telling the frontend driver to
   // add the correct libraries to link against as dependents in the object
   // file.
@@ -1330,14 +1330,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, 
const ArgList &Args,
 F128LibName.consume_front_insensitive("lib");
 if (!F128LibName.empty()) {
   bool AsNeeded = !TC.getTriple().isOSAIX();
-  CmdArgs.push_back("-lFortranFloat128Math");
+  CmdArgs.push_back("-lflang_rt.quadmath");
   if (AsNeeded)
 addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true);
   CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName));
   if (AsNeeded)
 addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
 }
-CmdArgs.push_back("-lFortranRuntime");
+CmdArgs.push_back("-lflang_rt.runtime");
 addArchSpecificRPath(TC, Args, CmdArgs);
 
 // needs libexecinfo for backtrace functions

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index e7b68f4a8c60a44..591003f56e8bbb9 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -346,11 +346,15 @@ static void processVSRuntimeLibrary(const ToolChain &TC, 
const ArgList &Args,
 ArgStringList &CmdArgs) {
   assert(TC.getTriple().isKnownWindowsMSVCEnvironment() &&
  "can only add VS runtime library on Windows!");
-  // if -fno-fortran-main has been passed, skip linking Fortran_main.a
-  if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
-CmdArgs.push_back(Args.MakeArgString(
-"--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins")));
-  }
+
+  // Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
+  // should only depend on msv(u)crt. LLVM still emits libgcc/compiler-rt
+  // functions in some cases like 128-bit integer math (__udivti3, __modti3,
+  // __fixsfti, __floattidf, ...) that msvc does not support. We are injecting 
a
+  // dependency to Compiler-RT's builtin library where these are implemented.
+  CmdArgs.push_back(Args.MakeArgString(
+  "--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins")));
+
   unsigned 

[clang] [flang] [lld] [Flang] Rename libFortranRuntime.a to libflang_rt.runtime.a (PR #122341)

2025-02-08 Thread Michael Kruse via cfe-commits

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


[clang] [flang] [lld] [llvm] [Flang][NFC] Move runtime library files to flang-rt. (PR #110298)

2025-02-08 Thread Michael Kruse via cfe-commits

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


[clang] [HLSL] Implement HLSL splatting (PR #118992)

2025-02-08 Thread Sarah Spall via cfe-commits

https://github.com/spall updated 
https://github.com/llvm/llvm-project/pull/118992

>From e994824f3630ee8b224afceb6c14d980c9013112 Mon Sep 17 00:00:00 2001
From: Sarah Spall 
Date: Fri, 6 Dec 2024 05:14:17 +
Subject: [PATCH 1/9] splat cast wip

---
 clang/include/clang/AST/OperationKinds.def |  3 ++
 clang/include/clang/Sema/SemaHLSL.h|  1 +
 clang/lib/CodeGen/CGExprAgg.cpp| 42 ++
 clang/lib/CodeGen/CGExprScalar.cpp | 16 +
 clang/lib/Sema/Sema.cpp|  1 +
 clang/lib/Sema/SemaCast.cpp|  9 -
 clang/lib/Sema/SemaHLSL.cpp| 26 ++
 7 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/AST/OperationKinds.def 
b/clang/include/clang/AST/OperationKinds.def
index b3dc7c3d8dc77e1..333fc7e1b18821e 100644
--- a/clang/include/clang/AST/OperationKinds.def
+++ b/clang/include/clang/AST/OperationKinds.def
@@ -370,6 +370,9 @@ CAST_OPERATION(HLSLArrayRValue)
 // Aggregate by Value cast (HLSL only).
 CAST_OPERATION(HLSLElementwiseCast)
 
+// Splat cast for Aggregates (HLSL only).
+CAST_OPERATION(HLSLSplatCast)
+
 //===- Binary Operations  
-===//
 // Operators listed in order of precedence.
 // Note that additions to this should also update the StmtVisitor class,
diff --git a/clang/include/clang/Sema/SemaHLSL.h 
b/clang/include/clang/Sema/SemaHLSL.h
index 6e8ca2e4710dec8..7508b149b0d81d0 100644
--- a/clang/include/clang/Sema/SemaHLSL.h
+++ b/clang/include/clang/Sema/SemaHLSL.h
@@ -144,6 +144,7 @@ class SemaHLSL : public SemaBase {
   bool CanPerformScalarCast(QualType SrcTy, QualType DestTy);
   bool ContainsBitField(QualType BaseTy);
   bool CanPerformElementwiseCast(Expr *Src, QualType DestType);
+  bool CanPerformSplat(Expr *Src, QualType DestType);
   ExprResult ActOnOutParamExpr(ParmVarDecl *Param, Expr *Arg);
 
   QualType getInoutParameterType(QualType Ty);
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index c3f1cbed6b39f95..f26189bc4907cea 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -491,6 +491,33 @@ static bool isTrivialFiller(Expr *E) {
   return false;
 }
 
+static void EmitHLSLSplatCast(CodeGenFunction &CGF, Address DestVal,
+ QualType DestTy, llvm::Value *SrcVal,
+ QualType SrcTy, SourceLocation Loc) {
+  // Flatten our destination
+  SmallVector DestTypes; // Flattened type
+  SmallVector IdxList;
+  SmallVector, 16> StoreGEPList;
+  // ^^ Flattened accesses to DestVal we want to store into
+  CGF.FlattenAccessAndType(DestVal, DestTy, IdxList, StoreGEPList,
+  DestTypes);
+
+  if (const VectorType *VT = SrcTy->getAs()) {
+assert(VT->getNumElements() == 1 && "Invalid HLSL splat cast.");
+
+SrcTy = VT->getElementType();
+SrcVal = CGF.Builder.CreateExtractElement(SrcVal, (uint64_t)0,
+ "vec.load");
+  }
+  assert(SrcTy->isScalarType() && "Invalid HLSL splat cast.");
+  for(unsigned i = 0; i < StoreGEPList.size(); i ++) {
+llvm::Value *Cast = CGF.EmitScalarConversion(SrcVal, SrcTy,
+DestTypes[i],
+Loc);
+CGF.PerformStore(StoreGEPList[i], Cast);
+  }
+}
+
 // emit a flat cast where the RHS is a scalar, including vector
 static void EmitHLSLScalarFlatCast(CodeGenFunction &CGF, Address DestVal,
QualType DestTy, llvm::Value *SrcVal,
@@ -963,6 +990,21 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
   case CK_HLSLArrayRValue:
 Visit(E->getSubExpr());
 break;
+  case CK_HLSLSplatCast: {
+Expr *Src = E->getSubExpr();
+QualType SrcTy = Src->getType();
+RValue RV = CGF.EmitAnyExpr(Src);
+QualType DestTy = E->getType();
+Address DestVal = Dest.getAddress();
+SourceLocation Loc = E->getExprLoc();
+
+if (RV.isScalar()) {
+  llvm::Value *SrcVal = RV.getScalarVal();
+  EmitHLSLSplatCast(CGF, DestVal, DestTy, SrcVal, SrcTy, Loc);
+  break;
+}
+llvm_unreachable("RHS of HLSL splat cast must be a scalar or vector.");
+  }
   case CK_HLSLElementwiseCast: {
 Expr *Src = E->getSubExpr();
 QualType SrcTy = Src->getType();
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 80daed7e5395193..7dc2682bae42f2e 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2795,6 +2795,22 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
 llvm::Value *Zero = llvm::Constant::getNullValue(CGF.SizeTy);
 return Builder.CreateExtractElement(Vec, Zero, "cast.vtrunc");
   }
+  case CK_HLSLSplatCast: {
+assert(DestTy->isVectorType() && "Destination type must be a vector.");
+auto *DestVecTy = DestTy->getAs();
+QualType SrcTy = E->getType();
+ 

[clang] [Analysis] Avoid repeated hash lookups (NFC) (PR #126378)

2025-02-08 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/126378

None

>From f36d21e31c863829cfe49ac21093795500733e64 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 8 Feb 2025 00:53:38 -0800
Subject: [PATCH] [Analysis] Avoid repeated hash lookups (NFC)

---
 clang/lib/Analysis/UninitializedValues.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Analysis/UninitializedValues.cpp 
b/clang/lib/Analysis/UninitializedValues.cpp
index bf2f7306186507e..3a052eb27a444f4 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -379,8 +379,10 @@ void ClassifyRefs::classify(const Expr *E, Class C) {
   }
 
   FindVarResult Var = findVar(E, DC);
-  if (const DeclRefExpr *DRE = Var.getDeclRefExpr())
-Classification[DRE] = std::max(Classification[DRE], C);
+  if (const DeclRefExpr *DRE = Var.getDeclRefExpr()) {
+auto &Class = Classification[DRE];
+Class = std::max(Class, C);
+  }
 }
 
 void ClassifyRefs::VisitDeclStmt(DeclStmt *DS) {

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


[clang] [Analysis] Avoid repeated hash lookups (NFC) (PR #126378)

2025-02-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-analysis

Author: Kazu Hirata (kazutakahirata)


Changes



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


1 Files Affected:

- (modified) clang/lib/Analysis/UninitializedValues.cpp (+4-2) 


``diff
diff --git a/clang/lib/Analysis/UninitializedValues.cpp 
b/clang/lib/Analysis/UninitializedValues.cpp
index bf2f7306186507e..3a052eb27a444f4 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -379,8 +379,10 @@ void ClassifyRefs::classify(const Expr *E, Class C) {
   }
 
   FindVarResult Var = findVar(E, DC);
-  if (const DeclRefExpr *DRE = Var.getDeclRefExpr())
-Classification[DRE] = std::max(Classification[DRE], C);
+  if (const DeclRefExpr *DRE = Var.getDeclRefExpr()) {
+auto &Class = Classification[DRE];
+Class = std::max(Class, C);
+  }
 }
 
 void ClassifyRefs::VisitDeclStmt(DeclStmt *DS) {

``




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


[clang] [Analysis] Avoid repeated hash lookups (NFC) (PR #126378)

2025-02-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes



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


1 Files Affected:

- (modified) clang/lib/Analysis/UninitializedValues.cpp (+4-2) 


``diff
diff --git a/clang/lib/Analysis/UninitializedValues.cpp 
b/clang/lib/Analysis/UninitializedValues.cpp
index bf2f7306186507e..3a052eb27a444f4 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -379,8 +379,10 @@ void ClassifyRefs::classify(const Expr *E, Class C) {
   }
 
   FindVarResult Var = findVar(E, DC);
-  if (const DeclRefExpr *DRE = Var.getDeclRefExpr())
-Classification[DRE] = std::max(Classification[DRE], C);
+  if (const DeclRefExpr *DRE = Var.getDeclRefExpr()) {
+auto &Class = Classification[DRE];
+Class = std::max(Class, C);
+  }
 }
 
 void ClassifyRefs::VisitDeclStmt(DeclStmt *DS) {

``




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


[clang] [ByteCode] Avoid repeated hash lookups (NFC) (PR #126379)

2025-02-08 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/126379

None

>From 5f7f1eb799ce24dfa065816a7ed9772cd256f501 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 8 Feb 2025 00:52:15 -0800
Subject: [PATCH] [ByteCode] Avoid repeated hash lookups (NFC)

---
 clang/lib/AST/ByteCode/Program.cpp | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Program.cpp 
b/clang/lib/AST/ByteCode/Program.cpp
index e0b86d46428a266..833c9ef88d770f9 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -18,14 +18,12 @@ using namespace clang;
 using namespace clang::interp;
 
 unsigned Program::getOrCreateNativePointer(const void *Ptr) {
-  auto It = NativePointerIndices.find(Ptr);
-  if (It != NativePointerIndices.end())
-return It->second;
+  auto [It, Inserted] =
+  NativePointerIndices.try_emplace(Ptr, NativePointers.size());
+  if (Inserted)
+NativePointers.push_back(Ptr);
 
-  unsigned Idx = NativePointers.size();
-  NativePointers.push_back(Ptr);
-  NativePointerIndices[Ptr] = Idx;
-  return Idx;
+  return It->second;
 }
 
 const void *Program::getNativePointer(unsigned Idx) {

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


[clang] [ByteCode] Avoid repeated hash lookups (NFC) (PR #126379)

2025-02-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes



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


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/Program.cpp (+5-7) 


``diff
diff --git a/clang/lib/AST/ByteCode/Program.cpp 
b/clang/lib/AST/ByteCode/Program.cpp
index e0b86d46428a26..833c9ef88d770f 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -18,14 +18,12 @@ using namespace clang;
 using namespace clang::interp;
 
 unsigned Program::getOrCreateNativePointer(const void *Ptr) {
-  auto It = NativePointerIndices.find(Ptr);
-  if (It != NativePointerIndices.end())
-return It->second;
+  auto [It, Inserted] =
+  NativePointerIndices.try_emplace(Ptr, NativePointers.size());
+  if (Inserted)
+NativePointers.push_back(Ptr);
 
-  unsigned Idx = NativePointers.size();
-  NativePointers.push_back(Ptr);
-  NativePointerIndices[Ptr] = Idx;
-  return Idx;
+  return It->second;
 }
 
 const void *Program::getNativePointer(unsigned Idx) {

``




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


[clang] [flang] [lld] [Flang] Rename libFortranRuntime.a to libflang_rt.runtime.a (PR #122341)

2025-02-08 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang,flang,lld` at step 7 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/153/builds/22347


Here is the relevant piece of the build log for the reference

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/div-zero.cpp (94194 of 
98230)
UNSUPPORTED: UBSan-Standalone-lld-x86_64 :: 
TestCases/Misc/Posix/print_stack_trace.cpp (94195 of 98230)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/sub-overflow.cpp (94196 
of 98230)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/no-recover.cpp (94197 of 
98230)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/negate-overflow.cpp 
(94198 of 98230)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/Misc/local_bounds.cpp (94199 of 
98230)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/Misc/coverage-levels.cpp (94200 
of 98230)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/incdec-overflow.cpp 
(94201 of 98230)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/suppressions.cpp (94202 
of 98230)
TIMEOUT: MLIR :: Examples/standalone/test.toy (94203 of 98230)
 TEST 'MLIR :: Examples/standalone/test.toy' FAILED 

Exit Code: 1
Timeout: Reached timeout of 60 seconds

Command Output (stdout):
--
# RUN: at line 1
"/etc/cmake/bin/cmake" 
"/build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone"
 -G "Ninja"  -DCMAKE_CXX_COMPILER=/usr/bin/clang++  
-DCMAKE_C_COMPILER=/usr/bin/clang   -DLLVM_ENABLE_LIBCXX=OFF 
-DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir  
-DLLVM_USE_LINKER=lld  -DPython3_EXECUTABLE="/usr/bin/python3.10"
# executed command: /etc/cmake/bin/cmake 
/build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone 
-G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/clang++ 
-DCMAKE_C_COMPILER=/usr/bin/clang -DLLVM_ENABLE_LIBCXX=OFF 
-DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir 
-DLLVM_USE_LINKER=lld -DPython3_EXECUTABLE=/usr/bin/python3.10
# .---command stdout
# | -- The CXX compiler identification is Clang 16.0.6
# | -- The C compiler identification is Clang 16.0.6
# | -- Detecting CXX compiler ABI info
# | -- Detecting CXX compiler ABI info - done
# | -- Check for working CXX compiler: /usr/bin/clang++ - skipped
# | -- Detecting CXX compile features
# | -- Detecting CXX compile features - done
# | -- Detecting C compiler ABI info
# | -- Detecting C compiler ABI info - done
# | -- Check for working C compiler: /usr/bin/clang - skipped
# | -- Detecting C compile features
# | -- Detecting C compile features - done
# | -- Looking for histedit.h
# | -- Looking for histedit.h - found
# | -- Found LibEdit: /usr/include (found version "2.11") 
# | -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
# | -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version 
"2.9.13") 
# | -- Using MLIRConfig.cmake in: 
/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir
# | -- Using LLVMConfig.cmake in: 
/build/buildbot/premerge-monolithic-linux/build/lib/cmake/llvm
# | -- Linker detection: unknown
# | -- Performing Test LLVM_LIBSTDCXX_MIN
# | -- Performing Test LLVM_LIBSTDCXX_MIN - Success
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR - Success
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Success
# | -- Performing Test C_SUPPORTS_FPIC
# | -- Performing Test C_SUPPORTS_FPIC - Success
# | -- Performing Test CXX_SUPPORTS_FPIC

```



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


[clang] [CrossTU] Avoid repeated hash lookups (NFC) (PR #126380)

2025-02-08 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/126380

None

>From e30d1ca09ca613dac98345c3dd9ec0bd6b7cda66 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 8 Feb 2025 00:57:25 -0800
Subject: [PATCH] [CrossTU] Avoid repeated hash lookups (NFC)

---
 clang/lib/CrossTU/CrossTranslationUnit.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp 
b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 9faf2a8a173411b..ad2ebb6cd6e6c80 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -453,7 +453,8 @@ 
CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction(
   return std::move(IndexLoadError);
 
 // Check if there is an entry in the index for the function.
-if (!NameFileMap.count(FunctionName)) {
+auto It = NameFileMap.find(FunctionName);
+if (It == NameFileMap.end()) {
   ++NumNotInOtherTU;
   return 
llvm::make_error(index_error_code::missing_definition);
 }
@@ -461,7 +462,7 @@ 
CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction(
 // Search in the index for the filename where the definition of 
FunctionName
 // resides.
 if (llvm::Expected FoundForFile =
-getASTUnitForFile(NameFileMap[FunctionName], DisplayCTUProgress)) {
+getASTUnitForFile(It->second, DisplayCTUProgress)) {
 
   // Update the cache.
   NameASTUnitMap[FunctionName] = *FoundForFile;

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


[clang] [CrossTU] Avoid repeated hash lookups (NFC) (PR #126380)

2025-02-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes



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


1 Files Affected:

- (modified) clang/lib/CrossTU/CrossTranslationUnit.cpp (+3-2) 


``diff
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp 
b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 9faf2a8a173411b..ad2ebb6cd6e6c80 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -453,7 +453,8 @@ 
CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction(
   return std::move(IndexLoadError);
 
 // Check if there is an entry in the index for the function.
-if (!NameFileMap.count(FunctionName)) {
+auto It = NameFileMap.find(FunctionName);
+if (It == NameFileMap.end()) {
   ++NumNotInOtherTU;
   return 
llvm::make_error(index_error_code::missing_definition);
 }
@@ -461,7 +462,7 @@ 
CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction(
 // Search in the index for the filename where the definition of 
FunctionName
 // resides.
 if (llvm::Expected FoundForFile =
-getASTUnitForFile(NameFileMap[FunctionName], DisplayCTUProgress)) {
+getASTUnitForFile(It->second, DisplayCTUProgress)) {
 
   // Update the cache.
   NameASTUnitMap[FunctionName] = *FoundForFile;

``




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


[clang] [TableGen] Avoid repeated map lookups (NFC) (PR #126381)

2025-02-08 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/126381

None

>From 20fe55df1856cb8405af76671452229e01a048b5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 8 Feb 2025 00:55:57 -0800
Subject: [PATCH] [TableGen] Avoid repeated map lookups (NFC)

---
 clang/utils/TableGen/ClangOptionDocEmitter.cpp | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp 
b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
index e08fb11df310023..b6c1aad90b5cb91 100644
--- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -109,13 +109,17 @@ Documentation extractDocumentation(const RecordKeeper 
&Records,
 // Pretend no-X and Xno-Y options are aliases of X and XY.
 std::string Name = std::string(R->getValueAsString("Name"));
 if (Name.size() >= 4) {
-  if (Name.substr(0, 3) == "no-" && OptionsByName[Name.substr(3)]) {
-Aliases[OptionsByName[Name.substr(3)]].push_back(R);
-continue;
+  if (Name.substr(0, 3) == "no-") {
+if (const Record *Opt = OptionsByName[Name.substr(3)]) {
+  Aliases[Opt].push_back(R);
+  continue;
+}
   }
-  if (Name.substr(1, 3) == "no-" && OptionsByName[Name[0] + 
Name.substr(4)]) {
-Aliases[OptionsByName[Name[0] + Name.substr(4)]].push_back(R);
-continue;
+  if (Name.substr(1, 3) == "no-") {
+if (const Record *Opt = OptionsByName[Name[0] + Name.substr(4)]) {
+  Aliases[Opt].push_back(R);
+  continue;
+}
   }
 }
 

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


[clang] [TableGen] Avoid repeated map lookups (NFC) (PR #126381)

2025-02-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes



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


1 Files Affected:

- (modified) clang/utils/TableGen/ClangOptionDocEmitter.cpp (+10-6) 


``diff
diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp 
b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
index e08fb11df31002..b6c1aad90b5cb9 100644
--- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -109,13 +109,17 @@ Documentation extractDocumentation(const RecordKeeper 
&Records,
 // Pretend no-X and Xno-Y options are aliases of X and XY.
 std::string Name = std::string(R->getValueAsString("Name"));
 if (Name.size() >= 4) {
-  if (Name.substr(0, 3) == "no-" && OptionsByName[Name.substr(3)]) {
-Aliases[OptionsByName[Name.substr(3)]].push_back(R);
-continue;
+  if (Name.substr(0, 3) == "no-") {
+if (const Record *Opt = OptionsByName[Name.substr(3)]) {
+  Aliases[Opt].push_back(R);
+  continue;
+}
   }
-  if (Name.substr(1, 3) == "no-" && OptionsByName[Name[0] + 
Name.substr(4)]) {
-Aliases[OptionsByName[Name[0] + Name.substr(4)]].push_back(R);
-continue;
+  if (Name.substr(1, 3) == "no-") {
+if (const Record *Opt = OptionsByName[Name[0] + Name.substr(4)]) {
+  Aliases[Opt].push_back(R);
+  continue;
+}
   }
 }
 

``




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


[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)

2025-02-08 Thread Jonathan Schleifer via cfe-commits

https://github.com/Midar created 
https://github.com/llvm/llvm-project/pull/126382

There was no reason for it to ever be disabled.

>From 28cc71ac247b1fc8d4d9d4ecd7ea3f210bca3ef2 Mon Sep 17 00:00:00 2001
From: Jonathan Schleifer 
Date: Sat, 8 Feb 2025 12:12:21 +0100
Subject: [PATCH] Allow direct dispatch for the ObjFW runtime

There was no reason for it to ever be disabled.
---
 clang/include/clang/Basic/ObjCRuntime.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/ObjCRuntime.h 
b/clang/include/clang/Basic/ObjCRuntime.h
index 1ccf60f0b7bee70..df42b4389861118 100644
--- a/clang/include/clang/Basic/ObjCRuntime.h
+++ b/clang/include/clang/Basic/ObjCRuntime.h
@@ -473,7 +473,7 @@ class ObjCRuntime {
 case GCC: return false;
 case GNUstep:
   return (getVersion() >= VersionTuple(2, 2));
-case ObjFW: return false;
+case ObjFW: return true;
 }
 llvm_unreachable("bad kind");
   }

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


[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)

2025-02-08 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


  1   2   >