From f08cea90a3470b37a4d5da040136eb8052a6caad Mon Sep 17 00:00:00 2001 From: "Hassan @Ubuntu" Date: Sat, 19 Jun 2021 20:13:40 +0200 Subject: [PATCH] Use cpp commenting style --- src/common/CriticalSignatures.h | 8 +-- src/common/MemoryActions.h | 7 +-- src/common/action.h | 10 ++-- src/common/defs.h | 32 +++++----- src/common/instruction.h | 60 ++++++++----------- .../commutativity/CommutativityChecker.cc | 12 ++-- .../commutativity/CommutativityChecker.h | 5 +- src/detector/determinacy/checker.cc | 18 ++---- src/detector/determinacy/checker.h | 2 +- src/detector/determinacy/operationSet.h | 5 +- src/functionengine/CallStack.h | 3 + .../callbacks/InstrumentationCallbacks.cc | 12 ++-- src/instrumentor/callbacks/OMPTCallbacks.h | 27 ++++----- src/instrumentor/eventlogger/Logger.h | 29 ++++----- src/instrumentor/eventlogger/TaskInfo.h | 26 ++++---- src/instrumentor/eventlogger/Util.h | 17 ++---- src/instrumentor/pass/DebugInfoHelper.h | 42 ++++--------- src/instrumentor/pass/IIRlogger.h | 40 ++++--------- src/instrumentor/pass/TaskSanitizer.cc | 2 +- test/Common_Defs_gtest.cc | 3 +- 20 files changed, 142 insertions(+), 218 deletions(-) diff --git a/src/common/CriticalSignatures.h b/src/common/CriticalSignatures.h index 360354c..514efae 100644 --- a/src/common/CriticalSignatures.h +++ b/src/common/CriticalSignatures.h @@ -17,16 +17,12 @@ namespace tasksan { -/** - * Returns signature to mark beginning of a critical section - */ +// Returns signature to mark beginning of a critical section inline std::string getStartCriticalSignature() { return "TASKSAN:BeginCriticalSection"; } -/* - * Returns a string signature to mark end of a critical section - */ +// Returns a string signature to mark end of a critical section inline std::string getEndCriticalSignature() { return "TASKSAN:EndCriticalSection"; } diff --git a/src/common/MemoryActions.h b/src/common/MemoryActions.h index 7bc56b1..c615c5b 100644 --- a/src/common/MemoryActions.h +++ b/src/common/MemoryActions.h @@ -38,8 +38,8 @@ class MemoryActions { storeAction( act ); } - /** Stores action if (a) is first action of task, or - * (b) is last write action */ + // Stores action if (a) is first action of task, or + // (b) is last write action inline void storeAction(Action & act) { if ( isEmpty || act.isWrite ) { action = act; @@ -66,8 +66,7 @@ class MemoryActions { } } - /** - * Returns true if current action is a write */ + // Returns true if current action is a write bool hasWrite() { if ( isEmpty || ( !action.isWrite )) { return false; diff --git a/src/common/action.h b/src/common/action.h index 5c8f1c6..5dde4ad 100644 --- a/src/common/action.h +++ b/src/common/action.h @@ -41,17 +41,15 @@ class Action { Action() { } - /** - * Generates std::string representation of the action and stores - * in "buff". It appends '\n' at the end of the std::string */ + // Generates std::string representation of the action and stores + // in "buff". It appends '\n' at the end of the std::string void printAction(std::ostringstream & buff) { printActionNN( buff ); buff << std::endl; } - /** - * Generates std::string representation of the action and stores in "buff". - * It does not append '\n' at the end of. the std::string */ + // Generates std::string representation of the action and stores in "buff". + // It does not append '\n' at the end of. the std::string void printActionNN(std::ostringstream & buff) { std::string type = " R "; if ( isWrite ) type = " W "; diff --git a/src/common/defs.h b/src/common/defs.h index 0530ae2..ff62d4d 100644 --- a/src/common/defs.h +++ b/src/common/defs.h @@ -15,25 +15,22 @@ #ifndef _COMMON_DEFS_H_ #define _COMMON_DEFS_H_ -#include -#include -#include -#include -#include -#include #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include +#include #include - -#include // std::mutex -//#include -//#include // std::thread +#include +#include +#include +#include +#include typedef bool BOOL; typedef void VOID; @@ -94,8 +91,9 @@ static std::string OperRepresentation(OPERATION op) { } }; -/** - * Definition below is for debugging printfs */ +////////////////////////////////////////////////// +/// Definition below is for debugging printfs // +////////////////////////////////////////////////// // #define DEBUG static std::mutex printLock; @@ -107,4 +105,4 @@ void inline PRINT_DEBUG(const std::string msg) { #endif // debug } -#endif +#endif // guard diff --git a/src/common/instruction.h b/src/common/instruction.h index 47c22af..e539658 100644 --- a/src/common/instruction.h +++ b/src/common/instruction.h @@ -30,13 +30,11 @@ class Instruction { // raw representation of instruction std::string raw; - /** - * Default constructor - */ + // Default constructor Instruction() {} - /** - * This constructor takes in IIR representation of an - * instruction and constructs an object representaion of it. */ + + // This constructor takes in IIR representation of an + // instruction and constructs an object representaion of it. Instruction(std::string stmt) { raw = trim( stmt ); @@ -102,37 +100,33 @@ class Instruction { oper = CALL; } - /* - // find operation - if (std::regex_search(segments[0], std::regex("store ")) { - oper = STORE; - std::string tmp = ; - std::stringstream a(trim(segments[0])); - tmp = ""' - (getline(ss, tok, ','); //store - } - if (std::regex_search(segments[0], std::regex("load ")) - oper = LOAD; + // // find operation + // if (std::regex_search(segments[0], std::regex("store ")) { + // oper = STORE; + // std::string tmp = ; + // std::stringstream a(trim(segments[0])); + // tmp = ""' + // (getline(ss, tok, ','); //store + // } + // if (std::regex_search(segments[0], std::regex("load ")) + // oper = LOAD; - if (std::regex_search(segments[0], std::regex("call ")) - oper = CALL; + // if (std::regex_search(segments[0], std::regex("call ")) + // oper = CALL; - if (std::regex_search(segments[0], std::regex("alloca ")) - oper = ALLOCA; + // if (std::regex_search(segments[0], std::regex("alloca ")) + // oper = ALLOCA; - if (std::regex_search(segments[0], std::regex("bitcast ")) - oper = BITCAST; + // if (std::regex_search(segments[0], std::regex("bitcast ")) + // oper = BITCAST; - if (std::regex_search(segments[0], std::regex("[fidb]add ")) - oper = ADD; + // if (std::regex_search(segments[0], std::regex("[fidb]add ")) + // oper = ADD; - if (std::regex_search(segments[0], std::regex("[fidb]mull ")) - oper = MULT; - */ + // if (std::regex_search(segments[0], std::regex("[fidb]mull ")) + // oper = MULT; } - - void print() { std::cout << "LineNo: " << lineNo << ", type: " << type @@ -143,16 +137,14 @@ class Instruction { << std::endl; } - /** - * Trims the left and right spaces from a std::string. */ + // Trims the left and right spaces from a std::string static std::string trim(std::string sentence) { size_t start = sentence.find_first_not_of(' '); size_t end = sentence.find_last_not_of(' '); return sentence.substr(start, (end -start)+1); } - /** - * Splits std::string into tokens substrings */ + // Splits std::string into tokens substrings std::vector splitInstruction(std::string stmt) { // split statements diff --git a/src/detector/commutativity/CommutativityChecker.cc b/src/detector/commutativity/CommutativityChecker.cc index 6520076..d1b55fd 100644 --- a/src/detector/commutativity/CommutativityChecker.cc +++ b/src/detector/commutativity/CommutativityChecker.cc @@ -17,9 +17,7 @@ #include "detector/determinacy/conflict.h" #include "detector/determinacy/report.h" -/** - * Parses IIR representation file for critical sections - */ +// Parses IIR representation file for critical sections VOID CommutativityChecker::parseTasksIR(char * IRlogName) { std::vector currentTask; std::string sttmt; // program statement @@ -56,10 +54,8 @@ VOID CommutativityChecker::parseTasksIR(char * IRlogName) { << Tasks.getSize() << std::endl; } -/** - * Checks for commutative critical sections operations which have been - * flagged as conflicts. - */ +// Checks for commutative critical sections operations which have been +// flagged as conflicts. bool CommutativityChecker::isCommutative(const Conflict & conflict) { // skip commutativity check if read-write conflict @@ -80,7 +76,7 @@ bool CommutativityChecker::isCommutative(const Conflict & conflict) { } BOOL CommutativityChecker::involveSimpleOperations( - /*std::string taskName,*/ + // std::string taskName, INTEGER lineNumber) { // get the instructions of a task diff --git a/src/detector/commutativity/CommutativityChecker.h b/src/detector/commutativity/CommutativityChecker.h index c67fa27..c48bd81 100644 --- a/src/detector/commutativity/CommutativityChecker.h +++ b/src/detector/commutativity/CommutativityChecker.h @@ -61,9 +61,8 @@ class CommutativityChecker { inline bool isCriticalSectionEnd(const std::string& sttmt) { return tasksan::getEndCriticalSignature() == sttmt; } - /** - * Returns the line number from the IR statement std::string - */ + + // Returns the line number from the IR statement std::string INTEGER getLineNumber(const std::string & sttmt) { std::smatch result; // get line number regex_search(sttmt, result, std::regex("^[0-9]+") ); diff --git a/src/detector/determinacy/checker.cc b/src/detector/determinacy/checker.cc index 8f9e553..e3a59aa 100644 --- a/src/detector/determinacy/checker.cc +++ b/src/detector/determinacy/checker.cc @@ -188,11 +188,8 @@ void Checker::saveTaskActions( const MemoryActions & taskActions ) { writes[taskActions.addr].push_back( taskActions ); // save } - -/** - * Records the determinacy race warning to the conflicts table. - * This is per pair of concurrent tasks. - */ +// Records the determinacy race warning to the conflicts table. +// This is per pair of concurrent tasks. VOID Checker::saveDeterminacyRaceReport(const Action& curMemAction, const Action& prevMemAction) { Conflict aConflict(curMemAction, prevMemAction); @@ -224,7 +221,7 @@ void Checker::addTaskNode(std::string & logLine) { Checker::saveHappensBeforeEdge(parId, sibId); } -/** Constructs action object from the log file */ +// Constructs action object from the log file void Checker::constructMemoryAction(std::stringstream & ssin, std::string & operation, Action & action) { @@ -245,7 +242,7 @@ void Checker::constructMemoryAction(std::stringstream & ssin, } else { action.isWrite = false; } -#ifdef DEBUG // check if data correctly set. +#ifdef DEBUG // check if data correctly set std::cout << "Action constructed: "; std::ostringstream buff; action.printAction(buff); @@ -273,7 +270,6 @@ void Checker::checkCommutativeOperations(CommutativityChecker & validator) { } } - VOID Checker::reportConflicts() { const std::string emptyLine( " "); @@ -351,10 +347,8 @@ VOID Checker::testing() { } } - -/** - * implementation of the checker destructor frees - * the memory dynamically generated for S-bags */ +// Implementation of the checker destructor frees +// the memory dynamically generated for S-bags Checker::~Checker() { for (auto it = serial_bags.begin(); it != serial_bags.end(); it++) { delete it->second; diff --git a/src/detector/determinacy/checker.h b/src/detector/determinacy/checker.h index cdc02c0..7d76ae4 100644 --- a/src/detector/determinacy/checker.h +++ b/src/detector/determinacy/checker.h @@ -68,7 +68,7 @@ class Checker { ~Checker(); private: - /** Constructs action object from the log file */ + // Constructs action object from the log file VOID constructMemoryAction(std::stringstream & ssin, std::string & opType, Action & action); diff --git a/src/detector/determinacy/operationSet.h b/src/detector/determinacy/operationSet.h index a87ca5e..f283e6c 100644 --- a/src/detector/determinacy/operationSet.h +++ b/src/detector/determinacy/operationSet.h @@ -27,9 +27,8 @@ class OperationSet { operations.insert( op ); } - /** - * Checks if operation "op" commutes with previous - * operations which manipulate a shared memory location. */ + // Checks if operation "op" commutes with previous + // operations which manipulate a shared memory location bool isCommutative(const OPERATION op) { // compare with other operation for (auto i : operations) { diff --git a/src/functionengine/CallStack.h b/src/functionengine/CallStack.h index 95cf2bc..911074a 100644 --- a/src/functionengine/CallStack.h +++ b/src/functionengine/CallStack.h @@ -19,6 +19,9 @@ #ifndef _FUNCTIONENGINE_CALLSTACK_H_ #define _FUNCTIONENGINE_CALLSTACK_H_ +#include +#include + class CallStack { private: std::stack funcStack; diff --git a/src/instrumentor/callbacks/InstrumentationCallbacks.cc b/src/instrumentor/callbacks/InstrumentationCallbacks.cc index fc41801..0e364c7 100644 --- a/src/instrumentor/callbacks/InstrumentationCallbacks.cc +++ b/src/instrumentor/callbacks/InstrumentationCallbacks.cc @@ -64,7 +64,7 @@ static TaskInfo * getTaskInfo(int * _type = NULL) { } } -/** Callbacks for store operations */ +// Callbacks for store operations inline void INS_MemRead( address addr, ulong size, @@ -89,8 +89,7 @@ inline void INS_MemRead( } } -/* - * Callbacks for store operations */ +// Callbacks for store operations inline void INS_MemWrite( address addr, lint value, @@ -116,9 +115,7 @@ inline void INS_MemWrite( } } - -/** - * A callback for memory writes of floats */ +// A callback for memory writes of floats void __tasksan_write_float( address addr, float value, @@ -131,8 +128,7 @@ void __tasksan_register_iir_file(void * fileName) { INS::initCommutativityChecker( (char *)fileName ); } -/** - * A callback for memory writes of doubles */ +// A callback for memory writes of doubles void __tasksan_write_double( address addr, double value, diff --git a/src/instrumentor/callbacks/OMPTCallbacks.h b/src/instrumentor/callbacks/OMPTCallbacks.h index bbd91f0..56e00d3 100644 --- a/src/instrumentor/callbacks/OMPTCallbacks.h +++ b/src/instrumentor/callbacks/OMPTCallbacks.h @@ -73,12 +73,12 @@ on_ompt_callback_implicit_task( static void on_ompt_callback_task_create( // called in the context of the creator - ompt_data_t *parent_task_data, /* id of parent task */ - const ompt_frame_t *parent_frame, /* frame data for parent task */ - ompt_data_t* new_task_data, /* id of created task */ + ompt_data_t *parent_task_data, // id of parent task + const ompt_frame_t *parent_frame, // frame data for parent task + ompt_data_t* new_task_data, // id of created task int type, int has_dependences, - const void *codeptr_ra) { /* pointer to outlined function */ + const void *codeptr_ra) { // pointer to outlined function int tid = ompt_get_thread_data()->value; switch ((int)type) { @@ -135,9 +135,9 @@ on_ompt_callback_task_create( // called in the context of the creator static void on_ompt_callback_task_schedule( // called in the context of the task - ompt_data_t *prior_task_data, /* data of prior task */ - ompt_task_status_t prior_task_status, /* status of prior task */ - ompt_data_t *next_task_data) { /* data of next task */ + ompt_data_t *prior_task_data, // data of prior task + ompt_task_status_t prior_task_status, // status of prior task + ompt_data_t *next_task_data) { // data of next task if (next_task_data->ptr == NULL) { TaskSanitizer_TaskBeginFunc(next_task_data); @@ -150,8 +150,7 @@ on_ompt_callback_task_schedule( // called in the context of the task // if (prior_task_status == ompt_task_complete) } -/* - * Callbacks for tokens */ +// Callbacks for tokens static void on_ompt_callback_task_dependences( ompt_data_t *task_data, @@ -198,11 +197,11 @@ on_ompt_callback_task_dependence( // Executed when a task inters or leaves a barrier // or a task region or a task group. static void on_ompt_callback_sync_region( - ompt_sync_region_kind_t kind, /* kind of sync region */ - ompt_scope_endpoint_t endpoint, /* endpoint of sync region */ - ompt_data_t *parallel_data, /* data of parallel region */ - ompt_data_t *task_data, /* data of task */ - const void *codeptr_ra) { /* return address of runtime call */ + ompt_sync_region_kind_t kind, // kind of sync region + ompt_scope_endpoint_t endpoint, // endpoint of sync region + ompt_data_t *parallel_data, // data of parallel region + ompt_data_t *task_data, // data of task + const void *codeptr_ra) { // return address of runtime call switch (kind) { case ompt_sync_region_barrier: diff --git a/src/instrumentor/eventlogger/Logger.h b/src/instrumentor/eventlogger/Logger.h index 97a9dde..3cd19aa 100644 --- a/src/instrumentor/eventlogger/Logger.h +++ b/src/instrumentor/eventlogger/Logger.h @@ -80,8 +80,7 @@ class INS { isOMPTinitialized = true; } - /* - * Generates a unique ID for each new task. */ + // Generates a unique ID for each new task static inline INTEGER GenTaskID() { INTEGER taskID = taskIDSeed.fetch_add(1); return taskID; @@ -90,9 +89,9 @@ class INS { static inline void initCommutativityChecker(char *fname) { onlineChecker.initializeCommutativityChecker(fname); } - /** - * registers the function if not registered yet. - * Also prints the function to standard output. */ + + // registers the function if not registered yet. + // Also prints the function to standard output. static inline INTEGER RegisterFunction(const STRING funcName) { guardLock.lock(); @@ -111,7 +110,7 @@ class INS { return funcID; } - /** close file used in logging */ + // close file used in logging static inline VOID Finalize() { guardLock.lock(); @@ -123,14 +122,14 @@ class INS { guardLock.unlock(); } - /** called when a task begins execution and retrieves parent task id */ + // called when a task begins execution and retrieves parent task id static inline VOID TaskBeginLog(TaskInfo& task) { guardLock.lock(); onlineChecker.onTaskCreate(task.taskID); guardLock.unlock(); } - /** called when a task begins execution. retrieves parent task id */ + // called when a task begins execution. retrieves parent task id static inline VOID TaskReceiveTokenLog( TaskInfo & task, ADDRESS bufLocAddr, INTEGER value ) { INTEGER parentID = -1; @@ -163,17 +162,15 @@ class INS { guardLock.unlock(); } - /** called before the task terminates. */ + // called before the task terminates. static inline VOID TaskEndLog( TaskInfo& task ) { //guardLock.lock(); // protect file descriptor // do something //guardLock.unlock(); } - /** - * stores the buffer address of the token and the - * value stored in the buffer for the succeeding task. - */ + // stores the buffer address of the token and the + // value stored in the buffer for the succeeding task. static inline VOID TaskSendTokenLog(TaskInfo & task, ADDRESS bufLocAddr, INTEGER value) { @@ -183,7 +180,7 @@ class INS { guardLock.unlock(); } - /** provides the address of memory a task reads from */ + // provides the address of memory a task reads from static inline VOID Read( TaskInfo & task, ADDRESS addr, INTEGER lineNo, STRING funcName ) { INTEGER funcID = task.getFunctionId( funcName ); @@ -203,7 +200,7 @@ class INS { guardLock.unlock(); } - /** stores a write action */ + // stores a write action static inline VOID Write(TaskInfo & task, ADDRESS addr, INTEGER value, INTEGER lineNo, STRING funcName) { @@ -225,7 +222,7 @@ class INS { guardLock.unlock(); } - /** Saves IDs of child tasks at a barrier */ + // Saves IDs of child tasks at a barrier static inline VOID saveChildHBs(TaskInfo & task) { guardLock.lock(); for (int uncleID : task.childrenIDs) { diff --git a/src/instrumentor/eventlogger/TaskInfo.h b/src/instrumentor/eventlogger/TaskInfo.h index 4a81426..46eda01 100644 --- a/src/instrumentor/eventlogger/TaskInfo.h +++ b/src/instrumentor/eventlogger/TaskInfo.h @@ -36,15 +36,13 @@ typedef struct TaskInfo { // stores the IDs of child tasks created by this task std::vector childrenIDs; - /** - * Appends child ID to a list of children IDs */ + // Appends child ID to a list of children IDs inline void addChild(int childID) { childrenIDs.push_back(childID); } - /** - * Stores the action info as performed by task. The rules for - * storing this information are explained in MemoryActions.h */ + // Stores the action info as performed by task. The rules for + // storing this information are explained in MemoryActions.h inline void saveMemoryAction(Action & action) { MemoryActions &loc = memoryLocations[action.addr]; loc.storeAction( action ); @@ -73,8 +71,7 @@ typedef struct TaskInfo { loc.storeAction(taskID, addr, value, lineNo, funcID, isWrite); } - /** - * Prints to ostringstream all memory access actions recorded. */ + // Prints to ostringstream all memory access actions recorded. void printMemoryActions() { for (auto it = memoryLocations.begin(); it != memoryLocations.end(); ++it) { @@ -82,10 +79,11 @@ typedef struct TaskInfo { } } - /** HELPER FUNCTIONS */ + ////////////////////////////////////////////////////// + /// HELPER FUNCTIONS // + ////////////////////////////////////////////////////// - /** - * returns ID if function registered before, otherwise 0. */ + // returns ID if function registered before, otherwise 0. inline INTEGER getFunctionId( const STRING funcName ) { auto fd = functions.find( funcName ); if ( fd == functions.end() ) { @@ -95,15 +93,13 @@ typedef struct TaskInfo { } } - /** - * Registers function for faster access. */ + // Registers function for faster access. void registerFunction(STRING funcName, INTEGER funcId ) { functions[funcName] = funcId; } - /** - * Clears all stored memory actions. - * Can executed once the actions are written to log file. */ + // Clears all stored memory actions. + // Can executed once the actions are written to log file. void flushLogs() { memoryLocations.clear(); actionBuffer.str(""); // clear buffer diff --git a/src/instrumentor/eventlogger/Util.h b/src/instrumentor/eventlogger/Util.h index e02ae4e..53cee77 100644 --- a/src/instrumentor/eventlogger/Util.h +++ b/src/instrumentor/eventlogger/Util.h @@ -23,8 +23,7 @@ // used in task action logging callbacks. namespace UTIL { -/** - * Creates and initializes action logging metadata */ +// Creates and initializes action logging metadata void createNewTaskMetadata(ompt_data_t *task_data) { // Null if this task created before OMPT initialization @@ -54,9 +53,8 @@ void createNewTaskMetadata(ompt_data_t *task_data) { ); } -/** - * Marks task metadata of completion of task. - * It also logs relevant information to file. */ +// Marks task metadata of completion of task. +// It also logs relevant information to file. void markEndOfTask(ompt_data_t *task_data) { // Null if this task created before OMPT initialization @@ -72,16 +70,13 @@ void markEndOfTask(ompt_data_t *task_data) { ") taskID: " + std::to_string(taskInfo->taskID)); } - -/** - * Marks this task as complete */ +// Marks this task as complete void endThisTask(ompt_data_t *task_data) { markEndOfTask(task_data); } -/** - * Changes identifer of the current task to - * new ID and thus make it look like a new task. */ +// Changes identifer of the current task to +// new ID and thus make it look like a new task. void disguiseToTewTask(ompt_data_t *task_data) { UTIL::createNewTaskMetadata(task_data); } diff --git a/src/instrumentor/pass/DebugInfoHelper.h b/src/instrumentor/pass/DebugInfoHelper.h index c2b7e4b..0d89c0e 100644 --- a/src/instrumentor/pass/DebugInfoHelper.h +++ b/src/instrumentor/pass/DebugInfoHelper.h @@ -25,9 +25,7 @@ namespace tasksan { /// reporting of TaskSanitizer. namespace debug { -/** - * Demangles names of attributes, functions, etc - */ +// Demangles names of attributes, functions, etc llvm::StringRef demangleName(llvm::StringRef name) { int status = -1; std::string name_(name.str()); @@ -39,9 +37,7 @@ llvm::StringRef demangleName(llvm::StringRef name) { return name; } -/* - * Returns file name with absolute path - */ +// Returns file name with absolute path std::string createAbsoluteFileName( std::string & dir_name, std::string &file_name) { @@ -71,9 +67,7 @@ std::string createAbsoluteFileName( return dir_name + file_name; } -/** - * Returns absolute file name of which the function belongs to. - */ +// Returns absolute file name of which the function belongs to. std::string getFullFilename(llvm::Module & M) { std::string name = "Unknown"; @@ -92,9 +86,7 @@ std::string getFullFilename(llvm::Module & M) { return name; } -/** - * Returns absolute file name of which the function belongs to. - */ +// Returns absolute file name of which the function belongs to. std::string getFilename(const llvm::Function &F) { std::string name = "Unknown"; std::string dirName = ""; @@ -119,10 +111,8 @@ std::string getFilename(const llvm::Function &F) { } -/** - * Returns name of the function under instrumentation - * as a value. The name is retrieved later at runtime. - */ +// Returns name of the function under instrumentation +// as a value. The name is retrieved later at runtime. llvm::Value* getFuncName(llvm::Function & F) { llvm::StringRef name = demangleName(F.getName()); auto idx = name.find('('); @@ -134,9 +124,7 @@ llvm::Value* getFuncName(llvm::Function & F) { return IRB.CreateGlobalStringPtr(name, "func_name"); } -/** - * Return function name as a std::string - */ +// Return function name as a std::string llvm::StringRef getFuncNameStr(llvm::Function & F) { llvm::StringRef name = demangleName(F.getName()); auto idx = name.find('('); @@ -159,10 +147,8 @@ bool hasMainFunction(llvm::Module & M) { return false; } - /** - * Returns the name of the memory location involved. - * By object, this refers to the name of the variable. - */ + // Returns the name of the memory location involved. + // By object, this refers to the name of the variable. llvm::Value * getObjectName(llvm::Value *V, llvm::Instruction* I, const llvm::DataLayout &DL) { llvm::Value* obj = GetUnderlyingObject(V, DL); @@ -176,10 +162,7 @@ bool hasMainFunction(llvm::Module & M) { } } - /** - * Retrieves the line number of the instruction - * being instrumented. - */ + // Retrieves the line number of the instruction being instrumented. llvm::Value* getLineNumber(llvm::Instruction* I) { if (auto Loc = I->getDebugLoc()) { // Here I is an LLVM instruction @@ -193,10 +176,7 @@ bool hasMainFunction(llvm::Module & M) { } } - /** - * Retrieves the line number of the instruction - * being instrumented. - */ + // Retrieves the line number of the instruction being instrumented. unsigned int getLineNo(llvm::Instruction* I) { if (auto Loc = I->getDebugLoc()) { // Here I is an LLVM instruction diff --git a/src/instrumentor/pass/IIRlogger.h b/src/instrumentor/pass/IIRlogger.h index 6b04c21..bb6b3b7 100644 --- a/src/instrumentor/pass/IIRlogger.h +++ b/src/instrumentor/pass/IIRlogger.h @@ -34,10 +34,8 @@ namespace IIRlog { // the log out stream std::ofstream logFile; - /** - * Opens an output log file which is later used for - * logging all instructions in program's critical sections. - */ + // Opens an output log file which is later used for + // logging all instructions in program's critical sections. void InitializeLogger( std::string cppName ) { std::string full_file_name = "" + cppName + ".iir"; @@ -50,20 +48,16 @@ namespace IIRlog { } - /** - * Saves a string to a log file - */ + // Saves a string to a log file void SaveToLogFile( llvm::StringRef taskName ) { logFile << taskName.str() << std::endl << std::flush; } - /** - * Saves IIR represenation of instruction and its - * corresponding line number to a file. - * - * This function is used in logging instructions which - * are in critical sections of a program. - */ + // Saves IIR represenation of instruction and its + // corresponding line number to a file. + // + // This function is used in logging instructions which + // are in critical sections of a program. void LogNewIIRcode(int lineNo, llvm::Instruction& IIRcode ) { //errs() << lineNo << ": " << IIRcode.str() << "\n"; std::string tempBuf; @@ -72,9 +66,7 @@ namespace IIRlog { logFile << lineNo << ": " << tempBuf << std::endl; } - /** - * Returns signature (function name) of call being made - */ + // Returns signature (function name) of call being made llvm::StringRef getCalledFunction(llvm::Instruction & Inst) { if ( llvm::isa(Inst) ) { llvm::CallInst *M = llvm::dyn_cast(&Inst); @@ -94,9 +86,7 @@ namespace IIRlog { return llvm::StringRef(""); } - /** - * Checks if the function call is for acquiring a lock - */ + // Checks if the function call is for acquiring a lock bool isLockInvocation(llvm::Instruction & Instr) { llvm::StringRef funcName = getCalledFunction(Instr); if (funcName.find("omp_set_lock") != llvm::StringRef::npos || @@ -107,9 +97,7 @@ namespace IIRlog { } } - /** - * Checks if function call is related to lock release - */ + // Checks if function call is related to lock release bool isUnlockInvocation(llvm::Instruction & Instr) { llvm::StringRef funcName = getCalledFunction(Instr); if (funcName.find("omp_unset_lock") != llvm::StringRef::npos || @@ -120,10 +108,8 @@ namespace IIRlog { } } - /** - * Logs all statements in critical sections for commutativity - * checking in verification of determinacy races - */ + // Logs all statements in critical sections for commutativity + // checking in verification of determinacy races void logTaskBody(llvm::Function & F, llvm::StringRef name) { std::string fullFileName = tasksan::debug::getFilename(F); diff --git a/src/instrumentor/pass/TaskSanitizer.cc b/src/instrumentor/pass/TaskSanitizer.cc index 84a9ad3..d62e71d 100644 --- a/src/instrumentor/pass/TaskSanitizer.cc +++ b/src/instrumentor/pass/TaskSanitizer.cc @@ -537,7 +537,7 @@ bool TaskSanitizer::instrumentLoadOrStore(llvm::Instruction *I, if (Idx < 0) return false; if (IsWrite && isVtableAccess(I)) { - DEBUG(llvm::dbgs() << " VPTR : " << *I << "\n"); + llvm::dbgs() << " VPTR : " << *I << "\n"; llvm::Value *StoredValue = llvm::cast(I)->getValueOperand(); // StoredValue may be a std::vector type if we are storing several vptrs at once. // In this case, just take the first element of the std::vector since this is diff --git a/test/Common_Defs_gtest.cc b/test/Common_Defs_gtest.cc index feb6ce7..90d1088 100644 --- a/test/Common_Defs_gtest.cc +++ b/test/Common_Defs_gtest.cc @@ -1,6 +1,7 @@ -#include "common/defs.h" #include +#include "common/defs.h" + //! \brief Test that OperRepresentation converts operations //! to approriate string representations. TEST(OperRepresentation, TestConversion) {