From b2659ec04a9814718736ad960635a9a28edd6078 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Wed, 7 Jun 2017 13:36:28 +0200 Subject: llvm4: use chrono helpers from LLVM LLVM 4 removes the old time interface and starts using the C++11's chrono. So switch to that in klee for LLVM 4 too. Signed-off-by: Jiri Slaby --- lib/Core/StatsTracker.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib/Core/StatsTracker.cpp') diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index 97e7fccb..6ad5b89f 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -285,6 +285,29 @@ void StatsTracker::done() { void StatsTracker::stepInstruction(ExecutionState &es) { if (OutputIStats) { if (TrackInstructionTime) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + static sys::TimePoint<> lastNowTime; + static std::chrono::nanoseconds lastUserTime(0); + + if (lastUserTime.count() == 0) { + std::chrono::nanoseconds sys; + sys::Process::GetTimeUsage(lastNowTime, lastUserTime, sys); + } else { + sys::TimePoint<> now; + std::chrono::nanoseconds user, sys; + + sys::Process::GetTimeUsage(now, user, sys); + + auto delta = + std::chrono::duration_cast(user - lastUserTime); + auto deltaNow = + std::chrono::duration_cast(now - lastNowTime); + stats::instructionTime += delta.count(); + stats::instructionRealTime += deltaNow.count(); + lastUserTime = user; + lastNowTime = now; + } +#else static sys::TimeValue lastNowTime(0,0),lastUserTime(0,0); if (lastUserTime.seconds()==0 && lastUserTime.nanoseconds()==0) { @@ -300,6 +323,7 @@ void StatsTracker::stepInstruction(ExecutionState &es) { lastUserTime = user; lastNowTime = now; } +#endif } Instruction *inst = es.pc->inst; -- cgit 1.4.1