[llvm] r369256 - [DebugInfo] Allow bundled calls in the MIR's call site info

David Stenberg via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 05:41:22 PDT 2019


Author: dstenb
Date: Mon Aug 19 05:41:22 2019
New Revision: 369256

URL: http://llvm.org/viewvc/llvm-project?rev=369256&view=rev
Log:
[DebugInfo] Allow bundled calls in the MIR's call site info

Summary:
Extend the MIR parser and writer so that the call site information can
refer to calls that are bundled.

Reviewers: aprantl, asowda, NikolaPrica, djtodoro, ivanbaev, vsk

Reviewed By: aprantl

Subscribers: arsenm, hiraditya, llvm-commits

Tags: #debug-info, #llvm

Differential Revision: https://reviews.llvm.org/D66145

Added:
    llvm/trunk/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
    llvm/trunk/lib/CodeGen/MIRPrinter.cpp

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp?rev=369256&r1=369255&r2=369256&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp Mon Aug 19 05:41:22 2019
@@ -357,8 +357,8 @@ bool MIRParserImpl::initializeCallSiteIn
                    Twine(" call instruction offset out of range.") +
                    "Unable to reference instruction at bb: " +
                    Twine(MILoc.BlockNum) + " at offset:" + Twine(MILoc.Offset));
-    auto CallI = std::next(CallB->begin(), MILoc.Offset);
-    if (!CallI->isCall())
+    auto CallI = std::next(CallB->instr_begin(), MILoc.Offset);
+    if (!CallI->isCall(MachineInstr::IgnoreBundle))
       return error(Twine(MF.getName()) +
                    Twine(" call site info should reference call "
                          "instruction. Instruction at bb:") +

Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=369256&r1=369255&r2=369256&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Mon Aug 19 05:41:22 2019
@@ -473,10 +473,11 @@ void MIRPrinter::convertCallSiteObjects(
     yaml::CallSiteInfo::MachineInstrLoc CallLocation;
 
     // Prepare instruction position.
-    MachineBasicBlock::const_iterator CallI = CSInfo.first->getIterator();
+    MachineBasicBlock::const_instr_iterator CallI = CSInfo.first->getIterator();
     CallLocation.BlockNum = CallI->getParent()->getNumber();
     // Get call instruction offset from the beginning of block.
-    CallLocation.Offset = std::distance(CallI->getParent()->begin(), CallI);
+    CallLocation.Offset =
+        std::distance(CallI->getParent()->instr_begin(), CallI);
     YmlCS.CallLocation = CallLocation;
     // Construct call arguments and theirs forwarding register info.
     for (auto ArgReg : CSInfo.second) {

Added: llvm/trunk/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir?rev=369256&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir Mon Aug 19 05:41:22 2019
@@ -0,0 +1,47 @@
+# RUN: llc -debug-entry-values -run-pass=none -verify-machineinstrs -o - %s | FileCheck %s
+
+# Verify that it is possible to read and write MIR where a callSites entry
+# points to a call residing in a bundle. The offset should point to the call
+# instruction, rather than the bundle head.
+
+# CHECK: name: caller
+# CHECK: callSites:
+# CHECK-NEXT: bb: 0, offset: 3, fwdArgRegs:
+# CHECK-NEXT:   arg: 0, reg: '$r0'
+
+# XXX: Please note that at the time of creating this test the Hexagon target
+# did not support call site information, so the "callSites" array has been
+# manually added.
+
+--- |
+  target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
+  target triple = "hexagon"
+
+  define i32 @caller() {
+  entry:
+    tail call void @callee(i32 12345)
+    ret i32 0
+  }
+
+  declare void @callee(i32)
+
+...
+---
+name:            caller
+tracksRegLiveness: true
+callSites:
+  - { bb: 0, offset: 3, fwdArgRegs:
+      - { arg: 0, reg: '$r0' } }
+body:             |
+  bb.0.entry:
+    BUNDLE implicit-def $r29, implicit-def $r30, implicit-def dead $r0, implicit-def dead $pc, implicit-def dead $r31, implicit $r29, implicit killed $framekey, implicit killed $framelimit, implicit killed $r30, implicit killed $r31 {
+      $r29 = S2_allocframe $r29, 0, implicit-def $r30, implicit killed $framekey, implicit killed $framelimit, implicit killed $r30, implicit killed $r31 :: (store 4 into stack)
+      $r0 = A2_tfrsi 12345
+      J2_call @callee, hexagoncsr, implicit-def dead $pc, implicit-def dead $r31, implicit internal killed $r29, implicit internal killed $r0, implicit-def $r29
+    }
+    BUNDLE implicit-def dead $r0, implicit-def $d15, implicit-def $r30, implicit-def $r31, implicit-def $pc, implicit-def $r29, implicit killed $r30, implicit killed $framekey {
+      $r0 = A2_tfrsi 0
+      $d15 = L4_return killed $r30, implicit-def $pc, implicit-def $r29, implicit killed $framekey, implicit-def dead $pc, implicit internal killed $r0
+    }
+
+...




More information about the llvm-commits mailing list