[llvm] 315e300 - [CodeGenPrepare][RISCV] Remove asserting VH references before erasing the dead GEP
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 18 08:41:22 PDT 2023
Author: Yingwei Zheng
Date: 2023-06-18T23:40:47+08:00
New Revision: 315e3001c0ebe1a76c0cb6109d29a3a5e22376de
URL: https://github.com/llvm/llvm-project/commit/315e3001c0ebe1a76c0cb6109d29a3a5e22376de
DIFF: https://github.com/llvm/llvm-project/commit/315e3001c0ebe1a76c0cb6109d29a3a5e22376de.diff
LOG: [CodeGenPrepare][RISCV] Remove asserting VH references before erasing the dead GEP
Fixes issue https://github.com/llvm/llvm-project/issues/63365
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D153194
Added:
llvm/test/CodeGen/RISCV/pr63365.ll
Modified:
llvm/lib/CodeGen/CodeGenPrepare.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 0e2793a8c3504..410bfc53d63ab 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -8180,7 +8180,9 @@ bool CodeGenPrepare::optimizeInst(Instruction *I, ModifyDT &ModifiedDT) {
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;
diff --git a/llvm/test/CodeGen/RISCV/pr63365.ll b/llvm/test/CodeGen/RISCV/pr63365.ll
new file mode 100644
index 0000000000000..3c7071a315b7a
--- /dev/null
+++ b/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
+}
More information about the llvm-commits
mailing list