fix up syntax errors
[c11llvm.git] / isAtomicCall.hpp
index 419312c..99e7532 100644 (file)
@@ -6,11 +6,17 @@ bool isAtomicCall(Instruction *I)
 {
        if ( auto *CI = dyn_cast<CallInst>(I) ) {
                Function *fun = CI->getCalledFunction();
 {
        if ( auto *CI = dyn_cast<CallInst>(I) ) {
                Function *fun = CI->getCalledFunction();
+               if (fun == NULL)
+                       return false;
+
                StringRef funName = fun->getName();
 
                StringRef funName = fun->getName();
 
-               if ( (CI->isTailCall() && funName.contains("atomic_")) ||
-                       funName.contains("atomic_compare_exchange_") ) {
-                       printArgs(CI);
+               // todo: come up with better rules for function name checking
+               if ( funName.contains("atomic_") ) {
+                       // printArgs(CI);
+                       return true;
+               } else if (funName.contains("atomic") ) {
+                       // errs() << "intercepted atomic calls: " << *I << "\n";
                        return true;
                }
        }
                        return true;
                }
        }
@@ -26,7 +32,7 @@ void printArgs (CallInst *CI)
        User::op_iterator begin = CI->arg_begin();
        User::op_iterator end = CI->arg_end();
 
        User::op_iterator begin = CI->arg_begin();
        User::op_iterator end = CI->arg_end();
 
-       if (funName.find("atomic_") != -1) {
+       if ( funName.contains("atomic_") ) {
                std::vector<Value *> parameters;
 
                for (User::op_iterator it = begin; it != end; ++it) {
                std::vector<Value *> parameters;
 
                for (User::op_iterator it = begin; it != end; ++it) {