[PATCH] D156365: [FuncSpec][NFC] Remove SSA copy intrinsics in the unittests.

Alexandros Lamprineas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 13:48:14 PDT 2023


labrinea created this revision.
labrinea added a reviewer: ChuanqiXu.
Herald added a subscriber: ormris.
Herald added a project: All.
labrinea requested review of this revision.
Herald added a project: LLVM.

Those are added by the SCCP Solver before invoking the Specializer.
They need to be removed otherwise the destructor of PredicateInfo
complains.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156365

Files:
  llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp


Index: llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
===================================================================
--- llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
+++ llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
@@ -23,6 +23,19 @@
 
 namespace llvm {
 
+static void removeSSACopy(Function &F) {
+  for (BasicBlock &BB : F) {
+    for (Instruction &Inst : llvm::make_early_inc_range(BB)) {
+      if (auto *II = dyn_cast<IntrinsicInst>(&Inst)) {
+        if (II->getIntrinsicID() != Intrinsic::ssa_copy)
+          continue;
+        Inst.replaceAllUsesWith(II->getOperand(0));
+        Inst.eraseFromParent();
+      }
+    }
+  }
+}
+
 class FunctionSpecializationTest : public testing::Test {
 protected:
   LLVMContext Ctx;
@@ -77,6 +90,8 @@
       Solver->markOverdefined(&Arg);
     Solver->solveWhileResolvedUndefsIn(*M);
 
+    removeSSACopy(*F);
+
     return FunctionSpecializer(*Solver, *M, &FAM, GetBFI, GetTLI, GetTTI,
                                GetAC);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156365.544500.patch
Type: text/x-patch
Size: 1030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230726/9214ebd6/attachment.bin>


More information about the llvm-commits mailing list