[PATCH] D115808: [DAGCombiner] Avoid combining adjacent stores at -O0 to improve debug experience
Shivam Gupta via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 17 15:14:02 PST 2021
xgupta updated this revision to Diff 395230.
xgupta added a comment.
.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115808/new/
https://reviews.llvm.org/D115808
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/RISCV/dbg-combine.ll
Index: llvm/test/CodeGen/RISCV/dbg-combine.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/dbg-combine.ll
@@ -0,0 +1,45 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s | FileCheck %s
+
+; Make sure that the sequence of store instructions for function foo is correctly
+; generated. More specifically, `sw a0, -20(s0)` instruction sequences must appear in
+; the output assembly.
+
+; cat dbg-combine.c
+; 1 int main ()
+; 2 {
+; 3 int size;
+; 4
+; 5 size = (int) sizeof (long long);
+; 6 size = (int) sizeof (void*);
+; 7 size = (int) sizeof (void (*)(void));
+; 8
+; 9 return 0;
+; 10 }
+
+define dso_local signext i32 @foo() #0 {
+; CHECK-LABEL: foo:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: addi sp, sp, -32
+; CHECK-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
+; CHECK-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
+; CHECK-NEXT: addi s0, sp, 32
+; CHECK-NEXT: li a0, 8
+; CHECK-NEXT: sw a0, -20(s0)
+; CHECK-NEXT: sw a0, -20(s0)
+; CHECK-NEXT: sw a0, -20(s0)
+; CHECK-NEXT: li a0, 0
+; CHECK-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
+; CHECK-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
+; CHECK-NEXT: addi sp, sp, 32
+; CHECK-NEXT: ret
+entry:
+ %size = alloca i32, align 4
+ store i32 8, i32* %size, align 4
+ store i32 8, i32* %size, align 4
+ store i32 8, i32* %size, align 4
+ ret i32 0
+}
+
+attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" }
+
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -18280,8 +18280,8 @@
if (StoreSDNode *ST1 = dyn_cast<StoreSDNode>(Chain)) {
if (ST->isUnindexed() && ST->isSimple() &&
ST1->isUnindexed() && ST1->isSimple()) {
- if (ST1->getBasePtr() == Ptr && ST1->getValue() == Value &&
- ST->getMemoryVT() == ST1->getMemoryVT() &&
+ if (OptLevel != CodeGenOpt::None && ST1->getBasePtr() == Ptr &&
+ ST1->getValue() == Value && ST->getMemoryVT() == ST1->getMemoryVT() &&
ST->getAddressSpace() == ST1->getAddressSpace()) {
// If this is a store followed by a store with the same value to the
// same location, then the store is dead/noop.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115808.395230.patch
Type: text/x-patch
Size: 2602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211217/14bb837d/attachment.bin>
More information about the llvm-commits
mailing list