Skip to content

Commit 28e48fe

Browse files
author
Peter Goodman
authored
Removes some deprecated functions, and removes the basic block functi… (#569)
* Removes some deprecated functions, and removes the basic block function cloning apis, in favor of apis on Arch * More tweaks for removing unnecessary APIs * Goodbye dse * Fix issue * Tweaks * Remove some annoying logs
1 parent 93aba7c commit 28e48fe

File tree

29 files changed

+162
-2377
lines changed

29 files changed

+162
-2377
lines changed

bin/lift/Lift.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ int main(int argc, char *argv[]) {
270270
// Optimize the module, but with a particular focus on only the functions
271271
// that we actually lifted.
272272
remill::OptimizationGuide guide = {};
273-
guide.eliminate_dead_stores = true;
274273
remill::OptimizeModule(arch, module, manager.traces, guide);
275274

276275
// Create a new module in which we will move all the lifted functions. Prepare
@@ -422,7 +421,6 @@ int main(int argc, char *argv[]) {
422421

423422
guide.slp_vectorize = true;
424423
guide.loop_vectorize = true;
425-
guide.eliminate_dead_stores = false;
426424
remill::OptimizeBareModule(&dest_module, guide);
427425
}
428426

include/remill/Arch/Arch.h

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,27 @@ class Arch {
175175
// Returns the name of the program counter register.
176176
virtual std::string_view ProgramCounterRegisterName(void) const = 0;
177177

178+
// Create a lifted function declaration with name `name` inside of `module`.
179+
//
180+
// NOTE(pag): This should be called after `PrepareModule` and after the
181+
// semantics have been loaded.
182+
llvm::Function *DeclareLiftedFunction(std::string_view name,
183+
llvm::Module *module) const;
184+
185+
// Create a lifted function with name `name` inside of `module`.
186+
//
187+
// NOTE(pag): This should be called after `PrepareModule` and after the
188+
// semantics have been loaded.
189+
llvm::Function *DefineLiftedFunction(std::string_view name,
190+
llvm::Module *module) const;
191+
192+
// Initialize an empty lifted function with the default variables that it
193+
// should contain.
194+
void InitializeEmptyLiftedFunction(llvm::Function *func) const;
195+
178196
// Converts an LLVM module object to have the right triple / data layout
179-
// information for the target architecture and ensures remill required functions
180-
// have the appropriate prototype and internal variables
197+
// information for the target architecture and ensures remill required
198+
// functions have the appropriate prototype and internal variables
181199
void PrepareModule(llvm::Module *mod) const;
182200

183201
// Get the state pointer and various other types from the `llvm::LLVMContext`
@@ -293,9 +311,10 @@ class Arch {
293311
// Populate the table of register information.
294312
virtual void PopulateRegisterTable(void) const = 0;
295313

296-
// Populate the `__remill_basic_block` function with variables.
297-
virtual void PopulateBasicBlockFunction(llvm::Module *module,
298-
llvm::Function *bb_func) const = 0;
314+
// Populate a just-initialized lifted function function with architecture-
315+
// specific variables.
316+
virtual void FinishLiftedFunctionInitialization(
317+
llvm::Module *module, llvm::Function *bb_func) const = 0;
299318

300319
llvm::Triple BasicTriple(void) const;
301320

include/remill/Arch/Runtime/Intrinsics.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121

2222
extern "C" {
2323

24-
// The basic block "template".
25-
[[gnu::used]] Memory *__remill_basic_block(State &state, addr_t pc,
26-
Memory *memory);
27-
2824
// Memory read intrinsics.
2925
[[gnu::used, gnu::const]] extern uint8_t __remill_read_memory_8(Memory *,
3026
addr_t);

include/remill/Arch/X86/Runtime/State.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,7 @@ static_assert(96 == sizeof(AddressSpace),
689689

690690
// Named the same way as the 64-bit version to keep names the same
691691
// across architectures. All registers are here, even the 64-bit ones. The
692-
// 64-bit ones are inaccessible in lifted 32-bit code because they will
693-
// not be referenced by named variables in the `__remill_basic_block`
694-
// function.
692+
// 64-bit ones are not used in lifted 32-bit code.
695693
struct alignas(8) GPR final {
696694

697695
// Prevents LLVM from casting a `GPR` into an `i64` to access `rax`.

include/remill/BC/Annotate.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ static bool Remove(llvm::Function *func) {
114114
template <typename OriginType>
115115
static void Annotate(llvm::Function *func) {
116116
auto &C = func->getContext();
117-
DLOG(INFO) << "Annotating: " << func->getName().str() << ": "
118-
<< OriginType::metadata_kind << " -> "
119-
<< OriginType::metadata_value;
120117
auto node =
121118
llvm::MDNode::get(C, llvm::MDString::get(C, OriginType::metadata_value));
122119
func->setMetadata(OriginType::metadata_kind, node);

include/remill/BC/DeadStoreEliminator.h

Lines changed: 0 additions & 64 deletions
This file was deleted.

include/remill/BC/InstructionLifter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ class InstructionLifter {
8989
void ClearCache(void) const;
9090

9191
protected:
92-
friend class TraceLifter;
93-
9492
// Lift an operand to an instruction.
9593
virtual llvm::Value *LiftOperand(Instruction &inst, llvm::BasicBlock *block,
9694
llvm::Value *state_ptr, llvm::Argument *arg,
@@ -136,6 +134,8 @@ class InstructionLifter {
136134
std::string_view reg_name, llvm::ConstantInt *zero);
137135

138136
private:
137+
friend class TraceLifter;
138+
139139
InstructionLifter(const InstructionLifter &) = delete;
140140
InstructionLifter(InstructionLifter &&) noexcept = delete;
141141
InstructionLifter(void) = delete;

include/remill/BC/Lifter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 202 Trail of Bits, Inc.
2+
* Copyright (c) 2020 Trail of Bits, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

include/remill/BC/Optimizer.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ struct OptimizationGuide {
4646
bool loop_vectorize;
4747
bool verify_input;
4848
bool verify_output;
49-
bool eliminate_dead_stores;
5049
};
5150

5251
template <typename T>
@@ -165,11 +164,8 @@ inline static void OptimizeModule(const remill::Arch *arch,
165164
return OptimizeModule(arch, module, trace_func_gen, guide);
166165
}
167166

168-
// Optimize a normal module. This might not contain special functions
169-
// like `__remill_basic_block`.
170-
//
171-
// NOTE(pag): It is an error to specify `guide.eliminate_dead_stores` as
172-
// `true`.
167+
// Optimize a normal module. This might not contain special Remill-specific
168+
// intrinsics functions like `__remill_jump`, etc.
173169
void OptimizeBareModule(llvm::Module *module, OptimizationGuide guide = {});
174170

175171
inline static void

include/remill/BC/Util.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,6 @@ std::string FindSemanticsBitcodeFile(std::string_view arch);
177177
// Return a pointer to the Nth argument (N=0 is the first argument).
178178
llvm::Argument *NthArgument(llvm::Function *func, size_t index);
179179

180-
// Returns a pointer to the `__remill_basic_block` function.
181-
llvm::Function *BasicBlockFunction(llvm::Module *module);
182-
183-
// Return the type of a lifted function.
184-
//
185-
// NOTE(pag): Deprecated. Use `remill::Arch::LiftedFunctionType()` instead.
186-
llvm::FunctionType *LiftedFunctionType(llvm::Module *module)
187-
__attribute__((deprecated));
188-
189180
// Return a vector of arguments to pass to a lifted function, where the
190181
// arguments are derived from `block`.
191182
std::array<llvm::Value *, kNumBlockArgs>
@@ -200,28 +191,6 @@ using ISelCallback =
200191
std::function<void(llvm::GlobalVariable *, llvm::Function *)>;
201192
void ForEachISel(llvm::Module *module, ISelCallback callback);
202193

203-
// Declare a lifted function of the correct type.
204-
llvm::Function *DeclareLiftedFunction(llvm::Module *module,
205-
std::string_view name);
206-
207-
// Returns the type of a state pointer.
208-
//
209-
// NOTE(pag): Deprecated. Use `remill::Arch::StatePointerType()` instead.
210-
llvm::PointerType *StatePointerType(llvm::Module *module)
211-
__attribute__((deprecated));
212-
213-
// Returns the type of a state pointer.
214-
//
215-
// NOTE(pag): Deprecated. Use `remill::Arch::MemoryPointerType()` instead.
216-
llvm::PointerType *MemoryPointerType(llvm::Module *module)
217-
__attribute__((deprecated));
218-
219-
// Returns the type of an address (addr_t in the State.h).
220-
//
221-
// NOTE(pag): Deprecated. Use `remill::Arch::AddressType()` instead.
222-
llvm::IntegerType *AddressType(llvm::Module *module)
223-
__attribute__((deprecated));
224-
225194
using ValueMap = std::unordered_map<llvm::Value *, llvm::Value *>;
226195
using TypeMap = std::unordered_map<llvm::Type *, llvm::Type *>;
227196
using MDMap = std::unordered_map<llvm::Metadata *, llvm::Metadata *>;
@@ -242,9 +211,6 @@ void CloneFunctionInto(llvm::Function *source_func, llvm::Function *dest_func,
242211
// `source_func` into the module of `dest_func`.
243212
void CloneFunctionInto(llvm::Function *source_func, llvm::Function *dest_func);
244213

245-
// Make `func` a clone of the `__remill_basic_block` function.
246-
void CloneBlockFunctionInto(llvm::Function *func);
247-
248214
// Returns a list of callers of a specific function.
249215
std::vector<llvm::CallInst *> CallersOf(llvm::Function *func);
250216

0 commit comments

Comments
 (0)