[PATCH] D153194: [CodeGenPrepare][RISCV] Remove asserting VH references before erasing the dead GEP

Yingwei Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 18 08:41:32 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG315e3001c0eb: [CodeGenPrepare][RISCV] Remove asserting VH references before erasing the dead… (authored by dtcxzyw).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153194/new/

https://reviews.llvm.org/D153194

Files:
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/test/CodeGen/RISCV/pr63365.ll


Index: llvm/test/CodeGen/RISCV/pr63365.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/pr63365.ll
@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=riscv32 | FileCheck %s
+
+ at G = external global i32
+ at G.1 = external global i32
+ at G.2 = external global i64
+ at G.3 = external global i1
+ at G.4 = external global i1
+ at G.5 = external global i8
+
+define void @f() {
+; CHECK-LABEL: f:
+; CHECK:       # %bb.0: # %BB
+; CHECK-NEXT:    addi sp, sp, -16
+; CHECK-NEXT:    .cfi_def_cfa_offset 16
+; CHECK-NEXT:    addi sp, sp, 16
+; CHECK-NEXT:    ret
+BB:
+  %A1 = alloca ptr, align 8
+  %G4 = getelementptr i1, ptr %A1, i32 65536
+  %G = getelementptr i1, ptr %A1, i64 4294967296
+  %L2 = load i8, ptr %G4, align 1
+  store i8 poison, ptr %G, align 1
+  ret void
+}
Index: llvm/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -8180,7 +8180,9 @@
                                         GEPI->getName(), GEPI);
       NC->setDebugLoc(GEPI->getDebugLoc());
       replaceAllUsesWith(GEPI, NC, FreshBBs, IsHugeFunc);
-      GEPI->eraseFromParent();
+      RecursivelyDeleteTriviallyDeadInstructions(
+          GEPI, TLInfo, nullptr,
+          [&](Value *V) { removeAllAssertingVHReferences(V); });
       ++NumGEPsElim;
       optimizeInst(NC, ModifiedDT);
       return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153194.532476.patch
Type: text/x-patch
Size: 1537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230618/6cea70f1/attachment.bin>


More information about the llvm-commits mailing list