Inliner::OptimizationRemark: Fix crash in clang/test/Frontend/optimization-remark.c on some hosts, including --vg.

DebugLoc in Callsite would not live after Inliner. It should be copied before Inliner.

llvm-svn: 206459
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index 17be3b2..6d3ceef 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -518,6 +518,9 @@
         if (!shouldInline(CS))
           continue;
 
+        // Get DebugLoc to report. CS will be invalid after Inliner.
+        DebugLoc DLoc = CS.getInstruction()->getDebugLoc();
+
         // Attempt to inline the function.
         if (!InlineCallIfPossible(CS, InlineInfo, InlinedArrayAllocas,
                                   InlineHistoryID, InsertLifetime, DL))
@@ -526,7 +529,7 @@
 
         // Report the inline decision.
         Caller->getContext().emitOptimizationRemark(
-            DEBUG_TYPE, *Caller, CS.getInstruction()->getDebugLoc(),
+            DEBUG_TYPE, *Caller, DLoc,
             Twine(Callee->getName() + " inlined into " + Caller->getName()));
 
         // If inlining this function gave us any new call sites, throw them