[PATCH] D81879: [CGP] Reset the debug location when promoting trunc(s)

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 15 14:21:12 PDT 2020


davide updated this revision to Diff 270861.
davide added a comment.

Context + simplified testcase.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81879/new/

https://reviews.llvm.org/D81879

Files:
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/test/Transforms/CodeGenPrepare/X86/promoted-trunc-loc.ll


Index: llvm/test/Transforms/CodeGenPrepare/X86/promoted-trunc-loc.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/CodeGenPrepare/X86/promoted-trunc-loc.ll
@@ -0,0 +1,44 @@
+; RUN: opt < %s -codegenprepare -S -mtriple=x86_64-unknown-unknown | FileCheck %s
+
+; Make sure the promoted trunc doesn't get a debug location associated.
+; CHECK: %promoted = trunc i32 %or to i16
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.13.0"
+
+ at b = global i16 0, align 2
+
+declare void @bar(i64)
+
+define i32 @foo(i16 %kkk) !dbg !6 {
+entry:
+  %t4 = load i16, i16* @b, align 2, !dbg !8
+  %conv4 = zext i16 %t4 to i32, !dbg !9
+  %or = or i16 %kkk, %t4, !dbg !10
+  %c = sext i16 %or to i64, !dbg !11
+  call void @bar(i64 %c), !dbg !12
+  %t5 = and i16 %or, 5, !dbg !13
+  %z = zext i16 %t5 to i32, !dbg !14
+  ret i32 %z, !dbg !15
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!3, !4}
+!llvm.module.flags = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "/Users/davide/work/llvm-project/patatino.ll", directory: "/")
+!2 = !{}
+!3 = !{i32 8}
+!4 = !{i32 0}
+!5 = !{i32 2, !"Debug Info Version", i32 3}
+!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
+!7 = !DISubroutineType(types: !2)
+!8 = !DILocation(line: 1, column: 1, scope: !6)
+!9 = !DILocation(line: 2, column: 1, scope: !6)
+!10 = !DILocation(line: 3, column: 1, scope: !6)
+!11 = !DILocation(line: 4, column: 1, scope: !6)
+!12 = !DILocation(line: 5, column: 1, scope: !6)
+!13 = !DILocation(line: 6, column: 1, scope: !6)
+!14 = !DILocation(line: 7, column: 1, scope: !6)
+!15 = !DILocation(line: 8, column: 1, scope: !6)
Index: llvm/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -2605,6 +2605,7 @@
     /// trunc Opnd to Ty.
     TruncBuilder(Instruction *Opnd, Type *Ty) : TypePromotionAction(Opnd) {
       IRBuilder<> Builder(Opnd);
+      Builder.SetCurrentDebugLocation(DebugLoc());
       Val = Builder.CreateTrunc(Opnd, Ty, "promoted");
       LLVM_DEBUG(dbgs() << "Do: TruncBuilder: " << *Val << "\n");
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81879.270861.patch
Type: text/x-patch
Size: 2515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200615/0db5a91c/attachment-0001.bin>


More information about the llvm-commits mailing list