[llvm] r294317 - Revert "[GVNHoist] Merge DebugLoc metadata on hoisted instructions"

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 7 09:31:13 PST 2017


Author: rnk
Date: Tue Feb  7 11:31:13 2017
New Revision: 294317

URL: http://llvm.org/viewvc/llvm-project?rev=294317&view=rev
Log:
Revert "[GVNHoist] Merge DebugLoc metadata on hoisted instructions"

This reverts commit r294250. It caused PR31891.

Add a test case that shows that inlinable calls retain location
information with an accurate scope.

Added:
    llvm/trunk/test/Transforms/GVNHoist/hoist-pr31891.ll
Removed:
    llvm/trunk/test/Transforms/GVNHoist/hoist-debugloc.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp?rev=294317&r1=294316&r2=294317&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp Tue Feb  7 11:31:13 2017
@@ -24,7 +24,6 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/ValueTracking.h"
-#include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Transforms/Utils/MemorySSA.h"
@@ -715,9 +714,6 @@ private:
         OtherGep = cast<GetElementPtrInst>(
             cast<StoreInst>(OtherInst)->getPointerOperand());
       ClonedGep->andIRFlags(OtherGep);
-      ClonedGep->setDebugLoc(
-          DILocation::getMergedLocation(
-            ClonedGep->getDebugLoc(), OtherGep->getDebugLoc()));
     }
 
     // Replace uses of Gep with ClonedGep in Repl.
@@ -866,9 +862,6 @@ private:
           }
 
           Repl->andIRFlags(I);
-          Repl->setDebugLoc(
-              DILocation::getMergedLocation(
-                Repl->getDebugLoc(), I->getDebugLoc()));
           combineKnownMetadata(Repl, I);
           I->replaceAllUsesWith(Repl);
           // Also invalidate the Alias Analysis cache.

Removed: llvm/trunk/test/Transforms/GVNHoist/hoist-debugloc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVNHoist/hoist-debugloc.ll?rev=294316&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/GVNHoist/hoist-debugloc.ll (original)
+++ llvm/trunk/test/Transforms/GVNHoist/hoist-debugloc.ll (removed)
@@ -1,69 +0,0 @@
-; RUN: opt < %s -gvn-hoist -S | FileCheck %s
-; CHECK: [[VREG:%[^ ]+]] = getelementptr{{.*}}@s1
-; CHECK-NOT: !dbg
-; CHECK-SAME: {{$}}
-; CHECK-NEXT: load{{.*}}[[VREG]]
-; CHECK-NOT: !dbg
-; CHECK-SAME: {{$}}
-
-target triple = "x86_64-unknown-linux-gnu"
-
-%struct.S1 = type { [10 x i32] }
-
- at s1 = external local_unnamed_addr global [10 x %struct.S1*], align 16
-
-define void @foo(i32 %x, i32 %y, i32 %i) !dbg !4 {
-entry:
-  %tobool = icmp ne i32 %y, 0, !dbg !8
-  br i1 %tobool, label %if.then, label %if.else, !dbg !10
-
-if.then:                                          ; preds = %entry
-  %add = add nsw i32 %x, %y, !dbg !11
-  %idxprom = sext i32 %i to i64, !dbg !12
-  %arrayidx = getelementptr inbounds [10 x %struct.S1*], [10 x %struct.S1*]* @s1, i64 0, i64 %idxprom, !dbg !12
-  %0 = load %struct.S1*, %struct.S1** %arrayidx, align 8, !dbg !12, !tbaa !13
-  %a = getelementptr inbounds %struct.S1, %struct.S1* %0, i32 0, i32 0, !dbg !17
-  br label %if.end, !dbg !12
-
-if.else:                                          ; preds = %entry
-  %idxprom3 = sext i32 %i to i64, !dbg !18
-  %arrayidx4 = getelementptr inbounds [10 x %struct.S1*], [10 x %struct.S1*]* @s1, i64 0, i64 %idxprom3, !dbg !18
-  %1 = load %struct.S1*, %struct.S1** %arrayidx4, align 8, !dbg !18, !tbaa !13
-  %a5 = getelementptr inbounds %struct.S1, %struct.S1* %1, i32 0, i32 0, !dbg !19
-  br label %if.end
-
-if.end:                                           ; preds = %if.else, %if.then
-  %a5.sink = phi [10 x i32]* [ %a5, %if.else ], [ %a, %if.then ]
-  %.sink = phi i32 [ %x, %if.else ], [ %add, %if.then ]
-  %idxprom6 = sext i32 %i to i64
-  %arrayidx7 = getelementptr inbounds [10 x i32], [10 x i32]* %a5.sink, i64 0, i64 %idxprom6
-  store i32 %.sink, i32* %arrayidx7, align 4, !tbaa !20
-  ret void, !dbg !22
-}
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!2, !3}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
-!1 = !DIFile(filename: "foo.c", directory: "b/")
-!2 = !{i32 2, !"Dwarf Version", i32 4}
-!3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 7, type: !5, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
-!5 = !DISubroutineType(types: !6)
-!6 = !{null, !7, !7, !7}
-!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!8 = !DILocation(line: 8, column: 7, scope: !9)
-!9 = distinct !DILexicalBlock(scope: !4, file: !1, line: 8, column: 7)
-!10 = !DILocation(line: 8, column: 7, scope: !4)
-!11 = !DILocation(line: 9, column: 18, scope: !9)
-!12 = !DILocation(line: 9, column: 5, scope: !9)
-!13 = !{!14, !14, i64 0}
-!14 = !{!"any pointer", !15, i64 0}
-!15 = !{!"omnipotent char", !16, i64 0}
-!16 = !{!"Simple C/C++ TBAA"}
-!17 = !DILocation(line: 9, column: 9, scope: !9)
-!18 = !DILocation(line: 11, column: 5, scope: !9)
-!19 = !DILocation(line: 11, column: 9, scope: !9)
-!20 = !{!21, !21, i64 0}
-!21 = !{!"int", !15, i64 0}
-!22 = !DILocation(line: 12, column: 1, scope: !4)

