From fbc266465ed3585efdbd8e9ebf71e97ce7e8b464 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 28 Jul 2024 01:34:35 +0200 Subject: Merge llvm-project main llvmorg-19-init-18630-gf2ccf80136a0 This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvm-project main llvmorg-19-init-18630-gf2ccf80136a0, the last commit before the upstream release/19.x branch was created. PR: 280562 MFC after: 1 month (cherry picked from commit 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583) --- .../llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp') diff --git a/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp b/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp index 0830b02370cd..309938accdf4 100644 --- a/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp +++ b/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp @@ -87,7 +87,8 @@ public: static char ID; PPCMergeStringPool() : ModulePass(ID) {} - bool runOnModule(Module &M) override { return mergeModuleStringPool(M); } + bool doInitialization(Module &M) override { return mergeModuleStringPool(M); } + bool runOnModule(Module &M) override { return false; } StringRef getPassName() const override { return "PPC Merge String Pool"; } @@ -280,6 +281,17 @@ bool PPCMergeStringPool::mergeModuleStringPool(Module &M) { // before every use in order to compute this offset. replaceUsesWithGEP(GV, PooledGlobal, ElementIndex); + // Replace all the uses by metadata. + if (GV->isUsedByMetadata()) { + Constant *Indices[2] = { + ConstantInt::get(Type::getInt32Ty(*Context), 0), + ConstantInt::get(Type::getInt32Ty(*Context), ElementIndex)}; + Constant *ConstGEP = ConstantExpr::getInBoundsGetElementPtr( + PooledStructType, PooledGlobal, Indices); + ValueAsMetadata::handleRAUW(GV, ConstGEP); + } + assert(!GV->isUsedByMetadata() && "Should be no metadata use anymore"); + // This GV has no more uses so we can erase it. if (GV->use_empty()) GV->eraseFromParent(); -- cgit v1.2.3