JIT: capture failing inline observation in more cases (#21471)
authorAndy Ayers <andya@microsoft.com>
Tue, 11 Dec 2018 22:59:29 +0000 (14:59 -0800)
committerGitHub <noreply@github.com>
Tue, 11 Dec 2018 22:59:29 +0000 (14:59 -0800)
We were not capturing failing inline observations for failed inlines
that got reported by the runtime directly. Move the point of capture
up in the jitted code so it always happens regardless of reporting
obligations.

src/jit/inline.cpp

index f523d2a..6bc8482 100644 (file)
@@ -659,6 +659,22 @@ InlineResult::InlineResult(Compiler* compiler, CORINFO_METHOD_HANDLE method, con
 
 void InlineResult::Report()
 {
+
+#ifdef DEBUG
+    // If this is a failure of a specific inline candidate and we haven't captured
+    // a failing observation yet, do so now.
+    if (IsFailure() && (m_Call != nullptr))
+    {
+        // compiler should have revoked candidacy on the call by now
+        assert((m_Call->gtFlags & GTF_CALL_INLINE_CANDIDATE) == 0);
+
+        if (m_Call->gtInlineObservation == InlineObservation::CALLEE_UNUSED_INITIAL)
+        {
+            m_Call->gtInlineObservation = m_Policy->GetObservation();
+        }
+    }
+#endif // DEBUG
+
     // If we weren't actually inlining, user may have suppressed
     // reporting via setReported(). If so, do nothing.
     if (m_Reported)
@@ -682,17 +698,6 @@ void InlineResult::Report()
 
         JITDUMP(format, m_Description, ResultString(), ReasonString(), caller, callee);
     }
-
-    // If the inline failed, leave information on the call so we can
-    // later recover what observation lead to the failure.
-    if (IsFailure() && (m_Call != nullptr))
-    {
-        // compiler should have revoked candidacy on the call by now
-        assert((m_Call->gtFlags & GTF_CALL_INLINE_CANDIDATE) == 0);
-
-        m_Call->gtInlineObservation = m_Policy->GetObservation();
-    }
-
 #endif // DEBUG
 
     // Was the result NEVER? If so we might want to propagate this to