X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=inline;f=CDSPass.cpp;h=684e03f1f3e45ab1b5ece0cf0af71d050c65f5b8;hb=1b9d40620be8be192b28e61c3856354c24a5555c;hp=3cbc4bd530509c41e1a3b721b823c8c036eafb87;hpb=327006d0cea75dfe9f6ccc4669702a62c5fecc35;p=c11llvm.git diff --git a/CDSPass.cpp b/CDSPass.cpp index 3cbc4bd..684e03f 100644 --- a/CDSPass.cpp +++ b/CDSPass.cpp @@ -42,6 +42,7 @@ #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" +#include "llvm/Transforms/Utils/EscapeEnumerator.h" #include using namespace llvm; @@ -167,6 +168,8 @@ void CDSPass::initializeCallbacks(Module &M) { CDSFuncEntry = M.getOrInsertFunction("cds_func_entry", VoidTy, Int8PtrTy); + CDSFuncExit = M.getOrInsertFunction("cds_func_exit", + VoidTy, Int8PtrTy); // Get the function to call from our untime library. for (unsigned i = 0; i < kNumberOfAccessSizes; i++) { @@ -334,8 +337,7 @@ bool CDSPass::runOnFunction(Function &F) { } for (auto Inst : AllLoadsAndStores) { - // Res |= instrumentLoadOrStore(Inst, DL); - // errs() << "load and store are replaced\n"; + Res |= instrumentLoadOrStore(Inst, DL); } for (auto Inst : AtomicAccesses) { @@ -344,23 +346,21 @@ bool CDSPass::runOnFunction(Function &F) { // only instrument functions that contain atomics if (Res && HasAtomic) { - /* IRBuilder<> IRB(F.getEntryBlock().getFirstNonPHI()); + /* Unused for now Value *ReturnAddress = IRB.CreateCall( Intrinsic::getDeclaration(F.getParent(), Intrinsic::returnaddress), IRB.getInt32(0)); + */ Value * FuncName = IRB.CreateGlobalStringPtr(F.getName()); - */ - //errs() << "function name: " << F.getName() << "\n"; - //IRB.CreateCall(CDSFuncEntry, FuncName); + IRB.CreateCall(CDSFuncEntry, FuncName); -/* - EscapeEnumerator EE(F, "tsan_cleanup", ClHandleCxxExceptions); + EscapeEnumerator EE(F, "cds_cleanup", true); while (IRBuilder<> *AtExit = EE.Next()) { - AtExit->CreateCall(TsanFuncExit, {}); + AtExit->CreateCall(CDSFuncExit, FuncName); } -*/ + Res = true; } } @@ -462,10 +462,8 @@ bool CDSPass::instrumentLoadOrStore(Instruction *I, if ( ArgType != Int8PtrTy && ArgType != Int16PtrTy && ArgType != Int32PtrTy && ArgType != Int64PtrTy ) { - //errs() << "A load or store of type "; - //errs() << *ArgType; - //errs() << " is passed in\n"; - return false; // if other types of load or stores are passed in + // if other types of load or stores are passed in + return false; } IRB.CreateCall(OnAccessFunc, IRB.CreatePointerCast(Addr, Addr->getType())); if (IsWrite) NumInstrumentedWrites++; @@ -476,6 +474,8 @@ bool CDSPass::instrumentLoadOrStore(Instruction *I, bool CDSPass::instrumentAtomic(Instruction * I, const DataLayout &DL) { IRBuilder<> IRB(I); + // errs() << "instrumenting: " << *I << "\n"; + if (auto *CI = dyn_cast(I)) { return instrumentAtomicCall(CI, DL); }