about summary refs log tree commit diff homepage
path: root/lib/Module/Checks.cpp
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2013-12-11 16:01:51 +0000
committerDan Liew <daniel.liew@imperial.ac.uk>2013-12-19 15:45:03 +0000
commit58de8cdce75bcee981ec813c57fb2ed7e83e9878 (patch)
tree2a7b344405e2ae327f69b980cd671c3b4d37f3cf /lib/Module/Checks.cpp
parent9809e76ec82c7bd70b8cb8b735be294ffb96d7bc (diff)
downloadklee-58de8cdce75bcee981ec813c57fb2ed7e83e9878.tar.gz
Remove old algorithm for acquiring debug info. Since LLVM 2.7,
debug information is attached directly to most instructions so
the simpler algorithm added in  5ecfd6e2fd5becc10be355b3a20d014e76e40518
can be used.

Since support for LLVM version < 2.9 has been removed the old algorithm
should be removed.

This has been tested with LLVM 2.9 and LLVM 3.3
Diffstat (limited to 'lib/Module/Checks.cpp')
-rw-r--r--lib/Module/Checks.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp
index bf37eea2..80b6b245 100644
--- a/lib/Module/Checks.cpp
+++ b/lib/Module/Checks.cpp
@@ -82,13 +82,13 @@ bool DivCheckPass::runOnModule(Module &M) {
                                                    NULL);
               divZeroCheckFunction = cast<Function>(fc);
             }
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
-            CallInst * ci =
-#endif
-	    CallInst::Create(divZeroCheckFunction, denominator, "", &*i);
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
+
+            CallInst * ci = CallInst::Create(divZeroCheckFunction, denominator, "", &*i);
+
+            // Set debug location of checking call to that of the div/rem
+            // operation so error locations are reported in the correct
+            // location.
             ci->setDebugLoc(binOp->getDebugLoc());
-#endif
             moduleChanged = true;
           }
         }
@@ -143,13 +143,14 @@ bool OvershiftCheckPass::runOnModule(Module &M) {
             }
 
             // Inject CallInstr to check if overshifting possible
+            CallInst* ci =
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
-            CallInst * ci = CallInst::Create(overshiftCheckFunction, args, "", &*i);
-            // set debug information from binary operand to preserve it
-            ci->setDebugLoc(binOp->getDebugLoc());
+            CallInst::Create(overshiftCheckFunction, args, "", &*i);
 #else
             CallInst::Create(overshiftCheckFunction, args.begin(), args.end(), "", &*i);
 #endif
+            // set debug information from binary operand to preserve it
+            ci->setDebugLoc(binOp->getDebugLoc());
             moduleChanged = true;
           }
         }