add source line number as a argument
[c11llvm.git] / isAtomicCall.hpp
1 #pragma once
2
3 void printArgs(CallInst *);
4
5 bool isAtomicCall(Instruction *I)
6 {
7         if ( auto *CI = dyn_cast<CallInst>(I) ) {
8                 Function *fun = CI->getCalledFunction();
9                 StringRef funName = fun->getName();
10
11                 if ( (CI->isTailCall() && funName.contains("atomic_")) ||
12                         funName.contains("atomic_compare_exchange_") ) {
13                         // printArgs(CI);
14                         return true;
15                 }
16         }
17
18         return false;
19 }
20
21 void printArgs (CallInst *CI)
22 {
23         Function *fun = CI->getCalledFunction();
24         StringRef funName = fun->getName();
25
26         User::op_iterator begin = CI->arg_begin();
27         User::op_iterator end = CI->arg_end();
28
29         if ( funName.contains("atomic_") ) {
30                 std::vector<Value *> parameters;
31
32                 for (User::op_iterator it = begin; it != end; ++it) {
33                         Value *param = *it;
34                         parameters.push_back(param);
35                         errs() << *param << " type: " << *param->getType()  << "\n";
36                 }
37         }
38
39 }