[PATCH] D27913: [XRay] Fix assertion failure on empty machine basic blocks (PR 31424)

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 00:25:11 PST 2016


dberris added inline comments.


================
Comment at: lib/CodeGen/XRayInstrumentation.cpp:114-115
 bool XRayInstrumentation::runOnMachineFunction(MachineFunction &MF) {
+  if (MF.empty())
+    return false; // The function is empty.
+
----------------
chandlerc wrote:
> Add a test case for this as well?
I'm not sure how to do that from a .mir properly, but I tried anyway. :)


================
Comment at: lib/CodeGen/XRayInstrumentation.cpp:136-140
+    // It could be that the first MachineBasicBlock is empty, despite the
+    // function not being empty. So we insert the instruction in this basic
+    // block always.
+    BuildMI(FirstMBB, FirstMBB.begin(), DebugLoc(),
+            TII->get(TargetOpcode::PATCHABLE_FUNCTION_ENTER));
----------------
chandlerc wrote:
> Why do you care about instrumenting functions which have no instructions in them?
Good point -- mostly because I'm not sure whether the assumption that the first MBB being empty implies that there are no instructions in the rest of the function. I'm happy to ignore this case (maybe because it's when an inlined function is there just for the debug info case).


https://reviews.llvm.org/D27913





More information about the llvm-commits mailing list