Skip to content

Commit

Permalink
Update comments about instruction skipping and replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
zacikpa committed Nov 10, 2023
1 parent 019c471 commit 2dcdc1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
13 changes: 7 additions & 6 deletions diffkemp/simpll/DifferentialFunctionComparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,9 @@ int DifferentialFunctionComparator::cmpAllocs(const CallInst *CL,
}

/// Check if the given instruction can be ignored (it does not affect
/// semantics). Replacements of ignorable instructions are stored
/// inside the ignored instructions map.
/// semantics). Ignorable instructions are stored inside the replaced
/// instructions map or the ignored instructions set, depending on whether
/// they need a replacement.
bool DifferentialFunctionComparator::maySkipInstruction(
const Instruction *Inst) const {
if (isa<AllocaInst>(Inst)) {
Expand Down Expand Up @@ -537,7 +538,7 @@ bool DifferentialFunctionComparator::maySkipInstruction(

/// Check whether the given cast can be ignored (it does not affect
/// semantics. First operands of ignorable casts are stored as their
/// replacements inside the ignored instructions map.
/// replacements inside the replaced instructions map.
bool DifferentialFunctionComparator::maySkipCast(const User *Cast) const {
auto SrcTy = Cast->getOperand(0)->getType();
auto DestTy = Cast->getType();
Expand Down Expand Up @@ -597,8 +598,8 @@ bool DifferentialFunctionComparator::maySkipCast(const User *Cast) const {
}

/// Check whether the given instruction is a repetitive variant of a previous
/// load with no store instructions in between. Replacements of ignorable loads
/// are stored inside the ignored instructions map.
/// load with no store or call instructions in between. Replacements of
/// ignorable loads are stored inside the replaced instructions map.
bool DifferentialFunctionComparator::maySkipLoad(const LoadInst *Load) const {
auto BB = Load->getParent();
if (!BB) {
Expand Down Expand Up @@ -689,7 +690,7 @@ bool mayIgnoreMacro(std::string macro) {
return ignoredMacroList.find(macro) != ignoredMacroList.end();
}

/// Retrive the replacement for the given value from the ignored instructions
/// Retrieve the replacement for the given value from the replaced instructions
/// map. Try to generate the replacement if a bitcast is given.
const Value *DifferentialFunctionComparator::getReplacementValue(
const Value *Replaced, DenseMap<const Value *, int> &sn_map) const {
Expand Down
14 changes: 8 additions & 6 deletions diffkemp/simpll/DifferentialFunctionComparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,26 +216,28 @@ class DifferentialFunctionComparator : public FunctionComparator {
bool accumulateAllOffsets(const BasicBlock &BB, uint64_t &Offset) const;

/// Check if the given instruction can be ignored (it does not affect
/// semantics). Replacements of ignorable instructions are stored
/// inside the ignored instructions map.
/// semantics). Ignorable instructions are stored inside the replaced
/// instructions map or the ignored instructions set, depending on whether
/// they need a replacement.
bool maySkipInstruction(const Instruction *Inst) const;

/// Check whether the given cast can be ignored (it does not affect
/// semantics. First operands of ignorable casts are stored as their
/// replacements inside the ignored instructions map.
/// replacements inside the replaced instructions map.
bool maySkipCast(const User *Cast) const;

/// Check whether the given instruction is a repetitive variant of a
/// previous load with no store instructions in between. Replacements of
/// ignorable loads are stored inside the ignored instructions map.
/// previous load with no store or call instructions in between.
/// Replacements of ignorable loads are stored inside the replaced
/// instructions map.
bool maySkipLoad(const LoadInst *Load) const;

/// Check whether the given reorderable binary operator can be skipped.
/// It can only be skipped if all its users are binary operations
/// of the same kind.
bool maySkipReorderableBinaryOp(const Instruction *Op) const;

/// Retrive the replacement for the given value from the ignored
/// Retrieve the replacement for the given value from the replaced
/// instructions map. Try to generate the replacement if a bitcast is given.
const Value *
getReplacementValue(const Value *Replaced,
Expand Down

0 comments on commit 2dcdc1b

Please sign in to comment.