aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2024-07-27 23:34:35 +0000
committerDimitry Andric <dim@FreeBSD.org>2024-10-23 18:26:01 +0000
commit0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583 (patch)
tree6cf5ab1f05330c6773b1f3f64799d56a9c7a1faa /contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp
parent6b9f7133aba44189d9625c352bc2c2a59baf18ef (diff)
parentac9a064cb179f3425b310fa2847f8764ac970a4d (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp14
1 files changed, 13 insertions, 1 deletions
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();