From dbca9deee4a28c78ba855fddc3c0d1250e3475b2 Mon Sep 17 00:00:00 2001 From: weiyu Date: Tue, 23 Jul 2019 18:15:44 -0700 Subject: [PATCH] instrument entries and exits of functions that contain volatile loads and stores --- CDSPass.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CDSPass.cpp b/CDSPass.cpp index 50aca18..6ec6dd2 100644 --- a/CDSPass.cpp +++ b/CDSPass.cpp @@ -327,6 +327,7 @@ bool CDSPass::runOnFunction(Function &F) { bool Res = false; bool HasAtomic = false; + bool HasVolatile = false; const DataLayout &DL = F.getParent()->getDataLayout(); // errs() << "--- " << F.getName() << "---\n"; @@ -341,9 +342,10 @@ bool CDSPass::runOnFunction(Function &F) { StoreInst *SI = dyn_cast(&I); bool isVolatile = ( LI ? LI->isVolatile() : SI->isVolatile() ); - if (isVolatile) + if (isVolatile) { VolatileLoadsAndStores.push_back(&I); - else + HasVolatile = true; + } else LocalLoadsAndStores.push_back(&I); } else if (isa(I) || isa(I)) { // not implemented yet @@ -366,7 +368,7 @@ bool CDSPass::runOnFunction(Function &F) { } // only instrument functions that contain atomics - if (Res && HasAtomic) { + if (Res && ( HasAtomic || HasVolatile) ) { IRBuilder<> IRB(F.getEntryBlock().getFirstNonPHI()); /* Unused for now Value *ReturnAddress = IRB.CreateCall( -- 2.34.1