Pārlūkot izejas kodu

Update LLVM and update APIs (#6147)

This also updates the patch file for compiler-rt as upstream has changed
a bit. No functional change.
Chandler Carruth 5 mēneši atpakaļ
vecāks
revīzija
13bb660f7f

+ 3 - 3
MODULE.bazel

@@ -103,14 +103,14 @@ bazel_dep(name = "zstd", version = "1.5.7", repo_name = "llvm_zstd")
 
 # We pin to specific upstream commits and try to track top-of-tree reasonably
 # closely rather than pinning to a specific release.
-# HEAD as of 2025-09-07.
-llvm_project_version = "c000c9e4bf737c1cc0e5c7b435b24ea73d21ee05"
+# HEAD as of 2025-11-14.
+llvm_project_version = "b2a81888f55735e9249ef25b6014a989e7f03969"
 
 # Load a repository for the raw llvm-project, pre-overlay.
 http_archive(
     name = "llvm-raw",
     build_file_content = "# empty",
-    integrity = "sha256-6URudXFgqoCuQI4hbb7AlN4Wj7WzLHFB4AWGjUV0UAI=",
+    integrity = "sha256-PkRNmo5RZgP0RecsLW8kbg7SIS84OPX+StuNL4omIhw=",
     patch_args = ["-p1"],
     patches = [
         "@carbon//bazel/llvm_project:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",

+ 8 - 5
bazel/llvm_project/0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch

@@ -8,14 +8,13 @@ Subject: [PATCH] Add libfuzzer target to compiler-rt.
  1 file changed, 17 insertions(+)
 
 diff --git a/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel b/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel
-index 9bdd454e1e36..0f30c21f63dc 100644
+index 90264449de76..115da4cb77f6 100644
 --- a/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel
 +++ b/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel
-@@ -50,3 +50,20 @@ cc_library(
-         ":config",
+@@ -57,6 +57,23 @@ cc_library(
      ],
  )
-+
+
 +cc_library(
 +    name = "FuzzerMain",
 +    srcs = glob(
@@ -32,5 +31,9 @@ index 9bdd454e1e36..0f30c21f63dc 100644
 +    ],
 +    includes = ["lib/fuzzer"],
 +)
++
+ cc_library(
+     name = "orc_rt_common_headers",
+     hdrs = [
 --
-2.42.0
+2.42.0

+ 2 - 2
common/raw_hashtable_benchmark_helpers.cpp

@@ -61,7 +61,7 @@ static_assert(llvm::isPowerOf2_64(NumFourCharStrs));
 static auto MakeFourCharStrs(llvm::ArrayRef<char> characters, absl::BitGen& gen)
     -> llvm::OwningArrayRef<std::array<char, 4>> {
   constexpr ssize_t NumCharsMask = NumChars - 1;
-  constexpr ssize_t NumCharsShift = llvm::CTLog2<NumChars>();
+  constexpr ssize_t NumCharsShift = llvm::ConstantLog2<NumChars>();
   llvm::OwningArrayRef<std::array<char, 4>> four_char_strs(NumFourCharStrs);
   for (auto [i, str] : llvm::enumerate(four_char_strs)) {
     str[0] = characters[i & NumCharsMask];
@@ -372,7 +372,7 @@ auto DumpHashStatistics(llvm::ArrayRef<T> keys) -> void {
   ssize_t expected_size =
       llvm::NextPowerOf2(keys.size() + (keys.size() / 7) - 1);
 
-  constexpr int GroupShift = llvm::CTLog2<GroupSize>();
+  constexpr int GroupShift = llvm::ConstantLog2<GroupSize>();
 
   size_t mask = ComputeProbeMaskFromSize(expected_size);
   uint64_t salt = ComputeSeed();

+ 1 - 1
common/raw_hashtable_metadata_group.h

@@ -124,7 +124,7 @@ class BitIndex
       return reinterpret_cast<T*>(
           &reinterpret_cast<std::byte*>(pointer)[index]);
     } else if constexpr (llvm::isPowerOf2_64(sizeof(T))) {
-      constexpr size_t ScaleShift = llvm::CTLog2<sizeof(T)>();
+      constexpr size_t ScaleShift = llvm::ConstantLog2<sizeof(T)>();
       static_assert(ScaleShift <= ByteEncodingShift,
                     "Scaling by >=8 should be handled above!");
       constexpr size_t FoldedShift = ByteEncodingShift - ScaleShift;

+ 0 - 1
toolchain/base/llvm_tools.bzl

@@ -24,7 +24,6 @@ LLVM_MAIN_TOOLS = {
     "nm": struct(bin_name = "llvm-nm", lib = "@llvm-project//llvm:llvm-nm-lib"),
     "objcopy": struct(bin_name = "llvm-objcopy", lib = "@llvm-project//llvm:llvm-objcopy-lib"),
     "objdump": struct(bin_name = "llvm-objdump", lib = "@llvm-project//llvm:llvm-objdump-lib"),
-    "profdata": struct(bin_name = "llvm-profdata", lib = "@llvm-project//llvm:llvm-profdata-lib"),
     "rc": struct(bin_name = "llvm-rc", lib = "@llvm-project//llvm:llvm-rc-lib"),
     "readobj": struct(bin_name = "llvm-readobj", lib = "@llvm-project//llvm:llvm-readobj-lib"),
     "sancov": struct(bin_name = "sancov", lib = "@llvm-project//llvm:sancov-lib"),

+ 6 - 5
toolchain/check/cpp/import.cpp

@@ -1095,7 +1095,7 @@ static auto MapBuiltinIntegerType(Context& context, SemIR::LocId loc_id,
   unsigned width = ast_context.getIntWidth(qual_type);
   bool is_signed = type.isSignedInteger();
   auto int_n_type = ast_context.getIntTypeForBitwidth(width, is_signed);
-  if (ast_context.hasSameType(qual_type, int_n_type)) {
+  if (clang::ASTContext::hasSameType(qual_type, int_n_type)) {
     TypeExpr type_expr =
         MakeIntType(context, context.ints().Add(width), is_signed);
     // Try to make sure integer types of 32 or 64 bits are complete so we can
@@ -1108,11 +1108,12 @@ static auto MapBuiltinIntegerType(Context& context, SemIR::LocId loc_id,
     }
     return type_expr;
   }
-  if (ast_context.hasSameType(qual_type, ast_context.CharTy)) {
+  if (clang::ASTContext::hasSameType(qual_type, ast_context.CharTy)) {
     return ExprAsType(context, Parse::NodeId::None,
                       MakeCharTypeLiteral(context, Parse::NodeId::None));
   }
-  if (ast_context.hasSameType(qual_type, ast_context.LongTy) && width == 32) {
+  if (clang::ASTContext::hasSameType(qual_type, ast_context.LongTy) &&
+      width == 32) {
     return ExprAsType(context, Parse::NodeId::None,
                       LookupNameInCore(context, Parse::NodeId::None,
                                        {"CppCompat", "Long32"}));
@@ -1181,7 +1182,7 @@ static auto LookupCustomRecordType(Context& context,
 // Maps a C++ tag type (class, struct, union, enum) to a Carbon type.
 static auto MapTagType(Context& context, const clang::TagType& type)
     -> TypeExpr {
-  auto* tag_decl = type.getOriginalDecl();
+  auto* tag_decl = type.getDecl();
   CARBON_CHECK(tag_decl);
 
   // Check if the declaration is already mapped.
@@ -1833,7 +1834,7 @@ static auto AddDependentUnimportedTypeDecls(Context& context,
   }
 
   if (const auto* tag_type = type->getAs<clang::TagType>()) {
-    AddDependentDecl(context, SemIR::ClangDeclKey(tag_type->getOriginalDecl()),
+    AddDependentDecl(context, SemIR::ClangDeclKey(tag_type->getDecl()),
                      worklist);
   }
 }

+ 1 - 1
toolchain/check/testdata/interop/cpp/function/thunk_ast.carbon

@@ -64,7 +64,7 @@ auto foo(short a) -> void;
 // CHECK:STDOUT: | |-ParmVarDecl {{0x[a-f0-9]+}} <<invalid sloc>> <invalid sloc> implicit 'std::align_val_t'
 // CHECK:STDOUT: | `-VisibilityAttr {{0x[a-f0-9]+}} <<invalid sloc>> Implicit Default
 // CHECK:STDOUT: |-FunctionDecl {{0x[a-f0-9]+}} <<carbon-internal>:8:1, line:14:1> line:8:7 operator new 'void *(unsigned long, void *) noexcept'
-// CHECK:STDOUT: | |-ParmVarDecl {{0x[a-f0-9]+}} <<built-in>:174:23, col:37> <carbon-internal>:8:33 'unsigned long'
+// CHECK:STDOUT: | |-ParmVarDecl {{0x[a-f0-9]+}} <<built-in>:176:23, col:37> <carbon-internal>:8:33 'unsigned long'
 // CHECK:STDOUT: | `-ParmVarDecl {{0x[a-f0-9]+}} <col:35, col:39> col:40 'void *'
 // CHECK:STDOUT: `-FunctionDecl {{0x[a-f0-9]+}} <./thunk_required.h:[[@LINE-51]]:6> col:6 foo__carbon_thunk 'void (short * _Nonnull)' extern
 // CHECK:STDOUT:   |-ParmVarDecl {{0x[a-f0-9]+}} <col:6> col:6 used a 'short * _Nonnull':'short *'

+ 5 - 2
toolchain/driver/clang_runner.cpp

@@ -326,8 +326,11 @@ auto ClangRunner::RunCC1(llvm::SmallVectorImpl<const char*>& cc1_args) -> int {
         installation_->clang_resource_path();
   }
 
+  // Create the filesystem.
+  clang_instance->createVirtualFileSystem(fs_, &diag_buffer);
+
   // Create the actual diagnostics engine.
-  clang_instance->createDiagnostics(*fs_);
+  clang_instance->createDiagnostics();
   if (!clang_instance->hasDiagnostics()) {
     return EXIT_FAILURE;
   }
@@ -374,7 +377,7 @@ auto ClangRunner::RunCC1(llvm::SmallVectorImpl<const char*>& cc1_args) -> int {
     // options are stored in the compiler invocation and we can recreate the VFS
     // from the compiler invocation.
     if (!clang_instance->hasFileManager()) {
-      clang_instance->createFileManager(fs_);
+      clang_instance->createFileManager();
     }
 
     if (auto profiler_output = clang_instance->createOutputFile(

+ 0 - 1
toolchain/driver/llvm_runner_test.cpp

@@ -47,7 +47,6 @@ TEST(LLVMRunnerTest, Version) {
       case LLVMTool::InstallNameTool:
       case LLVMTool::Lipo:
       case LLVMTool::Objcopy:
-      case LLVMTool::Profdata:
       case LLVMTool::Sancov:
       case LLVMTool::Strip:
       case LLVMTool::Symbolizer: