diff --git a/include/revng/RemoveLiftingArtifacts/PromoteInitCSVToUndef.h b/include/revng/RemoveLiftingArtifacts/PromoteInitCSVToUndef.h new file mode 100644 index 000000000..57d2df31e --- /dev/null +++ b/include/revng/RemoveLiftingArtifacts/PromoteInitCSVToUndef.h @@ -0,0 +1,33 @@ +#pragma once + +// +// This file is distributed under the MIT License. See LICENSE.md for details. +// + +#include "revng/Model/NameBuilder.h" +#include "revng/Pipebox/Helpers.h" +#include "revng/PipeboxCommon/Helpers/PipeRuns/LLVMFunctionMixin.h" +#include "revng/PipeboxCommon/LLVMContainer.h" +#include "revng/PipeboxCommon/Model.h" + +namespace revng::pypeline::piperuns { + +class PromoteInitCSVToUndef : public LLVMFunctionMixin { +private: + const model::Binary &Binary; + +public: + static constexpr llvm::StringRef Name = "promote-init-csv-to-undef"; + using Arguments = SingleLLVMFunctionsArgument; + + PromoteInitCSVToUndef(const class Model &Model, + llvm::StringRef Config, + llvm::StringRef DynamicConfig, + LLVMFunctionContainer &ModuleContainer) : + LLVMFunctionMixin(ModuleContainer), Binary(*Model.get().get()){}; + + void runOnLLVMFunction(const model::Function &Function, + llvm::Function &LLVMFunction); +}; + +} // namespace revng::pypeline::piperuns diff --git a/lib/Pipebox/Pipebox.cpp b/lib/Pipebox/Pipebox.cpp index 449803c6c..fb31fb661 100644 --- a/lib/Pipebox/Pipebox.cpp +++ b/lib/Pipebox/Pipebox.cpp @@ -19,6 +19,7 @@ #include "revng/PipeboxCommon/RawContainer.h" #include "revng/Recompile/CompileModulePipe.h" #include "revng/Recompile/LinkForTranslationPipe.h" +#include "revng/RemoveLiftingArtifacts/PromoteInitCSVToUndef.h" #include "revng/RemoveLiftingArtifacts/RemoveLiftingArtifacts.h" #include "revng/Yield/HexDump.h" #include "revng/Yield/Pipes/ProcessAssembly.h" @@ -68,6 +69,7 @@ static RegisterSingleOutputPipeRun P15; static RegisterSingleOutputPipeRun P16; static RegisterSingleOutputPipeRun P17; static RegisterFunctionPipeRun P18; +static RegisterFunctionPipeRun P19; // // Analyses diff --git a/lib/RemoveLiftingArtifacts/PromoteInitCSVToUndef.cpp b/lib/RemoveLiftingArtifacts/PromoteInitCSVToUndef.cpp index 87b736104..eab3fcba1 100644 --- a/lib/RemoveLiftingArtifacts/PromoteInitCSVToUndef.cpp +++ b/lib/RemoveLiftingArtifacts/PromoteInitCSVToUndef.cpp @@ -11,6 +11,7 @@ #include "revng/Model/LoadModelPass.h" #include "revng/Model/NamedTypedRegister.h" #include "revng/Model/Register.h" +#include "revng/RemoveLiftingArtifacts/PromoteInitCSVToUndef.h" #include "revng/Support/IRHelpers.h" using namespace llvm; @@ -90,3 +91,12 @@ static constexpr const char *Flag = "promote-init-csv-to-undef"; using Reg = RegisterPass; static Reg X(Flag, "Promotes calls to revng_undefined_* functions for CSV to undefs"); + +namespace revng::pypeline::piperuns { + +void PromoteInitCSVToUndef::runOnLLVMFunction(const model::Function &Function, + llvm::Function &LLVMFunction) { + undefPreservedRegistersInitialization(LLVMFunction, Function, Binary); +} + +} // namespace revng::pypeline::piperuns