From 3f69581d03ca4974ae6c6d3a7f1a58a1f4050aba Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 25 Jan 2018 17:11:13 -0800 Subject: [PATCH] cretonne::Context: add for_function constructor --- lib/cretonne/src/context.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/cretonne/src/context.rs b/lib/cretonne/src/context.rs index 221481a039..8aff5aa706 100644 --- a/lib/cretonne/src/context.rs +++ b/lib/cretonne/src/context.rs @@ -49,8 +49,16 @@ impl Context { /// The returned instance should be reused for compiling multiple functions in order to avoid /// needless allocator thrashing. pub fn new() -> Self { + Context::for_function(Function::new()) + } + + /// Allocate a new compilation context with an existing Function. + /// + /// The returned instance should be reused for compiling multiple functions in order to avoid + /// needless allocator thrashing. + pub fn for_function(func: Function) -> Self { Self { - func: Function::new(), + func: func, cfg: ControlFlowGraph::new(), domtree: DominatorTree::new(), regalloc: regalloc::Context::new(),