[llvm] r279681 - [Hexagon] Check for block end when skipping debug instructions

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 15:36:35 PDT 2016


Author: kparzysz
Date: Wed Aug 24 17:36:35 2016
New Revision: 279681

URL: http://llvm.org/viewvc/llvm-project?rev=279681&view=rev
Log:
[Hexagon] Check for block end when skipping debug instructions

Added:
    llvm/trunk/test/CodeGen/Hexagon/copy-to-combine-dbg.ll
Modified:
    llvm/trunk/lib/Target/Hexagon/HexagonCopyToCombine.cpp

Modified: llvm/trunk/lib/Target/Hexagon/HexagonCopyToCombine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonCopyToCombine.cpp?rev=279681&r1=279680&r2=279681&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonCopyToCombine.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonCopyToCombine.cpp Wed Aug 24 17:36:35 2016
@@ -476,6 +476,7 @@ bool HexagonCopyToCombine::runOnMachineF
   // Traverse basic blocks.
   for (MachineFunction::iterator BI = MF.begin(), BE = MF.end(); BI != BE;
        ++BI) {
+dbgs() << "BB#" << BI->getNumber() << "\n";
     PotentiallyNewifiableTFR.clear();
     findPotentialNewifiableTFRs(*BI);
 
@@ -521,10 +522,8 @@ MachineInstr *HexagonCopyToCombine::find
                                                  bool &DoInsertAtI1,
                                                  bool AllowC64) {
   MachineBasicBlock::iterator I2 = std::next(MachineBasicBlock::iterator(I1));
-
-  if (I2 != I1.getParent()->end())
-    while (I2->isDebugValue())
-      ++I2;
+  while (I2 != I1.getParent()->end() && I2->isDebugValue())
+    ++I2;
 
   unsigned I1DestReg = I1.getOperand(0).getReg();
 

Added: llvm/trunk/test/CodeGen/Hexagon/copy-to-combine-dbg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/copy-to-combine-dbg.ll?rev=279681&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/copy-to-combine-dbg.ll (added)
+++ llvm/trunk/test/CodeGen/Hexagon/copy-to-combine-dbg.ll Wed Aug 24 17:36:35 2016
@@ -0,0 +1,57 @@
+; RUN: llc -march=hexagon < %s | FileCheck %s
+; Check for some sane output (original problem was a crash).
+; CHECK: DEBUG_VALUE: fred:Count <- 0
+
+target triple = "hexagon"
+
+define i32 @fred(i32 %p) local_unnamed_addr #0 !dbg !6 {
+entry:
+  br label %cond.end
+
+cond.end:                                         ; preds = %entry
+  br i1 undef, label %cond.false.i, label %for.body.lr.ph.i
+
+for.body.lr.ph.i:                                 ; preds = %cond.end
+  tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !10, metadata !12) #0, !dbg !13
+  br label %for.body.i
+
+cond.false.i:                                     ; preds = %cond.end
+  unreachable
+
+for.body.i:                                       ; preds = %for.inc.i, %for.body.lr.ph.i
+  %inc.sink37.i = phi i32 [ 0, %for.body.lr.ph.i ], [ %inc.i, %for.inc.i ]
+  %call.i = tail call i8* undef(i32 12, i8* undef) #0
+  br label %for.inc.i
+
+for.inc.i:                                        ; preds = %for.body.i
+  %inc.i = add nuw i32 %inc.sink37.i, 1
+  %cmp1.i = icmp ult i32 %inc.i, %p
+  br i1 %cmp1.i, label %for.body.i, label %PQ_AllocMem.exit.loopexit
+
+PQ_AllocMem.exit.loopexit:                        ; preds = %for.inc.i
+  unreachable
+}
+
+declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
+
+attributes #0 = { nounwind }
+attributes #1 = { nounwind readnone }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+!llvm.ident = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (http://llvm.org/git/clang.git 37afcb099ac2b001f4c826da7ca1d077b67a508c) (http://llvm.org/git/llvm.git 5887f1c75b3ba216850c834b186efdd3e54b7d4f)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
+!1 = !DIFile(filename: "file.c", directory: "/")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{!"clang version 4.0.0 (http://llvm.org/git/clang.git 37afcb099ac2b001f4c826da7ca1d077b67a508c) (http://llvm.org/git/llvm.git 5887f1c75b3ba216850c834b186efdd3e54b7d4f)"}
+!6 = distinct !DISubprogram(name: "fred", scope: !1, file: !1, line: 116, type: !7, isLocal: false, isDefinition: true, scopeLine: 121, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !9)
+!7 = !DISubroutineType(types: !2)
+!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!9 = !{!10}
+!10 = !DILocalVariable(name: "Count", scope: !6, file: !1, line: 1, type: !8)
+!11 = distinct !DILocation(line: 1, column: 1, scope: !6)
+!12 = !DIExpression()
+!13 = !DILocation(line: 1, column: 1, scope: !6, inlinedAt: !11)




More information about the llvm-commits mailing list