Skip to content

Commit

Permalink
Release 2.0.3
Browse files Browse the repository at this point in the history
* fixes #233
  * fix: added missing requirements
  * fix: possible type error
  * fix: save working copy path
* fix #227: loop variables not classified as private anymore
* fix #229: added option to ignore metadata when determining variable names
* fixes #235: updated release instructions in wiki
* fixes #201: forward error codes in runDiscoPoP script 
* updated version files
  • Loading branch information
lukasrothenberger authored Dec 2, 2022
1 parent e7acc52 commit 240765b
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 41 deletions.
32 changes: 16 additions & 16 deletions DiscoPoP/DiscoPoP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ string DiscoPoP::determineVariableDefLine(Instruction *I) {
string varDefLine{"LineNotFound"};

bool isGlobal = false;
string varName = determineVariableName_static(&*I, isGlobal);
string varName = determineVariableName_static(&*I, isGlobal, true);
// varName = refineVarName(varName);
varName = (varName.find(".addr") == varName.npos)
? varName
Expand Down Expand Up @@ -283,10 +283,10 @@ string DiscoPoP::determineVariableDefLine(Instruction *I) {
if (AI) {
for (User *U: AI->users()) {
if (StoreInst * SI = dyn_cast<StoreInst>(U)) {
vn = determineVariableName_static(&*SI, isGlobal);
vn = determineVariableName_static(&*SI, isGlobal, true);
break;
} else if (LoadInst * LI = dyn_cast<LoadInst>(U)) {
vn = determineVariableName_static(&*LI, isGlobal);
vn = determineVariableName_static(&*LI, isGlobal, true);
break;
}
}
Expand Down Expand Up @@ -363,7 +363,7 @@ void DiscoPoP::populateGlobalVariablesSet(Region *TopRegion,
isa<CallInst>(instruction)) {

// NOTE: changed 'instruction' to '&*instruction'
string varName = determineVariableName_static(&*instruction, isGlobalVariable);
string varName = determineVariableName_static(&*instruction, isGlobalVariable, false);

if (isGlobalVariable) // add it if it is a global variable in the program
{
Expand Down Expand Up @@ -490,7 +490,7 @@ void DiscoPoP::createCUs(Region *TopRegion, set <string> &globalVariablesSet,
Type *Ty = operand->getType();
unsigned u = DL->getTypeSizeInBits(Ty);
cu->writeDataSize += u;
varName = determineVariableName_static(&*instruction, isGlobalVar);
varName = determineVariableName_static(&*instruction, isGlobalVar, false);
varType = determineVariableType(&*instruction);
suspiciousVariables.insert(varName);
if (lid > 0)
Expand All @@ -500,7 +500,7 @@ void DiscoPoP::createCUs(Region *TopRegion, set <string> &globalVariablesSet,
Type *Ty = instruction->getType();
unsigned u = DL->getTypeSizeInBits(Ty);
cu->readDataSize += u;
varName = determineVariableName_static(&*instruction, isGlobalVar);
varName = determineVariableName_static(&*instruction, isGlobalVar, false);
if (suspiciousVariables.count(varName)) {
// VIOLATION OF CAUTIOUS PROPERTY
// it is a load instruction which read the value of a global
Expand Down Expand Up @@ -681,7 +681,7 @@ void DiscoPoP::fillCUVariables(Region *TopRegion,
if (lid == 0)
continue;
// NOTE: changed 'instruction' to '&*instruction', next 2 lines
varName = determineVariableName_static(&*instruction, isGlobalVar);
varName = determineVariableName_static(&*instruction, isGlobalVar, false);
varType = determineVariableType(&*instruction);
varDefLine = determineVariableDefLine(&*instruction);

Expand Down Expand Up @@ -2114,7 +2114,7 @@ Type *DiscoPoP::pointsToStruct(PointerType *PTy) {
return structType->getTypeID() == Type::StructTyID ? structType : NULL;
}

string DiscoPoP::determineVariableName_static(Instruction *I, bool &isGlobalVariable /*=defaultIsGlobalVariableValue*/)
string DiscoPoP::determineVariableName_static(Instruction *I, bool &isGlobalVariable /*=defaultIsGlobalVariableValue*/, bool disable_MetadataMap)
{

assert(I && "Instruction cannot be NULL \n");
Expand All @@ -2126,7 +2126,7 @@ string DiscoPoP::determineVariableName_static(Instruction *I, bool &isGlobalVari
if (operand == NULL)
{
string retVal = getOrInsertVarName_static("", builder);
if (trueVarNamesFromMetadataMap.find(retVal) == trueVarNamesFromMetadataMap.end()) {
if (trueVarNamesFromMetadataMap.find(retVal) == trueVarNamesFromMetadataMap.end() || disable_MetadataMap) {
return retVal; // not found
} else {
return trueVarNamesFromMetadataMap[retVal]; // found
Expand All @@ -2141,7 +2141,7 @@ string DiscoPoP::determineVariableName_static(Instruction *I, bool &isGlobalVari
//MOHAMMAD ADDED THIS FOR CHECKING
isGlobalVariable = true;
string retVal = string(operand->getName());
if (trueVarNamesFromMetadataMap.find(retVal) == trueVarNamesFromMetadataMap.end()) {
if (trueVarNamesFromMetadataMap.find(retVal) == trueVarNamesFromMetadataMap.end() || disable_MetadataMap) {
return retVal; // not found
} else {
return trueVarNamesFromMetadataMap[retVal]; // found
Expand Down Expand Up @@ -2172,7 +2172,7 @@ string DiscoPoP::determineVariableName_static(Instruction *I, bool &isGlobalVari
if (ret.size() > 0)
{
string retVal = ret;
if (trueVarNamesFromMetadataMap.find(retVal) == trueVarNamesFromMetadataMap.end()) {
if (trueVarNamesFromMetadataMap.find(retVal) == trueVarNamesFromMetadataMap.end() || disable_MetadataMap) {
return retVal; // not found
} else {
return trueVarNamesFromMetadataMap[retVal]; // found
Expand All @@ -2181,7 +2181,7 @@ string DiscoPoP::determineVariableName_static(Instruction *I, bool &isGlobalVari
else
{
string retVal = getOrInsertVarName_static("", builder);
if (trueVarNamesFromMetadataMap.find(retVal) == trueVarNamesFromMetadataMap.end()) {
if (trueVarNamesFromMetadataMap.find(retVal) == trueVarNamesFromMetadataMap.end() || disable_MetadataMap) {
return retVal; // not found
} else {
return trueVarNamesFromMetadataMap[retVal]; // found
Expand All @@ -2196,12 +2196,12 @@ string DiscoPoP::determineVariableName_static(Instruction *I, bool &isGlobalVari
// we've found an array
if (PTy->getPointerElementType()->getTypeID() == Type::ArrayTyID && isa<GetElementPtrInst>(*ptrOperand))
{
return determineVariableName_static((Instruction *)ptrOperand, isGlobalVariable);
return determineVariableName_static((Instruction *)ptrOperand, isGlobalVariable, false);
}
return determineVariableName_static((Instruction *)gep, isGlobalVariable);
return determineVariableName_static((Instruction *)gep, isGlobalVariable, false);
}
string retVal = string(operand->getName().data());
if (trueVarNamesFromMetadataMap.find(retVal) == trueVarNamesFromMetadataMap.end()) {
if (trueVarNamesFromMetadataMap.find(retVal) == trueVarNamesFromMetadataMap.end() || disable_MetadataMap) {
return retVal; // not found
} else {
return trueVarNamesFromMetadataMap[retVal]; // found
Expand All @@ -2211,7 +2211,7 @@ string DiscoPoP::determineVariableName_static(Instruction *I, bool &isGlobalVari

if (isa<LoadInst>(*operand) || isa<StoreInst>(*operand))
{
return determineVariableName_static((Instruction *)(operand), isGlobalVariable);
return determineVariableName_static((Instruction *)(operand), isGlobalVariable, false);
}
// if we cannot determine the name, then return *
return ""; //getOrInsertVarName("*", builder);
Expand Down
2 changes: 1 addition & 1 deletion DiscoPoP/DiscoPoP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ namespace {

Value *determineVariableName_dynamic(Instruction *const I);

string determineVariableName_static(Instruction *I, bool &isGlobalVariable /*=defaultIsGlobalVariableValue*/);
string determineVariableName_static(Instruction *I, bool &isGlobalVariable /*=defaultIsGlobalVariableValue*/, bool disable_MetadataMap);

void getTrueVarNamesFromMetadata(Region *TopRegion, Node *root,
std::map <string, string> *trueVarNamesFromMetadataMap);
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.2
2.0.3
2 changes: 1 addition & 1 deletion discopop_explorer/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.2"
__version__ = "2.0.3"
4 changes: 2 additions & 2 deletions discopop_explorer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ def classify_loop_variables(
waw.update(__get_dep_of_type(pet, sub_node, DepType.WAW, False))
rev_raw.update(__get_dep_of_type(pet, sub_node, DepType.RAW, True))

# vars = pet.get_undefined_variables_inside_loop(loop)
vars = pet.get_undefined_variables_inside_loop(loop)
sub = pet.subtree_of_type(loop, NodeType.CU)
vars = list(pet.get_variables(sub))
# vars = list(pet.get_variables(sub))
for var in vars:
if is_loop_index2(pet, loop, var.name):
private.append(var)
Expand Down
2 changes: 1 addition & 1 deletion discopop_profiler/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.2"
__version__ = "2.0.3"
1 change: 1 addition & 0 deletions discopop_wizard/classes/ExecutionConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def save_changes(self, wizard, main_screen_obj,
self.executable_arguments = executable_args.get()
self.make_flags = make_flags.get()
self.project_path = project_path.get()
self.working_copy_path = self.project_path + "/.discopop"
self.linker_flags = project_linker_flags.get()
self.make_target = make_target.get()
self.notes = additional_notes.get("1.0", tk.END)
Expand Down
14 changes: 7 additions & 7 deletions discopop_wizard/classes/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class Settings(object):

def __init__(self) -> None:
# try and find default values for executables
self.clang = shutil.which("clang")
self.clangpp = shutil.which("clang++")
self.llvm_ar = shutil.which("llvm-ar-11")
self.llvm_link = shutil.which("llvm-link-11")
self.llvm_dis = shutil.which("llvm-dis-11")
self.llvm_opt = shutil.which("opt-11")
self.llvm_llc = shutil.which("llc-11")
self.llvm_llc = "" if shutil.which("llc-11") is None else shutil.which("llc-11")
self.llvm_opt = "" if shutil.which("opt-11") is None else shutil.which("opt-11")
self.llvm_dis = "" if shutil.which("llvm-dis-11") is None else shutil.which("llvm-dis-11")
self.llvm_link = "" if shutil.which("llvm-link-11") is None else shutil.which("llvm-link-11")
self.llvm_ar = "" if shutil.which("llvm-ar-11") is None else shutil.which("llvm-ar-11")
self.clangpp = "" if shutil.which("clang++") is None else shutil.which("clang++")
self.clang = "" if shutil.which("clang") is None else shutil.which("clang")

def init_from_values(self, values: dict):
"""values stems from reading the 'add_configuration' form."""
Expand Down
3 changes: 2 additions & 1 deletion discopop_wizard/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
# the 3-Clause BSD License. See the LICENSE file in the package base
# directory for details.

tk
tk
jsons
20 changes: 11 additions & 9 deletions docs/How_to_contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ The process is identical to the previously mentioned process for contributors wh
The process to solve an already known issue (bug or feature request) is basically identical to the previously described process.
However, instead of creating a fork of the repository please create a branch with a descriptive name, which allows to understand it's purpose and it's relation to the targeted issue.
A good and easy option for this is to use the `Create a branch` link which can be found in the `Development` section of each issue.
Follow the instructions for determining the Version number depending on the contents of your branch and create a pull request to the respective release branch.

## Creating a new release
Execute the following steps in order to create a new DiscoPoP release:
- Switch to the release branch (e.g. `release/1.2.3`) which shall be released
- Update the version files in the repository
- Create a branch of the `master` with the name `release/1.2.3`
- Create a tag on the newly created branch with the name `v1.2.3`
- Creating the tag triggers the automatic publication of the project to PyPi
- Create a draft for the new release
- Release target: the newly created branch `release/1.2.3`
- Release tag: `v1.2.3`
- Release title: `Version 1.2.3`
- Description should contain a summary of the most relevant changes
- If everything is fine, create the new release
- Create a pull request to the `master` branch and validate the changes
- Merge the pull request and create a tag on the `master` branch with the name `v1.2.3`
- Creating the tag triggers the automatic publication of the project to PyPi
- Creating the tag triggers the automatic creation of a release draft
- Update the newly created release draft
- Release tag: `v1.2.3`
- Release title: `Version 1.2.3`
- Description should contain a summary of the most relevant changes
- If everything is fine, publish the new release

### Determining the Version Number
Lets assume a current version number `1.2.3`.
Expand Down
13 changes: 11 additions & 2 deletions scripts/runDiscoPoP
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ log () {
esac
}

log_or_fail () {
RETVAL=$?
log $1 "$2\n"
if [ $RETVAL -ne 0 ]; then
log -e "Exiting script with code: ${RETVAL}"
exit $RETVAL
fi
}

#####
# Parse Arguments
# based on https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
Expand Down Expand Up @@ -301,10 +310,10 @@ rm -f $PROJECT/${EXECUTABLE_NAME}_dp_dep.txt

# build using gllvm as compiler
log -i "Building your application..."
log -d "\n$(make CC=$GLLVM/gclang CXX=$GLLVM/gclang++ LD=$GLLVM/gclang++ $MAKE_FLAGS $MAKEFILE_TARGET)"
log_or_fail -d "\n$(make CC=$GLLVM/gclang CXX=$GLLVM/gclang++ LD=$GLLVM/gclang++ $MAKE_FLAGS $MAKEFILE_TARGET)"

# create single .bc and .ll from the executable
log -v "$($GLLVM/get-bc -b -m -v $EXECUTABLE_NAME 2>&1)"
log_or_fail -v "$($GLLVM/get-bc -b -m -v $EXECUTABLE_NAME 2>&1)"
$LLVM_DIS ${EXECUTABLE_NAME}.bc -o ${EXECUTABLE_NAME}.ll

#####
Expand Down

0 comments on commit 240765b

Please sign in to comment.