diff --git a/SmallMap.h b/SmallMap.h index c5a6ccc28..5a171a75b 100644 --- a/SmallMap.h +++ b/SmallMap.h @@ -177,8 +177,7 @@ public: if (IsSorted || !isSmall() || Size <= 1) return; - auto Compare = [] (const Pair &A, - const Pair &B) { + auto Compare = [] (const Pair &A, const Pair &B) { return std::less()(A.first, B.first); }; std::sort(Vector.begin(), Vector.begin() + Size, Compare); diff --git a/codegenerator.cpp b/codegenerator.cpp index 9fec3d347..4be537339 100644 --- a/codegenerator.cpp +++ b/codegenerator.cpp @@ -583,8 +583,9 @@ void CodeGenerator::translate(uint64_t VirtualAddress) { // Instantiate helpers VariableManager Variables(*TheModule, *HelpersModule, TargetArchitecture); const Architecture &Arch = Binary.architecture(); + StringRef SPName = Arch.stackPointerRegister(); GlobalVariable *PCReg = Variables.getByEnvOffset(ptc.pc, "pc").first; - GlobalVariable *SPReg = Variables.getByEnvOffset(ptc.sp, Arch.stackPointerRegister()).first; + GlobalVariable *SPReg = Variables.getByEnvOffset(ptc.sp, SPName).first; IRBuilder<> Builder(Context); @@ -647,7 +648,8 @@ void CodeGenerator::translate(uint64_t VirtualAddress) { auto *Delimiter = Builder.CreateStore(StartPC, PCReg); // We need to remember this instruction so we can later insert a call here. - // The problem is that up until now we don't know where our CPUState structure is. + // The problem is that up until now we don't know where our CPUState structure + // is. // After the translation we will and use this information to create a call to // a helper function. // TODO: we need a more elegant solution here @@ -778,8 +780,10 @@ void CodeGenerator::translate(uint64_t VirtualAddress) { break; } + default: Result = Translator.translate(&Instruction, PC, NextPC); + break; } switch (Result) { diff --git a/cpustateaccessanalysis.h b/cpustateaccessanalysis.h index 914a7ca9a..c26427a0e 100644 --- a/cpustateaccessanalysis.h +++ b/cpustateaccessanalysis.h @@ -232,4 +232,5 @@ public: public: bool runOnModule(llvm::Module &TheModule) override; }; -#endif + +#endif // _CPUSTATEACCESSANALYSIS_H diff --git a/dump.cpp b/dump.cpp index 64b6923ae..5fb8aa2f4 100644 --- a/dump.cpp +++ b/dump.cpp @@ -217,10 +217,8 @@ int main(int argc, const char *argv[]) { SMDiagnostic Err; std::unique_ptr TheModule; { - Callgrind DisableCallgrind(false); - TheModule = parseIRFile(Parameters.InputPath, - Err, - Context); + Callgrind DisableCallgrind(false); + TheModule = parseIRFile(Parameters.InputPath, Err, Context); } if (!TheModule) { diff --git a/generatedcodebasicinfo.h b/generatedcodebasicinfo.h index 2d5db2874..412ccaa37 100644 --- a/generatedcodebasicinfo.h +++ b/generatedcodebasicinfo.h @@ -189,11 +189,9 @@ public: assert(T != nullptr); for (llvm::BasicBlock *Successor : T->successors()) { - if (!(Successor == Dispatcher - || Successor == DispatcherFail - || Successor == AnyPC - || Successor == UnexpectedPC - || isJumpTarget(Successor))) + if (not(Successor == Dispatcher or Successor == DispatcherFail + or Successor == AnyPC or Successor == UnexpectedPC + or isJumpTarget(Successor))) return false; } @@ -204,10 +202,8 @@ public: /// /// Return false if \p BB is a dispatcher-related basic block. bool isTranslated(llvm::BasicBlock *BB) const { - return BB != Dispatcher - && BB != DispatcherFail - && BB != AnyPC - && BB != UnexpectedPC; + return (BB != Dispatcher and BB != DispatcherFail and BB != AnyPC + and BB != UnexpectedPC); } /// \brief Find the PC which lead to generated \p TheInstruction diff --git a/reachingdefinitions.cpp b/reachingdefinitions.cpp index 08f5eaf58..2b6e9389d 100644 --- a/reachingdefinitions.cpp +++ b/reachingdefinitions.cpp @@ -911,7 +911,7 @@ ConditionalBasicBlockInfo::propagateTo(ConditionalBasicBlockInfo &Target, for (int I = DefinitionConditions.find_first(); I != -1; I = DefinitionConditions.find_next(I)) { - // Make sure the target BBI knows about all the necessary conditinos + // Make sure the target BBI knows about all the necessary conditions assert(I < static_cast(SeenConditions.size())); unsigned Index = Target.getConditionIndex(SeenConditions[I]); unsigned OppositeIndex = Target.getConditionIndex(-SeenConditions[I]); diff --git a/revamb.h b/revamb.h index 39599ae48..fef6f32d2 100644 --- a/revamb.h +++ b/revamb.h @@ -19,6 +19,7 @@ // Local includes #include "ir-helpers.h" + namespace llvm { class GlobalVariable; }; @@ -72,6 +73,7 @@ enum class DebugInfoType { // TODO: move me to another header file /// \brief Classification of the various basic blocks we are creating enum BlockType { + // TODO: UntypedBlock is a bad name UntypedBlock, ///< A basic block generated during translation that it's not a /// jump target. DispatcherBlock, ///< Basic block representing the dispatcher. @@ -320,11 +322,13 @@ static inline T *notNull(T *Pointer) { } static const std::array MarkerFunctionNames = { - "newpc", - "function_call", - "exitTB" + { "newpc", "function_call", "exitTB" } }; +/// \brief Checks if \p I is a marker +/// +/// A marker a function call to an empty function acting as meta-information, +/// for example the `function_call` marker. static inline bool isMarker(llvm::Instruction *I) { using namespace std::placeholders; using llvm::any_of; diff --git a/valgrindhelpers.h b/valgrindhelpers.h index 7683b8532..c34a4f674 100644 --- a/valgrindhelpers.h +++ b/valgrindhelpers.h @@ -5,7 +5,6 @@ class Callgrind { public: - Callgrind(bool Enable) : Enabled(Enable) { if (Enabled) { CALLGRIND_START_INSTRUMENTATION;