#include "llvm-c/Core.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/IR/DebugLoc.h"
#include "llvm/Support/Casting.h"
namespace llvm {
const Function &Fn;
/// Debug location where this diagnostic is triggered.
- const DebugLoc &DLoc;
+ DebugLoc DLoc;
/// Message to report.
const Twine &Msg;
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))
// 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