[InstCombine] Create store using IRBuilder
authorNikita Popov <npopov@redhat.com>
Wed, 17 May 2023 13:19:35 +0000 (15:19 +0200)
committerNikita Popov <npopov@redhat.com>
Wed, 17 May 2023 13:20:21 +0000 (15:20 +0200)
This ensures it gets reprocessed in the same iteration. In
particular the alignment will be increased (which is quite
pointless, of course).

llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/test/Transforms/InstCombine/getelementptr.ll

index a069a0b..e30e8d0 100644 (file)
@@ -1100,9 +1100,8 @@ Instruction *InstCombinerImpl::visitLoadInst(LoadInst &LI) {
     // that this code is not reachable.  We do this instead of inserting
     // an unreachable instruction directly because we cannot modify the
     // CFG.
-    StoreInst *SI = new StoreInst(PoisonValue::get(LI.getType()),
-                                  Constant::getNullValue(Op->getType()), &LI);
-    SI->setDebugLoc(LI.getDebugLoc());
+    Builder.CreateStore(PoisonValue::get(LI.getType()),
+                        Constant::getNullValue(Op->getType()));
     return replaceInstUsesWith(LI, PoisonValue::get(LI.getType()));
   }
 
index 15716b6..5a3343e 100644 (file)
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+; RUN: opt < %s -passes=instcombine -instcombine-infinite-loop-threshold=2 -S | FileCheck %s
 
 target datalayout = "e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64"