[llvm] 135709a - [DebugInfo] Ensure dead store elimination can mark an operand
Chris Jackson via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 07:00:14 PDT 2020
Author: Chris Jackson
Date: 2020-03-30T14:58:14+01:00
New Revision: 135709aa9013565b9d02000bb0ca744f7585e6a5
URL: https://github.com/llvm/llvm-project/commit/135709aa9013565b9d02000bb0ca744f7585e6a5
DIFF: https://github.com/llvm/llvm-project/commit/135709aa9013565b9d02000bb0ca744f7585e6a5.diff
LOG: [DebugInfo] Ensure dead store elimination can mark an operand
value as undefined
- Correct a debug info salvage and add a test
Reviewers: aprantl, vsk
Differential Revision: https://reviews.llvm.org/D76930
Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=45080
Added:
llvm/test/DebugInfo/X86/dead-store-elimination-marks-undef.ll
Modified:
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index eb6fcae0a548..14f07b309b44 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -143,7 +143,7 @@ deleteDeadInstruction(Instruction *I, BasicBlock::iterator *BBI,
++NumFastOther;
// Try to preserve debug information attached to the dead instruction.
- salvageDebugInfo(*DeadInst);
+ salvageDebugInfoOrMarkUndef(*DeadInst);
// This instruction is dead, zap it, in stages. Start by removing it from
// MemDep, which needs to know the operands and needs it to be in the
diff --git a/llvm/test/DebugInfo/X86/dead-store-elimination-marks-undef.ll b/llvm/test/DebugInfo/X86/dead-store-elimination-marks-undef.ll
new file mode 100644
index 000000000000..5f9e67653d96
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/dead-store-elimination-marks-undef.ll
@@ -0,0 +1,36 @@
+; RUN: opt -mtriple=x86_64-- -S --dse %s -o - | FileCheck %s
+; Ensure that we can mark a value as undefined when performing dead
+; store elimination.
+; Bugzilla #45080
+
+ at b = common dso_local local_unnamed_addr global i32 0, align 1
+
+define dso_local i32 @main() local_unnamed_addr !dbg !7 {
+ %1 = alloca i32, align 4
+ %2 = load i32, i32* @b, align 1, !dbg !13
+ ; CHECK: call void @llvm.dbg.value(metadata i32 undef
+ call void @llvm.dbg.value(metadata i32 %2, metadata !12, metadata !DIExpression()), !dbg !13
+ store i32 %2, i32* %1, align 4, !dbg !13
+ ret i32 0, !dbg !13
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2, nameTableKind: None)
+!1 = !DIFile(filename: "dead-store-elimination-marks-undef.ll", directory: "/temp/bz45080")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!6 = !{!"clang version 10.0.0"}
+!7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
+!8 = !DISubroutineType(types: !9)
+!9 = !{!10}
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!11 = !{!12}
+!12 = !DILocalVariable(name: "l_2864", scope: !7, file: !1, line: 4, type: !10)
+!13 = !DILocation(line: 5, column: 12, scope: !7)
+
More information about the llvm-commits
mailing list