[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
Sat Jun 17 03:47:32 PDT 2023
dtcxzyw created this revision.
dtcxzyw added reviewers: craig.topper, chfast.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
dtcxzyw requested review of this revision.
Herald added subscribers: llvm-commits, wangpc, eopXD, MaskRay.
Herald added a project: LLVM.
Fixes issue https://github.com/llvm/llvm-project/issues/63365
Repository:
rG LLVM Github Monorepo
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.532379.patch
Type: text/x-patch
Size: 1537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230617/6ed9f884/attachment.bin>
More information about the llvm-commits
mailing list