[llvm] [PPCMergeStringPool] Avoid replacing constant with instruction (PR #88846)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 22:13:12 PDT 2024


================
@@ -117,9 +118,16 @@ class PPCMergeStringPool : public ModulePass {
 // sure that they can be replaced.
 static bool hasReplaceableUsers(GlobalVariable &GV) {
   for (User *CurrentUser : GV.users()) {
-    // Instruction users are always valid.
-    if (isa<Instruction>(CurrentUser))
+    if (isa<Instruction>(CurrentUser)) {
+      if (auto *II = dyn_cast<IntrinsicInst>(CurrentUser)) {
+        // Some intrinsics require a plain global.
+        if (II->getIntrinsicID() == Intrinsic::eh_typeid_for)
+          return false;
+      }
+
----------------
nikic wrote:

Hm, maybe adding this check is a better fix. I assume it will also cover the eh.typeid.for issue if this intrinsic is only used if the global is *also* mentioned in a landingpad.

https://github.com/llvm/llvm-project/pull/88846


More information about the llvm-commits mailing list