llir-opt
0.0.1
Low-Level Post-Link Optimiser for OCaml and C
|
9 #include <unordered_map>
12 #include "core/adt/id.h"
13 #include "passes/pre_eval/symbolic_object.h"
14 #include "passes/pre_eval/symbolic_frame.h"
32 < std::forward_iterator_tag
38 std::vector<unsigned>::const_reverse_iterator it,
45 bool operator==(
const frame_iterator &that)
const {
return it_ == that.it_; }
46 bool operator!=(
const frame_iterator &that)
const {
return !(*
this == that); }
62 SymbolicFrame &operator*()
const {
return ctx_->frames_[*it_]; }
67 std::vector<unsigned>::const_reverse_iterator it_;
75 , std::unique_ptr<SymbolicObject>
81 , ObjectMap::const_iterator
82 , std::random_access_iterator_tag
87 : iterator_adaptor_base(it)
91 SymbolicObject &operator*()
const {
return *this->I->second.get(); }
120 unsigned EnterFrame(
Func &func, llvm::ArrayRef<SymbolicValue> args);
122 unsigned EnterFrame(llvm::ArrayRef<std::optional<unsigned>> objects);
143 SymbolicPointer::Ref
Pointer(
Atom &atom, int64_t offset);
145 SymbolicPointer::Ref
Pointer(
unsigned frame,
unsigned object, int64_t offset);
168 SymbolicPointer::Ref
Malloc(CallSite &site, std::optional<unsigned> size);
185 frame_iterator frame_end()
187 return frame_iterator(activeFrames_.rend(),
this);
189 llvm::iterator_range<frame_iterator> frames()
191 return llvm::make_range(
frame_begin(), frame_end());
196 object_iterator object_end() {
return object_iterator(objects_.end()); }
197 llvm::iterator_range<object_iterator> objects()
223 std::shared_ptr<DAGFunc>
230 std::vector<SymbolicFrame> frames_;
232 std::vector<unsigned> activeFrames_;
234 std::optional<SymbolicValue> extern_;
Definition: symbolic_context.h:28
Definition: symbolic_pointer.h:270
Definition: symbolic_value.h:24
SymbolicObject & GetFrame(unsigned frame, unsigned object)
Returns a frame object to store to.
Definition: symbolic_context.h:137
~SymbolicContext()
Cleanup.
Definition: symbolic_context.cpp:43
Definition: symbolic_object.h:26
void LeaveFrame(Func &func)
Pop a stack frame for a function from the heap.
Definition: symbolic_context.cpp:137
std::set< SymbolicFrame * > GetFrames(Func &func)
Return all the frames used to execute a function.
Definition: symbolic_context.cpp:657
Iterator over objects.
Definition: symbolic_context.h:79
void LeaveRoot()
Pop the root frame.
Definition: symbolic_context.cpp:151
Definition: symbolic_summary.h:17
SymbolicPointer::Ref Malloc(CallSite &site, std::optional< unsigned > size)
Definition: symbolic_context.cpp:499
const SymbolicFrame * GetActiveFrame() const
Return the top frame.
Definition: symbolic_context.h:111
object_iterator object_begin()
Iterator over objects.
Definition: symbolic_context.h:195
unsigned GetNumArgs() const
Returns the number of arguments.
Definition: symbolic_frame.h:97
SymbolicFrame * GetActiveFrame()
Return the top frame.
Definition: symbolic_context.cpp:48
Iterator over active frames.
Definition: symbolic_context.h:31
unsigned EnterFrame(Func &func, llvm::ArrayRef< SymbolicValue > args)
Push a stack frame for a function to the heap.
Definition: symbolic_context.cpp:68
SymbolicContext(SymbolicHeap &heap, SymbolicSummary &state)
Creates a new heap using values specified in the data segments.
Definition: symbolic_context.h:97
Definition: symbolic_frame.h:29
bool Store(const SymbolicPointer &addr, const SymbolicValue &val, Type type)
Definition: symbolic_context.cpp:374
DAGFunc & GetSCCFunc(Func &func)
Return the SCC version of a function.
Definition: symbolic_context.cpp:58
void Merge(const SymbolicContext &that)
Definition: symbolic_context.cpp:629
frame_iterator frame_begin()
Iterator over active frames.
Definition: symbolic_context.h:181
SymbolicPointer::Ref Pointer(Atom &atom, int64_t offset)
Create a pointer to an atom.
Definition: symbolic_context.cpp:332
bool HasFrame(Func &func)
Checks if a function is already on the stack.
Definition: symbolic_context.cpp:161
std::unordered_map< ID< SymbolicObject >, std::unique_ptr< SymbolicObject > > ObjectMap
Mapping from objects to their representation.
Definition: symbolic_context.h:76
SymbolicObject & GetObject(ID< SymbolicObject > object)
Returns the model for an object.
Definition: symbolic_context.cpp:355
SymbolicValue Load(const SymbolicPointer &addr, Type type)
Definition: symbolic_context.cpp:448
unsigned GetNumArgs() const
Return the number of arguments in the topmost frame.
Definition: symbolic_context.h:117
void Taint(const SymbolicValue &taint, const SymbolicValue &tainted)
Record a tainted value, propagating information along the call stack.
Definition: symbolic_context.cpp:172
Definition: symbolic_heap.h:21