[llvm] 2e00eba - [FuncSpec][NFC] Remove SSA copy intrinsics in the unittests.

Alexandros Lamprineas via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 00:40:57 PDT 2023


Author: Alexandros Lamprineas
Date: 2023-07-27T08:37:33+01:00
New Revision: 2e00eba232c1bde0c4bcb254b36bbf47ac0ebf7e

URL: https://github.com/llvm/llvm-project/commit/2e00eba232c1bde0c4bcb254b36bbf47ac0ebf7e
DIFF: https://github.com/llvm/llvm-project/commit/2e00eba232c1bde0c4bcb254b36bbf47ac0ebf7e.diff

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

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

Differential Revision: https://reviews.llvm.org/D156365

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp b/llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
index 222311dc040a86..81da6d8f6ed5c9 100644
--- a/llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
+++ b/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 @@ class FunctionSpecializationTest : public testing::Test {
       Solver->markOverdefined(&Arg);
     Solver->solveWhileResolvedUndefsIn(*M);
 
+    removeSSACopy(*F);
+
     return FunctionSpecializer(*Solver, *M, &FAM, GetBFI, GetTLI, GetTTI,
                                GetAC);
   }


        


More information about the llvm-commits mailing list