[llvm] ac6e177 - [Assignment Tracking] Remove overly defensive AllocaInst assertion
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 26 03:25:16 PDT 2023
Author: OCHyams
Date: 2023-04-26T11:24:31+01:00
New Revision: ac6e177ce60efdd688e0823389cd167f931437bd
URL: https://github.com/llvm/llvm-project/commit/ac6e177ce60efdd688e0823389cd167f931437bd
DIFF: https://github.com/llvm/llvm-project/commit/ac6e177ce60efdd688e0823389cd167f931437bd.diff
LOG: [Assignment Tracking] Remove overly defensive AllocaInst assertion
Remove assert from AssignmentTrackingAnalysis that fires if a local variable
has non-alloca storage. The analysis can emit these locations but the
assignment tracking code in SelectionDAG isn't ready to handle non-alloca
storage for locals yet. The AssignmentTrackingPass (pass that adds assignment
tracking metadata) ignores non-alloca dbg.declares, so the only variables
affected are those who's backing storage is changed from an alloca during
optimisation, and the result is the variables are dropped.
Fixes: https://ci.chromium.org/ui/p/pigweed/builders/toolchain/
toolchain-ci-pigweed-linux/b8783274592206481489/overview
Reviewed By: StephenTozer
Differential Revision: https://reviews.llvm.org/D149135
Added:
llvm/test/DebugInfo/assignment-tracking/X86/global-storage.ll
Modified:
llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
index d5e133d88c604..5ef850d09d925 100644
--- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -2194,8 +2194,7 @@ bool AssignmentTrackingLowering::run(FunctionVarLocsBuilder *FnVarLocsBuilder) {
//
// Unless we've already done so, create the single location def now.
if (AlwaysStackHomed.insert(Aggr).second) {
- assert(!VarLoc.Values.hasArgList() &&
- isa<AllocaInst>(VarLoc.Values.getVariableLocationOp(0)));
+ assert(!VarLoc.Values.hasArgList());
// TODO: When more complex cases are handled VarLoc.Expr should be
// built appropriately rather than always using an empty DIExpression.
// The assert below is a reminder.
diff --git a/llvm/test/DebugInfo/assignment-tracking/X86/global-storage.ll b/llvm/test/DebugInfo/assignment-tracking/X86/global-storage.ll
new file mode 100644
index 0000000000000..7d265acdb5bb4
--- /dev/null
+++ b/llvm/test/DebugInfo/assignment-tracking/X86/global-storage.ll
@@ -0,0 +1,45 @@
+; RUN: llc %s -stop-after=finalize-isel -o - | FileCheck %s
+
+;; Local variable has global storage. Check AssignmentTrackingAnalysis doesn't
+;; crash/assert.
+
+;; FIXME: We ideally want a DBG_VALUE deref here. It's not possible with the
+;; current setup, but will be possible when assignment tracking is extended to
+;; understand non-alloca storage.
+
+; CHECK: stack: []
+; CHECK-NOT: DBG_
+
+target triple = "x86_64-unknown-linux-gnu"
+
+ at a = dso_local global i32 0, align 4
+
+define dso_local void @_Z3funi(i32 noundef %x) !dbg !15 {
+entry:
+ store i32 %x, ptr @a, align 4, !DIAssignID !27
+ call void @llvm.dbg.assign(metadata i32 %x, metadata !23, metadata !DIExpression(), metadata !27, metadata ptr @a, metadata !DIExpression()), !dbg !21
+ ret void
+}
+
+declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!6, !7, !13}
+!llvm.ident = !{!14}
+
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 17.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "test.cpp", directory: "/")
+!4 = !{}
+!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!6 = !{i32 7, !"Dwarf Version", i32 5}
+!7 = !{i32 2, !"Debug Info Version", i32 3}
+!13 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
+!14 = !{!"clang version 17.0.0"}
+!15 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funi", scope: !3, file: !3, line: 2, type: !16, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !18)
+!16 = !DISubroutineType(types: !17)
+!17 = !{null, !5}
+!18 = !{}
+!20 = !DILocalVariable(name: "x", arg: 1, scope: !15, file: !3, line: 2, type: !5)
+!21 = !DILocation(line: 0, scope: !15)
+!23 = !DILocalVariable(name: "a", scope: !15, file: !3, line: 3, type: !5)
+!27 = distinct !DIAssignID()
More information about the llvm-commits
mailing list