Added: llvm/trunk/test/Transforms/GVNHoist/hoist-pr31891.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVNHoist/hoist-pr31891.ll?rev=294317&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/GVNHoist/hoist-pr31891.ll (added)
+++ llvm/trunk/test/Transforms/GVNHoist/hoist-pr31891.ll Tue Feb  7 11:31:13 2017
@@ -0,0 +1,82 @@
+; RUN: opt -S -gvn-hoist < %s | FileCheck %s
+
+; Hoisted inlinable calls need to have accurate scope information, but we're
+; allowed to erase the line information.
+
+source_filename = "t.c"
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.0.24215"
+
+; Function Attrs: noinline nounwind readnone uwtable
+define float @fabsf(float %f) #0 !dbg !7 {
+entry:
+  %conv = fpext float %f to double, !dbg !9
+  %call = call double @fabs(double %conv) #1, !dbg !10
+  %conv1 = fptrunc double %call to float, !dbg !11
+  ret float %conv1, !dbg !12
+}
+
+; Function Attrs: nounwind readnone
+declare double @fabs(double) #1
+
+; Function Attrs: noinline nounwind uwtable
+define void @hoistit(i32 %cond, float %f) #2 !dbg !13 {
+entry:
+  %tobool = icmp ne i32 %cond, 0, !dbg !14
+  br i1 %tobool, label %if.then, label %if.else, !dbg !14
+
+if.then:                                          ; preds = %entry
+  %call = call float @fabsf(float %f) #1, !dbg !15
+  call void @useit1(float %call), !dbg !16
+  br label %if.end, !dbg !18
+
+if.else:                                          ; preds = %entry
+  %call1 = call float @fabsf(float %f) #1, !dbg !19
+  call void @useit2(float %call1), !dbg !20
+  br label %if.end
+
+if.end:                                           ; preds = %if.else, %if.then
+  ret void, !dbg !21
+}
+
+; CHECK-LABEL: define void @hoistit({{.*}}) {{.*}} !dbg ![[sp_hoistit:[0-9]+]]
+; CHECK: call float @fabsf(float %f) {{.*}} !dbg ![[dbgloc:[0-9]+]]
+; CHECK: br i1 %tobool, label %if.then, label %if.else
+
+; CHECK: ![[sp_hoistit]] = !DISubprogram(name: "hoistit", {{.*}})
+; CHECK: ![[dbgloc]] = !DILocation({{.*}}, scope: !13)
+
+declare void @useit1(float)
+
+declare void @useit2(float)
+
+attributes #0 = { noinline nounwind readnone uwtable }
+attributes #1 = { nounwind readnone }
+attributes #2 = { noinline nounwind uwtable }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
+!1 = !DIFile(filename: "t.c", directory: "C:\5Csrc\5Cllvm\5Cbuild")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"PIC Level", i32 2}
+!6 = !{!"clang version 5.0.0 "}
+!7 = distinct !DISubprogram(name: "fabsf", scope: !1, file: !1, line: 4, type: !8, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!8 = !DISubroutineType(types: !2)
+!9 = !DILocation(line: 5, column: 22, scope: !7)
+!10 = !DILocation(line: 5, column: 17, scope: !7)
+!11 = !DILocation(line: 5, column: 10, scope: !7)
+!12 = !DILocation(line: 5, column: 3, scope: !7)
+!13 = distinct !DISubprogram(name: "hoistit", scope: !1, file: !1, line: 7, type: !8, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!14 = !DILocation(line: 8, column: 7, scope: !13)
+!15 = !DILocation(line: 9, column: 12, scope: !13)
+!16 = !DILocation(line: 9, column: 5, scope: !17)
+!17 = !DILexicalBlockFile(scope: !13, file: !1, discriminator: 1)
+!18 = !DILocation(line: 10, column: 3, scope: !13)
+!19 = !DILocation(line: 11, column: 12, scope: !13)
+!20 = !DILocation(line: 11, column: 5, scope: !17)
+!21 = !DILocation(line: 13, column: 1, scope: !13)




More information about the llvm-commits mailing list