[PATCH] D38088: Fix out-of-order stepping behavior in programs with hoisted constants.

Matthew Voss via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 16:41:17 PDT 2017


ormris updated this revision to Diff 116114.
ormris added a comment.

Updating https://reviews.llvm.org/D38088: Fix out-of-order stepping behavior in programs with hoisted constants.

Change list:

- Remove unnecessary asserts
- Edit comment to ensure consistency with new behavior


https://reviews.llvm.org/D38088

Files:
  lib/Transforms/Scalar/ConstantHoisting.cpp
  test/Transforms/ConstantHoisting/X86/constanthoist-debuginfo.ll


Index: test/Transforms/ConstantHoisting/X86/constanthoist-debuginfo.ll
===================================================================
--- /dev/null
+++ test/Transforms/ConstantHoisting/X86/constanthoist-debuginfo.ll
@@ -0,0 +1,41 @@
+; RUN: opt -S -consthoist < %s | FileCheck %s
+; ModuleID = 'test-hoist-debug.cpp'
+source_filename = "test-hoist-debug.cpp"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: noinline nounwind optnone uwtable
+define i32 @_Z3foov() !dbg !7 {
+; CHECK: bitcast
+; CHECK-NOT: !dbg !11
+; CHECK: inttoptr 
+  %a0 = inttoptr i64 4646526064 to i32*
+  %v0 = load i32, i32* %a0, align 16
+
+  %a1 = inttoptr i64 4646526080 to i32*
+  %v1 = load i32, i32* %a1, align 16
+
+  %a2 = inttoptr i64 4646526096 to i32*
+  %v2 = load i32, i32* %a2, align 16, !dbg !11
+
+  %r0 = add i32 %v0, %v1
+  %r1 = add i32 %r0, %v2
+  ret i32 %r1
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 (trunk 313291)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "test-hoist-debug.cpp", directory: "/tmp")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 6.0.0 (trunk 313291)"}
+!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!8 = !DISubroutineType(types: !9)
+!9 = !{!10}
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!11 = !DILocation(line: 2, column: 3, scope: !7)
Index: lib/Transforms/Scalar/ConstantHoisting.cpp
===================================================================
--- lib/Transforms/Scalar/ConstantHoisting.cpp
+++ lib/Transforms/Scalar/ConstantHoisting.cpp
@@ -738,11 +738,9 @@
       }
       UsesNum = Uses;
 
-      // Use the same debug location as the last user of the constant.
-      assert(!Base->use_empty() && "The use list is empty!?");
-      assert(isa<Instruction>(Base->user_back()) &&
-             "All uses should be instructions.");
-      Base->setDebugLoc(cast<Instruction>(Base->user_back())->getDebugLoc());
+      // Erase debug location to ensure consistent stepping in profilers and
+      // debuggers.
+      Base->setDebugLoc(DebugLoc());
     }
     (void)UsesNum;
     (void)ReBasesNum;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38088.116114.patch
Type: text/x-patch
Size: 2629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170920/3c21bc03/attachment.bin>


More information about the llvm-commits mailing list