[PATCH] D159121: [CodeGen] Properly update insertion point of the builder

Danila Malyutin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 29 10:52:47 PDT 2023


danilaml created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
danilaml requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Other code assumes that it can use passed Builder parameter to
generate new instructions but this code path created its own IRBuilder
instance, leaving the passed builder with an old insertion point.

Fixes https://github.com/llvm/llvm-project/issues/65044


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159121

Files:
  llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
  llvm/test/CodeGen/AArch64/complex-deinterleaving-crash.ll


Index: llvm/test/CodeGen/AArch64/complex-deinterleaving-crash.ll
===================================================================
--- llvm/test/CodeGen/AArch64/complex-deinterleaving-crash.ll
+++ llvm/test/CodeGen/AArch64/complex-deinterleaving-crash.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
 ; XFAIL: *
 ; RUN: llc %s --mattr=+complxnum -o - | FileCheck %s
 
@@ -6,6 +7,10 @@
 
 ; Check that deinterleaving pass doesn't generate broken IR
 define void @check_deinterleave_crash() #0 {
+; CHECK-LABEL: check_deinterleave_crash:
+; CHECK:       // %bb.0: // %bb
+; CHECK-NEXT:    mov x8, xzr
+; CHECK-NEXT:    str wzr, [x8]
 bb:
   br label %bb173
 
Index: llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
===================================================================
--- llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
+++ llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
@@ -1952,6 +1952,8 @@
       ReplacementNode =
           IRB.CreateIntrinsic(Intrinsic::experimental_vector_interleave2, NewTy,
                               {Node->Real, Node->Imag});
+      if (Builder.GetInsertPoint()->comesBefore(InsertPoint))
+        Builder.SetInsertPoint(InsertPoint);
     } else {
       ReplacementNode =
           Builder.CreateIntrinsic(Intrinsic::experimental_vector_interleave2,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159121.554425.patch
Type: text/x-patch
Size: 1369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230829/17c56c4c/attachment.bin>


More information about the llvm-commits mailing list