about summary refs log tree commit diff homepage
path: root/lib/Core
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2019-01-11 14:39:47 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2019-03-19 15:37:46 +0000
commit2558d3e34b4e0a47a1fe224683604ddaec96f69c (patch)
treeaeaf940c46d047fa5e6622ee72c581c5326dd423 /lib/Core
parentf8a481b82a403641440f6fd0de9f50af127fceec (diff)
downloadklee-2558d3e34b4e0a47a1fe224683604ddaec96f69c.tar.gz
Use debugging information from newer LLVM versions
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/Executor.cpp7
-rw-r--r--lib/Core/StatsTracker.cpp40
2 files changed, 25 insertions, 22 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index cd0f6078..82fe2356 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -597,7 +597,7 @@ void Executor::initializeGlobalObject(ExecutionState &state, ObjectState *os,
     for (unsigned i=0, e=cds->getNumElements(); i != e; ++i)
       initializeGlobalObject(state, os, cds->getElementAsConstant(i),
                              offset + i*elementSize);
-  } else if (!isa<UndefValue>(c)) {
+  } else if (!isa<UndefValue>(c) && !isa<MetadataAsValue>(c)) {
     unsigned StoreBits = targetData->getTypeStoreSizeInBits(c->getType());
     ref<ConstantExpr> C = evalConstant(c);
 
@@ -1329,6 +1329,8 @@ void Executor::executeCall(ExecutionState &state,
                            Function *f,
                            std::vector< ref<Expr> > &arguments) {
   Instruction *i = ki->inst;
+  if (i && isa<DbgInfoIntrinsic>(i))
+    return;
   if (f && f->isDeclaration()) {
     switch(f->getIntrinsicID()) {
     case Intrinsic::not_intrinsic:
@@ -1909,6 +1911,9 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
 
   case Instruction::Invoke:
   case Instruction::Call: {
+    // Ignore debug intrinsic calls
+    if (isa<DbgInfoIntrinsic>(i))
+      break;
     CallSite cs(i);
 
     unsigned numArgs = cs.arg_size();
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index 67553ad0..c0e3264d 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -546,7 +546,7 @@ void StatsTracker::writeIStats() {
       // KCachegrind can create two entries for the function, one with an
       // unnamed file and one without.
       Function *fn = &*fnIt;
-      const InstructionInfo &ii = executor.kmodule->infos->getFunctionInfo(fn);
+      const FunctionInfo &ii = executor.kmodule->infos->getFunctionInfo(*fn);
       if (ii.file != sourceFile) {
         of << "fl=" << ii.file << "\n";
         sourceFile = ii.file;
@@ -558,7 +558,7 @@ void StatsTracker::writeIStats() {
         for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end(); 
              it != ie; ++it) {
           Instruction *instr = &*it;
-          const InstructionInfo &ii = executor.kmodule->infos->getInfo(instr);
+          const InstructionInfo &ii = executor.kmodule->infos->getInfo(*instr);
           unsigned index = ii.id;
           if (ii.file!=sourceFile) {
             of << "fl=" << ii.file << "\n";
@@ -575,14 +575,13 @@ void StatsTracker::writeIStats() {
               (isa<CallInst>(instr) || isa<InvokeInst>(instr))) {
             CallSiteSummaryTable::iterator it = callSiteStats.find(instr);
             if (it!=callSiteStats.end()) {
-              for (std::map<llvm::Function*, CallSiteInfo>::iterator
-                     fit = it->second.begin(), fie = it->second.end(); 
+              for (auto fit = it->second.begin(), fie = it->second.end();
                    fit != fie; ++fit) {
-                Function *f = fit->first;
+                const Function *f = fit->first;
                 CallSiteInfo &csi = fit->second;
-                const InstructionInfo &fii = 
-                  executor.kmodule->infos->getFunctionInfo(f);
-  
+                const FunctionInfo &fii =
+                    executor.kmodule->infos->getFunctionInfo(*f);
+
                 if (fii.file!="" && fii.file!=sourceFile)
                   of << "cfl=" << fii.file << "\n";
                 of << "cfn=" << f->getName().str() << "\n";
@@ -746,7 +745,7 @@ void StatsTracker::computeReachableUncovered() {
              it != ie; ++it) {
           Instruction *inst = &*it;
           instructions.push_back(inst);
-          unsigned id = infos.getInfo(inst).id;
+          unsigned id = infos.getInfo(*inst).id;
           sm.setIndexedValue(stats::minDistToReturn, 
                              id, 
                              isa<ReturnInst>(inst)
@@ -761,8 +760,8 @@ void StatsTracker::computeReachableUncovered() {
     bool changed;
     do {
       changed = false;
-      for (std::vector<Instruction*>::iterator it = instructions.begin(),
-             ie = instructions.end(); it != ie; ++it) {
+      for (auto it = instructions.begin(), ie = instructions.end(); it != ie;
+           ++it) {
         Instruction *inst = *it;
         unsigned bestThrough = 0;
 
@@ -782,13 +781,13 @@ void StatsTracker::computeReachableUncovered() {
         }
        
         if (bestThrough) {
-          unsigned id = infos.getInfo(*it).id;
+          unsigned id = infos.getInfo(*(*it)).id;
           uint64_t best, cur = best = sm.getIndexedValue(stats::minDistToReturn, id);
           std::vector<Instruction*> succs = getSuccs(*it);
           for (std::vector<Instruction*>::iterator it2 = succs.begin(),
                  ie = succs.end(); it2 != ie; ++it2) {
             uint64_t dist = sm.getIndexedValue(stats::minDistToReturn,
-                                               infos.getInfo(*it2).id);
+                                               infos.getInfo(*(*it2)).id);
             if (dist) {
               uint64_t val = bestThrough + dist;
               if (best==0 || val<best)
@@ -824,7 +823,7 @@ void StatsTracker::computeReachableUncovered() {
       for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end(); 
            it != ie; ++it) {
         Instruction *inst = &*it;
-        unsigned id = infos.getInfo(inst).id;
+        unsigned id = infos.getInfo(*inst).id;
         instructions.push_back(inst);
         sm.setIndexedValue(stats::minDistToUncovered, 
                            id, 
@@ -842,8 +841,8 @@ void StatsTracker::computeReachableUncovered() {
     for (std::vector<Instruction*>::iterator it = instructions.begin(),
            ie = instructions.end(); it != ie; ++it) {
       Instruction *inst = *it;
-      uint64_t best, cur = best = sm.getIndexedValue(stats::minDistToUncovered, 
-                                                     infos.getInfo(inst).id);
+      uint64_t best, cur = best = sm.getIndexedValue(stats::minDistToUncovered,
+                                                     infos.getInfo(*inst).id);
       unsigned bestThrough = 0;
       
       if (isa<CallInst>(inst) || isa<InvokeInst>(inst)) {
@@ -858,8 +857,8 @@ void StatsTracker::computeReachableUncovered() {
           }
 
           if (!(*fnIt)->isDeclaration()) {
-            uint64_t calleeDist = sm.getIndexedValue(stats::minDistToUncovered,
-                                                     infos.getFunctionInfo(*fnIt).id);
+            uint64_t calleeDist = sm.getIndexedValue(
+                stats::minDistToUncovered, infos.getFunctionInfo(*(*fnIt)).id);
             if (calleeDist) {
               calleeDist = 1+calleeDist; // count instruction itself
               if (best==0 || calleeDist<best)
@@ -876,7 +875,7 @@ void StatsTracker::computeReachableUncovered() {
         for (std::vector<Instruction*>::iterator it2 = succs.begin(),
                ie = succs.end(); it2 != ie; ++it2) {
           uint64_t dist = sm.getIndexedValue(stats::minDistToUncovered,
-                                             infos.getInfo(*it2).id);
+                                             infos.getInfo(*(*it2)).id);
           if (dist) {
             uint64_t val = bestThrough + dist;
             if (best==0 || val<best)
@@ -886,8 +885,7 @@ void StatsTracker::computeReachableUncovered() {
       }
 
       if (best != cur) {
-        sm.setIndexedValue(stats::minDistToUncovered, 
-                           infos.getInfo(inst).id, 
+        sm.setIndexedValue(stats::minDistToUncovered, infos.getInfo(*inst).id,
                            best);
         changed = true;
       }