-bool containsStr() {
-
-}
-
bool CDSPass::instrumentAtomicCall(CallInst *CI, const DataLayout &DL) {
IRBuilder<> IRB(CI);
Function *fun = CI->getCalledFunction();
parameters.push_back(param);
}
+ // obtain source line number of the CallInst
+ Value *position = getPosition(CI, IRB);
+
// the pointer to the address is always the first argument
Value *OrigPtr = parameters[0];
int Idx = getMemoryAccessFuncIndex(OrigPtr, DL);
if (funName.contains("atomic_init")) {
Value *ptr = IRB.CreatePointerCast(OrigPtr, PtrTy);
Value *val = IRB.CreateBitOrPointerCast(parameters[1], Ty);
- Value *args[] = {ptr, val};
+ Value *args[] = {ptr, val, position};
- Instruction* funcInst=CallInst::Create(CDSAtomicInit[Idx], args,"");
+ Instruction* funcInst=CallInst::Create(CDSAtomicInit[Idx], args);
ReplaceInstWithInst(CI, funcInst);
return true;
else
order = ConstantInt::get(OrdTy,
(int) AtomicOrderingCABI::seq_cst);
- Value *args[] = {ptr, order};
+ Value *args[] = {ptr, order, position};
- Instruction* funcInst=CallInst::Create(CDSAtomicLoad[Idx], args,"");
+ Instruction* funcInst=CallInst::Create(CDSAtomicLoad[Idx], args);
ReplaceInstWithInst(CI, funcInst);
return true;
else
order = ConstantInt::get(OrdTy,
(int) AtomicOrderingCABI::seq_cst);
- Value *args[] = {ptr, val, order};
+ Value *args[] = {ptr, val, order, position};
- Instruction* funcInst=CallInst::Create(CDSAtomicStore[Idx], args,"");
+ Instruction* funcInst=CallInst::Create(CDSAtomicStore[Idx], args);
ReplaceInstWithInst(CI, funcInst);
return true;
else
order = ConstantInt::get(OrdTy,
(int) AtomicOrderingCABI::seq_cst);
- Value *args[] = {ptr, val, order};
+ Value *args[] = {ptr, val, order, position};
- Instruction* funcInst=CallInst::Create(CDSAtomicRMW[op][Idx], args,"");
+ Instruction* funcInst=CallInst::Create(CDSAtomicRMW[op][Idx], args);
ReplaceInstWithInst(CI, funcInst);
return true;
}
Value *args[] = {Addr, CmpOperand, NewOperand,
- order_succ, order_fail};
+ order_succ, order_fail, position};
- Instruction* funcInst=CallInst::Create(CDSAtomicCAS_V2[Idx], args,"");
+ Instruction* funcInst=CallInst::Create(CDSAtomicCAS_V2[Idx], args);
ReplaceInstWithInst(CI, funcInst);
return true;