summaryrefslogtreecommitdiffstats
path: root/build/build-clang
diff options
context:
space:
mode:
Diffstat (limited to 'build/build-clang')
-rw-r--r--build/build-clang/arm64e-hack.patch52
-rw-r--r--build/build-clang/clang-17.json4
-rw-r--r--build/build-clang/clang-18.json4
-rw-r--r--build/build-clang/clang-trunk.json6
-rw-r--r--build/build-clang/llvm-symbolizer-17.json7
-rw-r--r--build/build-clang/llvm-symbolizer-18.json7
-rw-r--r--build/build-clang/llvm-symbolizer-trunk.json11
-rw-r--r--build/build-clang/revert-llvmorg-16-init-11301-g163bb6d64e5f_clang_19.patch183
-rw-r--r--build/build-clang/revert-llvmorg-19-init-6891-ga4de589d117a.patch547
-rw-r--r--build/build-clang/revert-llvmorg-19-init-6898-g60deb8b39afe.patch66
-rw-r--r--build/build-clang/revert-llvmorg-19-init-6902-gbdb60e6f0c8e.patch24
-rw-r--r--build/build-clang/revert-llvmorg-19-init-7044-g30fd099d5062.patch58
12 files changed, 959 insertions, 10 deletions
diff --git a/build/build-clang/arm64e-hack.patch b/build/build-clang/arm64e-hack.patch
new file mode 100644
index 0000000000..8856fd2f5b
--- /dev/null
+++ b/build/build-clang/arm64e-hack.patch
@@ -0,0 +1,52 @@
+Add hackish support for arm64e to LLD
+
+The current lld output is known as arm64e.old. This hack adds the right flag to
+make it appear as arm64e.
+
+An upstreamable solution would be more involved.
+
+diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
+index 14c111ce9685..45fa7c59c420 100644
+--- a/lld/MachO/Driver.cpp
++++ b/lld/MachO/Driver.cpp
+@@ -773,8 +773,13 @@ static TargetInfo *createTargetInfo(InputArgList &args) {
+ switch (cpuType) {
+ case CPU_TYPE_X86_64:
+ return createX86_64TargetInfo();
+- case CPU_TYPE_ARM64:
+- return createARM64TargetInfo();
++ case CPU_TYPE_ARM64: {
++ auto target = createARM64TargetInfo();
++ if (cpuSubtype == CPU_SUBTYPE_ARM64E) {
++ target->cpuSubtype = CPU_SUBTYPE_ARM64E | CPU_SUBTYPE_PTRAUTH_ABI;
++ }
++ return target;
++ }
+ case CPU_TYPE_ARM64_32:
+ return createARM64_32TargetInfo();
+ default:
+diff --git a/lldb/include/lldb/Host/SafeMachO.h b/lldb/include/lldb/Host/SafeMachO.h
+index 0540383b8c52..a7650f760305 100644
+--- a/lldb/include/lldb/Host/SafeMachO.h
++++ b/lldb/include/lldb/Host/SafeMachO.h
+@@ -115,6 +115,8 @@
+ #undef CPU_SUBTYPE_MC980000_ALL
+ #undef CPU_SUBTYPE_MC98601
+
++#undef CPU_SUBTYPE_PTRAUTH_ABI
++
+ #undef VM_PROT_READ
+ #undef VM_PROT_WRITE
+ #undef VM_PROT_EXECUTE
+diff --git a/llvm/include/llvm/BinaryFormat/MachO.h b/llvm/include/llvm/BinaryFormat/MachO.h
+index bef70f869520..7dfe5d031381 100644
+--- a/llvm/include/llvm/BinaryFormat/MachO.h
++++ b/llvm/include/llvm/BinaryFormat/MachO.h
+@@ -1578,6 +1578,7 @@ enum : uint32_t {
+ // Capability bits used in the definition of cpusubtype.
+ CPU_SUBTYPE_MASK = 0xff000000, // Mask for architecture bits
+ CPU_SUBTYPE_LIB64 = 0x80000000, // 64 bit libraries
++ CPU_SUBTYPE_PTRAUTH_ABI = 0x80000000, // pointer authentication with versioned ABI
+
+ // Special CPU subtype constants.
+ CPU_SUBTYPE_MULTIPLE = ~0u
diff --git a/build/build-clang/clang-17.json b/build/build-clang/clang-17.json
index 1e941aac77..3d855cbec8 100644
--- a/build/build-clang/clang-17.json
+++ b/build/build-clang/clang-17.json
@@ -5,15 +5,13 @@
"unpoison-thread-stacks_clang_10.patch",
"downgrade-mangling-error_clang_12.patch",
"fuzzing_ccov_build_clang_12.patch",
- "partial-revert-llvmorg-17-init-17713-gc8e055d485ea.patch",
- "revert-llvmorg-17-init-4120-g02e8eb1a438b.patch",
"partial-revert-llvmorg-16-init-17151-gaa0883b59ae1_clang_17.patch",
"revert-llvmorg-16-init-11301-g163bb6d64e5f_clang_17.patch",
"revert-llvmorg-15-init-13446-g7524fe962e47.patch",
- "revert-llvmorg-15-init-11205-gcead4eceb01b_clang_16.patch",
"llvmorg-18-init-8471-g160e8eb44961.patch",
"D146664.patch",
"win64-ret-null-on-commitment-limit_clang_14.patch",
+ "arm64e-hack.patch",
"compiler-rt-rss-limit-heap-profile.patch"
]
}
diff --git a/build/build-clang/clang-18.json b/build/build-clang/clang-18.json
index 5f66e58947..8290f31048 100644
--- a/build/build-clang/clang-18.json
+++ b/build/build-clang/clang-18.json
@@ -9,13 +9,11 @@
"revert-llvmorg-18-init-6208-g2baf4a06ef06.patch",
"revert-llvmorg-18-init-6193-gb88cffeafd39.patch",
"revert-llvmorg-18-init-6188-gc649f29c24c9.patch",
- "partial-revert-llvmorg-17-init-17713-gc8e055d485ea.patch",
- "revert-llvmorg-17-init-4120-g02e8eb1a438b_clang_18.patch",
"partial-revert-llvmorg-16-init-17151-gaa0883b59ae1_clang_17.patch",
"revert-llvmorg-16-init-11301-g163bb6d64e5f_clang_18.patch",
"revert-llvmorg-15-init-13446-g7524fe962e47.patch",
- "revert-llvmorg-15-init-11205-gcead4eceb01b_clang_18.patch",
"win64-ret-null-on-commitment-limit_clang_14.patch",
+ "arm64e-hack.patch",
"compiler-rt-rss-limit-heap-profile.patch"
]
}
diff --git a/build/build-clang/clang-trunk.json b/build/build-clang/clang-trunk.json
index 5f66e58947..2e39e7a0ec 100644
--- a/build/build-clang/clang-trunk.json
+++ b/build/build-clang/clang-trunk.json
@@ -9,13 +9,11 @@
"revert-llvmorg-18-init-6208-g2baf4a06ef06.patch",
"revert-llvmorg-18-init-6193-gb88cffeafd39.patch",
"revert-llvmorg-18-init-6188-gc649f29c24c9.patch",
- "partial-revert-llvmorg-17-init-17713-gc8e055d485ea.patch",
- "revert-llvmorg-17-init-4120-g02e8eb1a438b_clang_18.patch",
"partial-revert-llvmorg-16-init-17151-gaa0883b59ae1_clang_17.patch",
- "revert-llvmorg-16-init-11301-g163bb6d64e5f_clang_18.patch",
+ "revert-llvmorg-16-init-11301-g163bb6d64e5f_clang_19.patch",
"revert-llvmorg-15-init-13446-g7524fe962e47.patch",
- "revert-llvmorg-15-init-11205-gcead4eceb01b_clang_18.patch",
"win64-ret-null-on-commitment-limit_clang_14.patch",
+ "arm64e-hack.patch",
"compiler-rt-rss-limit-heap-profile.patch"
]
}
diff --git a/build/build-clang/llvm-symbolizer-17.json b/build/build-clang/llvm-symbolizer-17.json
new file mode 100644
index 0000000000..211c613d3d
--- /dev/null
+++ b/build/build-clang/llvm-symbolizer-17.json
@@ -0,0 +1,7 @@
+{
+ "patches": [
+ "partial-revert-llvmorg-17-init-17713-gc8e055d485ea.patch",
+ "revert-llvmorg-17-init-4120-g02e8eb1a438b.patch",
+ "revert-llvmorg-15-init-11205-gcead4eceb01b_clang_16.patch"
+ ]
+}
diff --git a/build/build-clang/llvm-symbolizer-18.json b/build/build-clang/llvm-symbolizer-18.json
new file mode 100644
index 0000000000..357eab9792
--- /dev/null
+++ b/build/build-clang/llvm-symbolizer-18.json
@@ -0,0 +1,7 @@
+{
+ "patches": [
+ "partial-revert-llvmorg-17-init-17713-gc8e055d485ea.patch",
+ "revert-llvmorg-17-init-4120-g02e8eb1a438b.patch",
+ "revert-llvmorg-15-init-11205-gcead4eceb01b_clang_18.patch"
+ ]
+}
diff --git a/build/build-clang/llvm-symbolizer-trunk.json b/build/build-clang/llvm-symbolizer-trunk.json
new file mode 100644
index 0000000000..8aa80eff8c
--- /dev/null
+++ b/build/build-clang/llvm-symbolizer-trunk.json
@@ -0,0 +1,11 @@
+{
+ "patches": [
+ "revert-llvmorg-19-init-7044-g30fd099d5062.patch",
+ "revert-llvmorg-19-init-6902-gbdb60e6f0c8e.patch",
+ "revert-llvmorg-19-init-6898-g60deb8b39afe.patch",
+ "revert-llvmorg-19-init-6891-ga4de589d117a.patch",
+ "partial-revert-llvmorg-17-init-17713-gc8e055d485ea.patch",
+ "revert-llvmorg-17-init-4120-g02e8eb1a438b.patch",
+ "revert-llvmorg-15-init-11205-gcead4eceb01b_clang_18.patch"
+ ]
+}
diff --git a/build/build-clang/revert-llvmorg-16-init-11301-g163bb6d64e5f_clang_19.patch b/build/build-clang/revert-llvmorg-16-init-11301-g163bb6d64e5f_clang_19.patch
new file mode 100644
index 0000000000..a296eb9153
--- /dev/null
+++ b/build/build-clang/revert-llvmorg-16-init-11301-g163bb6d64e5f_clang_19.patch
@@ -0,0 +1,183 @@
+From cf00b30288c4c81b2c6a5af01c38f236148777a0 Mon Sep 17 00:00:00 2001
+From: Mike Hommey <mh@glandium.org>
+Date: Tue, 28 Mar 2023 06:13:36 +0900
+Subject: [PATCH] Revert "[Passes][VectorCombine] enable early run generally
+ and try load folds"
+
+This reverts commit 163bb6d64e5f1220777c3ec2a8b58c0666a74d91.
+It causes various reftest regressions.
+---
+ llvm/lib/Passes/PassBuilderPipelines.cpp | 7 ++++---
+ llvm/lib/Transforms/Vectorize/VectorCombine.cpp | 8 ++------
+ llvm/test/Other/new-pm-defaults.ll | 2 +-
+ .../Other/new-pm-thinlto-postlink-defaults.ll | 1 -
+ .../Other/new-pm-thinlto-postlink-pgo-defaults.ll | 1 -
+ .../new-pm-thinlto-postlink-samplepgo-defaults.ll | 1 -
+ .../Other/new-pm-thinlto-prelink-pgo-defaults.ll | 1 -
+ .../new-pm-thinlto-prelink-samplepgo-defaults.ll | 1 -
+ .../PhaseOrdering/X86/vec-load-combine.ll | 15 +++++++++++----
+ 9 files changed, 18 insertions(+), 19 deletions(-)
+
+diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
+index eed29c25714b..b925448cd6c0 100644
+--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
++++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
+@@ -611,9 +611,10 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
+ // Delete small array after loop unroll.
+ FPM.addPass(SROAPass(SROAOptions::ModifyCFG));
+
+- // Try vectorization/scalarization transforms that are both improvements
+- // themselves and can allow further folds with GVN and InstCombine.
+- FPM.addPass(VectorCombinePass(/*TryEarlyFoldsOnly=*/true));
++ // The matrix extension can introduce large vector operations early, which can
++ // benefit from running vector-combine early on.
++ if (EnableMatrix)
++ FPM.addPass(VectorCombinePass(/*TryEarlyFoldsOnly=*/true));
+
+ // Eliminate redundancies.
+ FPM.addPass(MergedLoadStoreMotionPass());
+diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+index 2e489757ebc1..810a9f92bb7a 100644
+--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
++++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+@@ -1715,23 +1715,6 @@ bool VectorCombine::run() {
+ bool IsFixedVectorType = isa<FixedVectorType>(I.getType());
+ auto Opcode = I.getOpcode();
+
+- // These folds should be beneficial regardless of when this pass is run
+- // in the optimization pipeline.
+- // The type checking is for run-time efficiency. We can avoid wasting time
+- // dispatching to folding functions if there's no chance of matching.
+- if (IsFixedVectorType) {
+- switch (Opcode) {
+- case Instruction::InsertElement:
+- MadeChange |= vectorizeLoadInsert(I);
+- break;
+- case Instruction::ShuffleVector:
+- MadeChange |= widenSubvectorLoad(I);
+- break;
+- default:
+- break;
+- }
+- }
+-
+ // This transform works with scalable and fixed vectors
+ // TODO: Identify and allow other scalable transforms
+ if (isa<VectorType>(I.getType())) {
+@@ -1753,9 +1736,11 @@ bool VectorCombine::run() {
+ if (IsFixedVectorType) {
+ switch (Opcode) {
+ case Instruction::InsertElement:
++ MadeChange |= vectorizeLoadInsert(I);
+ MadeChange |= foldInsExtFNeg(I);
+ break;
+ case Instruction::ShuffleVector:
++ MadeChange |= widenSubvectorLoad(I);
+ MadeChange |= foldShuffleOfBinops(I);
+ MadeChange |= foldShuffleOfCastops(I);
+ MadeChange |= foldSelectShuffle(I);
+diff --git a/llvm/test/Other/new-pm-defaults.ll b/llvm/test/Other/new-pm-defaults.ll
+index 13612c3bb459..5f84d28af4a6 100644
+--- a/llvm/test/Other/new-pm-defaults.ll
++++ b/llvm/test/Other/new-pm-defaults.ll
+@@ -186,7 +186,7 @@
+ ; CHECK-O-NEXT: Running pass: LoopFullUnrollPass
+ ; CHECK-EP-LOOP-END-NEXT: Running pass: NoOpLoopPass
+ ; CHECK-O-NEXT: Running pass: SROAPass on foo
+-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass
++; CHECK-MATRIX: Running pass: VectorCombinePass
+ ; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass
+ ; CHECK-O23SZ-NEXT: Running pass: GVNPass
+ ; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis
+diff --git a/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
+index 3f5d2d5b153d..ea07128c9f6a 100644
+--- a/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
++++ b/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
+@@ -159,7 +159,6 @@
+ ; CHECK-O-NEXT: Running pass: LoopDeletionPass
+ ; CHECK-O-NEXT: Running pass: LoopFullUnrollPass
+ ; CHECK-O-NEXT: Running pass: SROAPass on foo
+-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass
+ ; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass
+ ; CHECK-O23SZ-NEXT: Running pass: GVNPass
+ ; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis
+diff --git a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
+index 29021ceace54..43e943cb6011 100644
+--- a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
++++ b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
+@@ -121,7 +121,6 @@
+ ; CHECK-O-NEXT: Running pass: LoopDeletionPass
+ ; CHECK-O-NEXT: Running pass: LoopFullUnrollPass
+ ; CHECK-O-NEXT: Running pass: SROAPass on foo
+-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass
+ ; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass
+ ; CHECK-O23SZ-NEXT: Running pass: GVNPass
+ ; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis
+diff --git a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
+index daf3141a1f2c..78914d1c23b2 100644
+--- a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
++++ b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
+@@ -130,7 +130,6 @@
+ ; CHECK-O-NEXT: Running pass: LoopDeletionPass
+ ; CHECK-O-NEXT: Running pass: LoopFullUnrollPass
+ ; CHECK-O-NEXT: Running pass: SROAPass on foo
+-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass
+ ; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass
+ ; CHECK-O23SZ-NEXT: Running pass: GVNPass
+ ; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis
+diff --git a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+index bfe80902f806..5b62ba39add3 100644
+--- a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
++++ b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+@@ -160,7 +160,6 @@
+ ; CHECK-O-NEXT: Running pass: LoopDeletionPass
+ ; CHECK-O-NEXT: Running pass: LoopFullUnrollPass
+ ; CHECK-O-NEXT: Running pass: SROAPass on foo
+-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass
+ ; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass
+ ; CHECK-O23SZ-NEXT: Running pass: GVNPass
+ ; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis
+diff --git a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+index c7daf7aa46b1..17475423d696 100644
+--- a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
++++ b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+@@ -124,7 +124,6 @@
+ ; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
+ ; CHECK-O-NEXT: Running pass: LoopDeletionPass
+ ; CHECK-O-NEXT: Running pass: SROAPass on foo
+-; CHECK-O23SZ-NEXT: Running pass: VectorCombinePass
+ ; CHECK-O23SZ-NEXT: Running pass: MergedLoadStoreMotionPass
+ ; CHECK-O23SZ-NEXT: Running pass: GVNPass
+ ; CHECK-O23SZ-NEXT: Running analysis: MemoryDependenceAnalysis
+diff --git a/llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll b/llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll
+index 77cbc70ff369..dd7164febea4 100644
+--- a/llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll
++++ b/llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll
+@@ -12,13 +12,20 @@ $getAt = comdat any
+ define dso_local noundef <4 x float> @ConvertVectors_ByRef(ptr noundef nonnull align 16 dereferenceable(16) %0) #0 {
+ ; SSE-LABEL: @ConvertVectors_ByRef(
+ ; SSE-NEXT: [[TMP2:%.*]] = load <4 x float>, ptr [[TMP0:%.*]], align 16
+-; SSE-NEXT: [[TMP3:%.*]] = shufflevector <4 x float> [[TMP2]], <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 2>
+-; SSE-NEXT: ret <4 x float> [[TMP3]]
++; SSE-NEXT: [[TMP3:%.*]] = getelementptr inbounds [4 x float], ptr [[TMP0]], i64 0, i64 1
++; SSE-NEXT: [[TMP4:%.*]] = load <2 x float>, ptr [[TMP3]], align 4
++; SSE-NEXT: [[TMP5:%.*]] = shufflevector <2 x float> [[TMP4]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
++; SSE-NEXT: [[TMP6:%.*]] = shufflevector <4 x float> [[TMP2]], <4 x float> [[TMP5]], <4 x i32> <i32 0, i32 4, i32 5, i32 undef>
++; SSE-NEXT: [[TMP7:%.*]] = shufflevector <4 x float> [[TMP6]], <4 x float> [[TMP5]], <4 x i32> <i32 0, i32 1, i32 2, i32 5>
++; SSE-NEXT: ret <4 x float> [[TMP7]]
+ ;
+ ; AVX-LABEL: @ConvertVectors_ByRef(
+ ; AVX-NEXT: [[TMP2:%.*]] = load <4 x float>, ptr [[TMP0:%.*]], align 16
+-; AVX-NEXT: [[TMP3:%.*]] = shufflevector <4 x float> [[TMP2]], <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 2>
+-; AVX-NEXT: ret <4 x float> [[TMP3]]
++; AVX-NEXT: [[TMP3:%.*]] = getelementptr inbounds [4 x float], ptr [[TMP0]], i64 0, i64 2
++; AVX-NEXT: [[TMP4:%.*]] = load float, ptr [[TMP3]], align 8
++; AVX-NEXT: [[TMP5:%.*]] = insertelement <4 x float> [[TMP2]], float [[TMP4]], i64 2
++; AVX-NEXT: [[TMP6:%.*]] = insertelement <4 x float> [[TMP5]], float [[TMP4]], i64 3
++; AVX-NEXT: ret <4 x float> [[TMP6]]
+ ;
+ %2 = alloca ptr, align 8
+ %3 = alloca <4 x float>, align 16
+--
+2.39.0.1.g6739ec1790
+
diff --git a/build/build-clang/revert-llvmorg-19-init-6891-ga4de589d117a.patch b/build/build-clang/revert-llvmorg-19-init-6891-ga4de589d117a.patch
new file mode 100644
index 0000000000..a54bb501a1
--- /dev/null
+++ b/build/build-clang/revert-llvmorg-19-init-6891-ga4de589d117a.patch
@@ -0,0 +1,547 @@
+From 4ec62cd0d0eb38965cac21aca62b6ac01a5b052e Mon Sep 17 00:00:00 2001
+From: Mike Hommey <mh@glandium.org>
+Date: Fri, 5 Apr 2024 05:59:24 +0900
+Subject: [PATCH 4/4] Revert "[InstallAPI] Add support for parsing dSYMs
+ (#86852)"
+
+This reverts commit a4de589d117a4fd52554da3c61ae6eb26c90a0c8.
+---
+ .../include/clang/InstallAPI/DylibVerifier.h | 20 +---
+ clang/include/clang/InstallAPI/MachO.h | 1 -
+ clang/lib/InstallAPI/CMakeLists.txt | 1 -
+ clang/lib/InstallAPI/DylibVerifier.cpp | 71 +++--------
+ clang/test/InstallAPI/diagnostics-dsym.test | 43 -------
+ .../tools/clang-installapi/InstallAPIOpts.td | 2 -
+ clang/tools/clang-installapi/Options.cpp | 6 +-
+ clang/tools/clang-installapi/Options.h | 3 -
+ llvm/include/llvm/TextAPI/DylibReader.h | 9 --
+ llvm/include/llvm/TextAPI/Record.h | 17 ---
+ llvm/lib/TextAPI/BinaryReader/CMakeLists.txt | 1 -
+ llvm/lib/TextAPI/BinaryReader/DylibReader.cpp | 111 +-----------------
+ 12 files changed, 22 insertions(+), 263 deletions(-)
+ delete mode 100644 clang/test/InstallAPI/diagnostics-dsym.test
+
+diff --git a/clang/include/clang/InstallAPI/DylibVerifier.h b/clang/include/clang/InstallAPI/DylibVerifier.h
+index 22cdc234486c..49de24763f1f 100644
+--- a/clang/include/clang/InstallAPI/DylibVerifier.h
++++ b/clang/include/clang/InstallAPI/DylibVerifier.h
+@@ -31,7 +31,6 @@ enum class VerificationMode {
+ class DylibVerifier : llvm::MachO::RecordVisitor {
+ private:
+ struct SymbolContext;
+- struct DWARFContext;
+
+ public:
+ enum class Result { NoVerify, Ignore, Valid, Invalid };
+@@ -55,7 +54,7 @@ public:
+ DiagnosticsEngine *Diag = nullptr;
+
+ // Handle diagnostics reporting for target level violations.
+- void emitDiag(llvm::function_ref<void()> Report, RecordLoc *Loc = nullptr);
++ void emitDiag(llvm::function_ref<void()> Report);
+
+ VerifierContext() = default;
+ VerifierContext(DiagnosticsEngine *Diag) : Diag(Diag) {}
+@@ -64,10 +63,9 @@ public:
+ DylibVerifier() = default;
+
+ DylibVerifier(llvm::MachO::Records &&Dylib, DiagnosticsEngine *Diag,
+- VerificationMode Mode, bool Demangle, StringRef DSYMPath)
++ VerificationMode Mode, bool Demangle)
+ : Dylib(std::move(Dylib)), Mode(Mode), Demangle(Demangle),
+- DSYMPath(DSYMPath), Exports(std::make_unique<SymbolSet>()),
+- Ctx(VerifierContext{Diag}) {}
++ Exports(std::make_unique<SymbolSet>()), Ctx(VerifierContext{Diag}) {}
+
+ Result verify(GlobalRecord *R, const FrontendAttrs *FA);
+ Result verify(ObjCInterfaceRecord *R, const FrontendAttrs *FA);
+@@ -145,12 +143,6 @@ private:
+ std::string getAnnotatedName(const Record *R, SymbolContext &SymCtx,
+ bool ValidSourceLoc = true);
+
+- /// Extract source location for symbol implementations.
+- /// As this is a relatively expensive operation, it is only used
+- /// when there is a violation to report and there is not a known declaration
+- /// in the interface.
+- void accumulateSrcLocForDylibSymbols();
+-
+ // Symbols in dylib.
+ llvm::MachO::Records Dylib;
+
+@@ -160,17 +152,11 @@ private:
+ // Attempt to demangle when reporting violations.
+ bool Demangle = false;
+
+- // File path to DSYM file.
+- StringRef DSYMPath;
+-
+ // Valid symbols in final text file.
+ std::unique_ptr<SymbolSet> Exports = std::make_unique<SymbolSet>();
+
+ // Track current state of verification while traversing AST.
+ VerifierContext Ctx;
+-
+- // Track DWARF provided source location for dylibs.
+- DWARFContext *DWARFCtx = nullptr;
+ };
+
+ } // namespace installapi
+diff --git a/clang/include/clang/InstallAPI/MachO.h b/clang/include/clang/InstallAPI/MachO.h
+index 827220dbf39f..4961c596fd68 100644
+--- a/clang/include/clang/InstallAPI/MachO.h
++++ b/clang/include/clang/InstallAPI/MachO.h
+@@ -34,7 +34,6 @@ using ObjCCategoryRecord = llvm::MachO::ObjCCategoryRecord;
+ using ObjCIVarRecord = llvm::MachO::ObjCIVarRecord;
+ using ObjCIFSymbolKind = llvm::MachO::ObjCIFSymbolKind;
+ using Records = llvm::MachO::Records;
+-using RecordLoc = llvm::MachO::RecordLoc;
+ using RecordsSlice = llvm::MachO::RecordsSlice;
+ using BinaryAttrs = llvm::MachO::RecordsSlice::BinaryAttrs;
+ using SymbolSet = llvm::MachO::SymbolSet;
+diff --git a/clang/lib/InstallAPI/CMakeLists.txt b/clang/lib/InstallAPI/CMakeLists.txt
+index e0bc8d969ecb..894db699578f 100644
+--- a/clang/lib/InstallAPI/CMakeLists.txt
++++ b/clang/lib/InstallAPI/CMakeLists.txt
+@@ -1,7 +1,6 @@
+ set(LLVM_LINK_COMPONENTS
+ Support
+ TextAPI
+- TextAPIBinaryReader
+ Demangle
+ Core
+ )
+diff --git a/clang/lib/InstallAPI/DylibVerifier.cpp b/clang/lib/InstallAPI/DylibVerifier.cpp
+index c0eda1d81b9b..ba25e4183a9b 100644
+--- a/clang/lib/InstallAPI/DylibVerifier.cpp
++++ b/clang/lib/InstallAPI/DylibVerifier.cpp
+@@ -10,7 +10,6 @@
+ #include "clang/InstallAPI/FrontendRecords.h"
+ #include "clang/InstallAPI/InstallAPIDiagnostic.h"
+ #include "llvm/Demangle/Demangle.h"
+-#include "llvm/TextAPI/DylibReader.h"
+
+ using namespace llvm::MachO;
+
+@@ -36,14 +35,6 @@ struct DylibVerifier::SymbolContext {
+ bool Inlined = false;
+ };
+
+-struct DylibVerifier::DWARFContext {
+- // Track whether DSYM parsing has already been attempted to avoid re-parsing.
+- bool ParsedDSYM{false};
+-
+- // Lookup table for source locations by symbol name.
+- DylibReader::SymbolToSourceLocMap SourceLocs{};
+-};
+-
+ static bool isCppMangled(StringRef Name) {
+ // InstallAPI currently only supports itanium manglings.
+ return (Name.starts_with("_Z") || Name.starts_with("__Z") ||
+@@ -520,16 +511,14 @@ DylibVerifier::Result DylibVerifier::verify(GlobalRecord *R,
+ return verifyImpl(R, SymCtx);
+ }
+
+-void DylibVerifier::VerifierContext::emitDiag(llvm::function_ref<void()> Report,
+- RecordLoc *Loc) {
++void DylibVerifier::VerifierContext::emitDiag(
++ llvm::function_ref<void()> Report) {
+ if (!DiscoveredFirstError) {
+ Diag->Report(diag::warn_target)
+ << (PrintArch ? getArchitectureName(Target.Arch)
+ : getTargetTripleName(Target));
+ DiscoveredFirstError = true;
+ }
+- if (Loc && Loc->isValid())
+- llvm::errs() << Loc->File << ":" << Loc->Line << ":" << 0 << ": ";
+
+ Report();
+ }
+@@ -572,36 +561,26 @@ void DylibVerifier::visitSymbolInDylib(const Record &R, SymbolContext &SymCtx) {
+ return;
+ }
+
+- const bool IsLinkerSymbol = SymbolName.starts_with("$ld$");
+-
+- // All checks at this point classify as some kind of violation.
+- // The different verification modes dictate whether they are reported to the
+- // user.
+- if (IsLinkerSymbol || (Mode > VerificationMode::ErrorsOnly))
+- accumulateSrcLocForDylibSymbols();
+- RecordLoc Loc = DWARFCtx->SourceLocs.lookup(SymCtx.SymbolName);
++ // All checks at this point classify as some kind of violation that should be
++ // reported.
+
+ // Regardless of verification mode, error out on mismatched special linker
+ // symbols.
+- if (IsLinkerSymbol) {
+- Ctx.emitDiag(
+- [&]() {
+- Ctx.Diag->Report(diag::err_header_symbol_missing)
+- << getAnnotatedName(&R, SymCtx, Loc.isValid());
+- },
+- &Loc);
++ if (SymbolName.starts_with("$ld$")) {
++ Ctx.emitDiag([&]() {
++ Ctx.Diag->Report(diag::err_header_symbol_missing)
++ << getAnnotatedName(&R, SymCtx, /*ValidSourceLoc=*/false);
++ });
+ updateState(Result::Invalid);
+ return;
+ }
+
+ // Missing declarations for exported symbols are hard errors on Pedantic mode.
+ if (Mode == VerificationMode::Pedantic) {
+- Ctx.emitDiag(
+- [&]() {
+- Ctx.Diag->Report(diag::err_header_symbol_missing)
+- << getAnnotatedName(&R, SymCtx, Loc.isValid());
+- },
+- &Loc);
++ Ctx.emitDiag([&]() {
++ Ctx.Diag->Report(diag::err_header_symbol_missing)
++ << getAnnotatedName(&R, SymCtx, /*ValidSourceLoc=*/false);
++ });
+ updateState(Result::Invalid);
+ return;
+ }
+@@ -609,12 +588,10 @@ void DylibVerifier::visitSymbolInDylib(const Record &R, SymbolContext &SymCtx) {
+ // Missing declarations for exported symbols are warnings on ErrorsAndWarnings
+ // mode.
+ if (Mode == VerificationMode::ErrorsAndWarnings) {
+- Ctx.emitDiag(
+- [&]() {
+- Ctx.Diag->Report(diag::warn_header_symbol_missing)
+- << getAnnotatedName(&R, SymCtx, Loc.isValid());
+- },
+- &Loc);
++ Ctx.emitDiag([&]() {
++ Ctx.Diag->Report(diag::warn_header_symbol_missing)
++ << getAnnotatedName(&R, SymCtx, /*ValidSourceLoc=*/false);
++ });
+ updateState(Result::Ignore);
+ return;
+ }
+@@ -645,18 +622,6 @@ void DylibVerifier::visitObjCIVar(const ObjCIVarRecord &R,
+ visitSymbolInDylib(R, SymCtx);
+ }
+
+-void DylibVerifier::accumulateSrcLocForDylibSymbols() {
+- if (DSYMPath.empty())
+- return;
+-
+- assert(DWARFCtx != nullptr && "Expected an initialized DWARFContext");
+- if (DWARFCtx->ParsedDSYM)
+- return;
+- DWARFCtx->ParsedDSYM = true;
+- DWARFCtx->SourceLocs =
+- DylibReader::accumulateSourceLocFromDSYM(DSYMPath, Ctx.Target);
+-}
+-
+ void DylibVerifier::visitObjCInterface(const ObjCInterfaceRecord &R) {
+ if (R.isVerified())
+ return;
+@@ -690,8 +655,6 @@ DylibVerifier::Result DylibVerifier::verifyRemainingSymbols() {
+ return Result::NoVerify;
+ assert(!Dylib.empty() && "No binary to verify against");
+
+- DWARFContext DWARFInfo;
+- DWARFCtx = &DWARFInfo;
+ Ctx.DiscoveredFirstError = false;
+ Ctx.PrintArch = true;
+ for (std::shared_ptr<RecordsSlice> Slice : Dylib) {
+diff --git a/clang/test/InstallAPI/diagnostics-dsym.test b/clang/test/InstallAPI/diagnostics-dsym.test
+deleted file mode 100644
+index ee2c8b32df29..000000000000
+--- a/clang/test/InstallAPI/diagnostics-dsym.test
++++ /dev/null
+@@ -1,43 +0,0 @@
+-; REQUIRES: system-darwin
+-
+-; RUN: rm -rf %t
+-; RUN: split-file %s %t
+-
+-// Build a simple dylib with debug info.
+-; RUN: %clang --target=arm64-apple-macos13 -g -dynamiclib %t/foo.c \
+-; RUN: -current_version 1 -compatibility_version 1 -L%t/usr/lib \
+-; RUN: -save-temps \
+-; RUN: -o %t/foo.dylib -install_name %t/foo.dylib
+-; RUN: dsymutil %t/foo.dylib -o %t/foo.dSYM
+-
+-; RUN: not clang-installapi -x c++ --target=arm64-apple-macos13 \
+-; RUN: -install_name %t/foo.dylib \
+-; RUN: -current_version 1 -compatibility_version 1 \
+-; RUN: -o %t/output.tbd \
+-; RUN: --verify-against=%t/foo.dylib --dsym=%t/foo.dSYM \
+-; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s
+-
+-; CHECK: violations found for arm64
+-; CHECK: foo.c:5:0: error: no declaration found for exported symbol 'bar' in dynamic library
+-; CHECK: foo.c:1:0: error: no declaration found for exported symbol 'foo' in dynamic library
+-
+-;--- foo.c
+-int foo(void) {
+- return 1;
+-}
+-extern char bar;
+-char bar = 'a';
+-
+-;--- usr/lib/libSystem.tbd
+-{
+- "main_library": {
+- "install_names": [
+- {"name": "/usr/lib/libSystem.B.dylib"}
+- ],
+- "target_info": [
+- {"target": "arm64-macos"}
+- ]
+- },
+- "tapi_tbd_version": 5
+-}
+-
+diff --git a/clang/tools/clang-installapi/InstallAPIOpts.td b/clang/tools/clang-installapi/InstallAPIOpts.td
+index 010f2507a1d1..71532c9cf24d 100644
+--- a/clang/tools/clang-installapi/InstallAPIOpts.td
++++ b/clang/tools/clang-installapi/InstallAPIOpts.td
+@@ -29,8 +29,6 @@ def verify_mode_EQ : Joined<["--"], "verify-mode=">,
+ HelpText<"Specify the severity and extend of the validation. Valid modes are ErrorsOnly, ErrorsAndWarnings, and Pedantic.">;
+ def demangle : Flag<["--", "-"], "demangle">,
+ HelpText<"Demangle symbols when printing warnings and errors">;
+-def dsym: Joined<["--"], "dsym=">,
+- MetaVarName<"<path>">, HelpText<"Specify dSYM path for enriched diagnostics.">;
+
+ // Additional input options.
+ def extra_project_header : Separate<["-"], "extra-project-header">,
+diff --git a/clang/tools/clang-installapi/Options.cpp b/clang/tools/clang-installapi/Options.cpp
+index c4f39b7c8417..8e4a1b019fd8 100644
+--- a/clang/tools/clang-installapi/Options.cpp
++++ b/clang/tools/clang-installapi/Options.cpp
+@@ -241,9 +241,6 @@ Options::processAndFilterOutInstallAPIOptions(ArrayRef<const char *> Args) {
+ if (const Arg *A = ParsedArgs.getLastArg(OPT_verify_against))
+ DriverOpts.DylibToVerify = A->getValue();
+
+- if (const Arg *A = ParsedArgs.getLastArg(OPT_dsym))
+- DriverOpts.DSYMPath = A->getValue();
+-
+ // Handle exclude & extra header directories or files.
+ auto handleAdditionalInputArgs = [&](PathSeq &Headers,
+ clang::installapi::ID OptID) {
+@@ -525,8 +522,7 @@ InstallAPIContext Options::createContext() {
+ }
+
+ Ctx.Verifier = std::make_unique<DylibVerifier>(
+- std::move(*Slices), Diags, DriverOpts.VerifyMode, DriverOpts.Demangle,
+- DriverOpts.DSYMPath);
++ std::move(*Slices), Diags, DriverOpts.VerifyMode, DriverOpts.Demangle);
+ return Ctx;
+ }
+
+diff --git a/clang/tools/clang-installapi/Options.h b/clang/tools/clang-installapi/Options.h
+index 82e04b49d125..3671e4c8274b 100644
+--- a/clang/tools/clang-installapi/Options.h
++++ b/clang/tools/clang-installapi/Options.h
+@@ -67,9 +67,6 @@ struct DriverOptions {
+ /// \brief Output path.
+ std::string OutputPath;
+
+- /// \brief DSYM path.
+- std::string DSYMPath;
+-
+ /// \brief File encoding to print.
+ FileType OutFT = FileType::TBD_V5;
+
+diff --git a/llvm/include/llvm/TextAPI/DylibReader.h b/llvm/include/llvm/TextAPI/DylibReader.h
+index 6861d3cb1591..b556fbf6832a 100644
+--- a/llvm/include/llvm/TextAPI/DylibReader.h
++++ b/llvm/include/llvm/TextAPI/DylibReader.h
+@@ -13,7 +13,6 @@
+ #ifndef LLVM_TEXTAPI_DYLIBREADER_H
+ #define LLVM_TEXTAPI_DYLIBREADER_H
+
+-#include "llvm/ADT/StringMap.h"
+ #include "llvm/Support/Error.h"
+ #include "llvm/Support/MemoryBuffer.h"
+ #include "llvm/TextAPI/ArchitectureSet.h"
+@@ -44,14 +43,6 @@ Expected<Records> readFile(MemoryBufferRef Buffer, const ParseOption &Opt);
+ /// \param Buffer Data that points to dylib.
+ Expected<std::unique_ptr<InterfaceFile>> get(MemoryBufferRef Buffer);
+
+-using SymbolToSourceLocMap = llvm::StringMap<RecordLoc>;
+-/// Get the source location for each symbol from dylib.
+-///
+-/// \param DSYM Path to DSYM file.
+-/// \param T Requested target slice for dylib.
+-SymbolToSourceLocMap accumulateSourceLocFromDSYM(const StringRef DSYM,
+- const Target &T);
+-
+ } // namespace llvm::MachO::DylibReader
+
+ #endif // LLVM_TEXTAPI_DYLIBREADER_H
+diff --git a/llvm/include/llvm/TextAPI/Record.h b/llvm/include/llvm/TextAPI/Record.h
+index 7d721988ec3d..ef152ce43387 100644
+--- a/llvm/include/llvm/TextAPI/Record.h
++++ b/llvm/include/llvm/TextAPI/Record.h
+@@ -27,23 +27,6 @@ LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+
+ class RecordsSlice;
+
+-// Defines lightweight source location for records.
+-struct RecordLoc {
+- RecordLoc() = default;
+- RecordLoc(std::string File, unsigned Line)
+- : File(std::move(File)), Line(Line) {}
+-
+- /// Whether there is source location tied to the RecordLoc object.
+- bool isValid() const { return !File.empty(); }
+-
+- bool operator==(const RecordLoc &O) const {
+- return std::tie(File, Line) == std::tie(O.File, O.Line);
+- }
+-
+- const std::string File;
+- const unsigned Line = 0;
+-};
+-
+ // Defines a list of linkage types.
+ enum class RecordLinkage : uint8_t {
+ // Unknown linkage.
+diff --git a/llvm/lib/TextAPI/BinaryReader/CMakeLists.txt b/llvm/lib/TextAPI/BinaryReader/CMakeLists.txt
+index c4535310d91c..cbdf7b2c9696 100644
+--- a/llvm/lib/TextAPI/BinaryReader/CMakeLists.txt
++++ b/llvm/lib/TextAPI/BinaryReader/CMakeLists.txt
+@@ -2,7 +2,6 @@ add_llvm_component_library(LLVMTextAPIBinaryReader
+ DylibReader.cpp
+
+ LINK_COMPONENTS
+- DebugInfoDWARF
+ Support
+ Object
+ TextAPI
+diff --git a/llvm/lib/TextAPI/BinaryReader/DylibReader.cpp b/llvm/lib/TextAPI/BinaryReader/DylibReader.cpp
+index f92a2d19a63f..2e36d4a8b98c 100644
+--- a/llvm/lib/TextAPI/BinaryReader/DylibReader.cpp
++++ b/llvm/lib/TextAPI/BinaryReader/DylibReader.cpp
+@@ -12,8 +12,7 @@
+
+ #include "llvm/TextAPI/DylibReader.h"
+ #include "llvm/ADT/STLExtras.h"
+-#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
+-#include "llvm/DebugInfo/DWARF/DWARFContext.h"
++#include "llvm/ADT/StringMap.h"
+ #include "llvm/Object/Binary.h"
+ #include "llvm/Object/MachOUniversal.h"
+ #include "llvm/Support/Endian.h"
+@@ -433,111 +432,3 @@ DylibReader::get(MemoryBufferRef Buffer) {
+
+ return convertToInterfaceFile(*SlicesOrErr);
+ }
+-
+-static void DWARFErrorHandler(Error Err) { /**/ }
+-
+-static SymbolToSourceLocMap
+-accumulateLocs(MachOObjectFile &Obj,
+- const std::unique_ptr<DWARFContext> &DiCtx) {
+- SymbolToSourceLocMap LocMap;
+- for (const auto &Symbol : Obj.symbols()) {
+- Expected<uint32_t> FlagsOrErr = Symbol.getFlags();
+- if (!FlagsOrErr) {
+- consumeError(FlagsOrErr.takeError());
+- continue;
+- }
+-
+- if (!(*FlagsOrErr & SymbolRef::SF_Exported))
+- continue;
+-
+- Expected<uint64_t> AddressOrErr = Symbol.getAddress();
+- if (!AddressOrErr) {
+- consumeError(AddressOrErr.takeError());
+- continue;
+- }
+- const uint64_t Address = *AddressOrErr;
+-
+- auto TypeOrErr = Symbol.getType();
+- if (!TypeOrErr) {
+- consumeError(TypeOrErr.takeError());
+- continue;
+- }
+- const bool IsCode = (*TypeOrErr & SymbolRef::ST_Function);
+-
+- auto *DWARFCU = IsCode ? DiCtx->getCompileUnitForCodeAddress(Address)
+- : DiCtx->getCompileUnitForDataAddress(Address);
+- if (!DWARFCU)
+- continue;
+-
+- const DWARFDie &DIE = IsCode ? DWARFCU->getSubroutineForAddress(Address)
+- : DWARFCU->getVariableForAddress(Address);
+- const std::string File = DIE.getDeclFile(
+- llvm::DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
+- const uint64_t Line = DIE.getDeclLine();
+-
+- auto NameOrErr = Symbol.getName();
+- if (!NameOrErr) {
+- consumeError(NameOrErr.takeError());
+- continue;
+- }
+- auto Name = *NameOrErr;
+- auto Sym = parseSymbol(Name);
+-
+- if (!File.empty() && Line != 0)
+- LocMap.insert({Sym.Name.str(), RecordLoc(File, Line)});
+- }
+-
+- return LocMap;
+-}
+-
+-SymbolToSourceLocMap
+-DylibReader::accumulateSourceLocFromDSYM(const StringRef DSYM,
+- const Target &T) {
+- // Find sidecar file.
+- auto DSYMsOrErr = MachOObjectFile::findDsymObjectMembers(DSYM);
+- if (!DSYMsOrErr) {
+- consumeError(DSYMsOrErr.takeError());
+- return SymbolToSourceLocMap();
+- }
+- if (DSYMsOrErr->empty())
+- return SymbolToSourceLocMap();
+-
+- const StringRef Path = DSYMsOrErr->front();
+- auto BufOrErr = MemoryBuffer::getFile(Path);
+- if (auto Err = BufOrErr.getError())
+- return SymbolToSourceLocMap();
+-
+- auto BinOrErr = createBinary(*BufOrErr.get());
+- if (!BinOrErr) {
+- consumeError(BinOrErr.takeError());
+- return SymbolToSourceLocMap();
+- }
+- // Handle single arch.
+- if (auto *Single = dyn_cast<MachOObjectFile>(BinOrErr->get())) {
+- auto DiCtx = DWARFContext::create(
+- *Single, DWARFContext::ProcessDebugRelocations::Process, nullptr, "",
+- DWARFErrorHandler, DWARFErrorHandler);
+-
+- return accumulateLocs(*Single, DiCtx);
+- }
+- // Handle universal companion file.
+- if (auto *Fat = dyn_cast<MachOUniversalBinary>(BinOrErr->get())) {
+- auto ObjForArch = Fat->getObjectForArch(getArchitectureName(T.Arch));
+- if (!ObjForArch) {
+- consumeError(ObjForArch.takeError());
+- return SymbolToSourceLocMap();
+- }
+- auto MachOOrErr = ObjForArch->getAsObjectFile();
+- if (!MachOOrErr) {
+- consumeError(MachOOrErr.takeError());
+- return SymbolToSourceLocMap();
+- }
+- auto &Obj = **MachOOrErr;
+- auto DiCtx = DWARFContext::create(
+- Obj, DWARFContext::ProcessDebugRelocations::Process, nullptr, "",
+- DWARFErrorHandler, DWARFErrorHandler);
+-
+- return accumulateLocs(Obj, DiCtx);
+- }
+- return SymbolToSourceLocMap();
+-}
+--
+2.44.0.1.g9765aa7075
+
diff --git a/build/build-clang/revert-llvmorg-19-init-6898-g60deb8b39afe.patch b/build/build-clang/revert-llvmorg-19-init-6898-g60deb8b39afe.patch
new file mode 100644
index 0000000000..f6a566c199
--- /dev/null
+++ b/build/build-clang/revert-llvmorg-19-init-6898-g60deb8b39afe.patch
@@ -0,0 +1,66 @@
+From 3675bcd1e8d3026aa5f1c232986ce43c7cf72cd9 Mon Sep 17 00:00:00 2001
+From: Mike Hommey <mh@glandium.org>
+Date: Fri, 5 Apr 2024 05:59:19 +0900
+Subject: [PATCH 3/4] Revert "[InstallAPI][test] Tweak test to run on older CI
+ config"
+
+This reverts commit 60deb8b39afe9be90e30aa18d77ad129dacd4d55.
+---
+ clang/test/InstallAPI/diagnostics-dsym.test | 26 ++++++++++++---------
+ 1 file changed, 15 insertions(+), 11 deletions(-)
+
+diff --git a/clang/test/InstallAPI/diagnostics-dsym.test b/clang/test/InstallAPI/diagnostics-dsym.test
+index 45c69c09d286..ee2c8b32df29 100644
+--- a/clang/test/InstallAPI/diagnostics-dsym.test
++++ b/clang/test/InstallAPI/diagnostics-dsym.test
+@@ -4,20 +4,20 @@
+ ; RUN: split-file %s %t
+
+ // Build a simple dylib with debug info.
+-; RUN: %clang --target=x86_64-apple-macos10.15 -g -dynamiclib %t/foo.c \
++; RUN: %clang --target=arm64-apple-macos13 -g -dynamiclib %t/foo.c \
+ ; RUN: -current_version 1 -compatibility_version 1 -L%t/usr/lib \
+ ; RUN: -save-temps \
+ ; RUN: -o %t/foo.dylib -install_name %t/foo.dylib
+ ; RUN: dsymutil %t/foo.dylib -o %t/foo.dSYM
+
+-; RUN: not clang-installapi -x c++ --target=x86_64-apple-macos10.15 \
++; RUN: not clang-installapi -x c++ --target=arm64-apple-macos13 \
+ ; RUN: -install_name %t/foo.dylib \
+ ; RUN: -current_version 1 -compatibility_version 1 \
+ ; RUN: -o %t/output.tbd \
+ ; RUN: --verify-against=%t/foo.dylib --dsym=%t/foo.dSYM \
+ ; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s
+
+-; CHECK: violations found for x86_64
++; CHECK: violations found for arm64
+ ; CHECK: foo.c:5:0: error: no declaration found for exported symbol 'bar' in dynamic library
+ ; CHECK: foo.c:1:0: error: no declaration found for exported symbol 'foo' in dynamic library
+
+@@ -29,11 +29,15 @@ extern char bar;
+ char bar = 'a';
+
+ ;--- usr/lib/libSystem.tbd
+---- !tapi-tbd
+-tbd-version: 4
+-targets: [ x86_64-macos ]
+-install-name: '/usr/lib/libSystem.B.dylib'
+-exports:
+- - targets: [ x86_64-macos ]
+- symbols: [ dyld_stub_binder ]
+-...
++{
++ "main_library": {
++ "install_names": [
++ {"name": "/usr/lib/libSystem.B.dylib"}
++ ],
++ "target_info": [
++ {"target": "arm64-macos"}
++ ]
++ },
++ "tapi_tbd_version": 5
++}
++
+--
+2.44.0.1.g9765aa7075
+
diff --git a/build/build-clang/revert-llvmorg-19-init-6902-gbdb60e6f0c8e.patch b/build/build-clang/revert-llvmorg-19-init-6902-gbdb60e6f0c8e.patch
new file mode 100644
index 0000000000..28a27dc7cc
--- /dev/null
+++ b/build/build-clang/revert-llvmorg-19-init-6902-gbdb60e6f0c8e.patch
@@ -0,0 +1,24 @@
+From 79ff81df7b4593769ec40539e7a669e7d038efd1 Mon Sep 17 00:00:00 2001
+From: Mike Hommey <mh@glandium.org>
+Date: Fri, 5 Apr 2024 05:59:15 +0900
+Subject: [PATCH 2/4] Revert "[InstallAPI][test] Add requires x86_64 for
+ hardcoded target test"
+
+This reverts commit bdb60e6f0c8e89abf9bdf36411348db304ca65ba.
+---
+ clang/test/InstallAPI/diagnostics-dsym.test | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/clang/test/InstallAPI/diagnostics-dsym.test b/clang/test/InstallAPI/diagnostics-dsym.test
+index 8a1b394f2f86..45c69c09d286 100644
+--- a/clang/test/InstallAPI/diagnostics-dsym.test
++++ b/clang/test/InstallAPI/diagnostics-dsym.test
+@@ -1,4 +1,4 @@
+-; REQUIRES: 86_64-darwin
++; REQUIRES: system-darwin
+
+ ; RUN: rm -rf %t
+ ; RUN: split-file %s %t
+--
+2.44.0.1.g9765aa7075
+
diff --git a/build/build-clang/revert-llvmorg-19-init-7044-g30fd099d5062.patch b/build/build-clang/revert-llvmorg-19-init-7044-g30fd099d5062.patch
new file mode 100644
index 0000000000..eac26c075c
--- /dev/null
+++ b/build/build-clang/revert-llvmorg-19-init-7044-g30fd099d5062.patch
@@ -0,0 +1,58 @@
+From 30a876f2ca438ebbd1db53c5008759f565940d2b Mon Sep 17 00:00:00 2001
+From: Mike Hommey <mh@glandium.org>
+Date: Fri, 5 Apr 2024 05:59:08 +0900
+Subject: [PATCH 1/4] Revert "[InstallAPI] Fixup dsym test (#87299)"
+
+This reverts commit 30fd099d5062638b5fe6b89135ad6433a888023a.
+---
+ clang/test/InstallAPI/diagnostics-dsym.test | 13 ++++++-------
+ 1 file changed, 6 insertions(+), 7 deletions(-)
+
+diff --git a/clang/test/InstallAPI/diagnostics-dsym.test b/clang/test/InstallAPI/diagnostics-dsym.test
+index c9cbeffef7ba..8a1b394f2f86 100644
+--- a/clang/test/InstallAPI/diagnostics-dsym.test
++++ b/clang/test/InstallAPI/diagnostics-dsym.test
+@@ -1,24 +1,23 @@
+-; REQUIRES: system-darwin
+-; REQUIRES: target-aarch64
++; REQUIRES: 86_64-darwin
+
+ ; RUN: rm -rf %t
+ ; RUN: split-file %s %t
+
+ // Build a simple dylib with debug info.
+-; RUN: %clang --target=arm64-apple-macos11 -g -dynamiclib %t/foo.c \
++; RUN: %clang --target=x86_64-apple-macos10.15 -g -dynamiclib %t/foo.c \
+ ; RUN: -current_version 1 -compatibility_version 1 -L%t/usr/lib \
+ ; RUN: -save-temps \
+ ; RUN: -o %t/foo.dylib -install_name %t/foo.dylib
+ ; RUN: dsymutil %t/foo.dylib -o %t/foo.dSYM
+
+-; RUN: not clang-installapi -x c++ --target=arm64-apple-macos11 \
++; RUN: not clang-installapi -x c++ --target=x86_64-apple-macos10.15 \
+ ; RUN: -install_name %t/foo.dylib \
+ ; RUN: -current_version 1 -compatibility_version 1 \
+ ; RUN: -o %t/output.tbd \
+ ; RUN: --verify-against=%t/foo.dylib --dsym=%t/foo.dSYM \
+ ; RUN: --verify-mode=Pedantic 2>&1 | FileCheck %s
+
+-; CHECK: violations found for arm64
++; CHECK: violations found for x86_64
+ ; CHECK: foo.c:5:0: error: no declaration found for exported symbol 'bar' in dynamic library
+ ; CHECK: foo.c:1:0: error: no declaration found for exported symbol 'foo' in dynamic library
+
+@@ -32,9 +31,9 @@ char bar = 'a';
+ ;--- usr/lib/libSystem.tbd
+ --- !tapi-tbd
+ tbd-version: 4
+-targets: [ arm64-macos ]
++targets: [ x86_64-macos ]
+ install-name: '/usr/lib/libSystem.B.dylib'
+ exports:
+- - targets: [ arm64-macos ]
++ - targets: [ x86_64-macos ]
+ symbols: [ dyld_stub_binder ]
+ ...
+--
+2.44.0.1.g9765aa7075
+