[Bf-blender-cvs] [cdda6bd] object_nodes: Fix module linking: initialize the node graph module right away to avoid repeating code.

Lukas Tönne noreply at git.blender.org
Thu May 19 19:29:35 CEST 2016


Commit: cdda6bd19a9948731261518ee3c4f4e6eb9910eb
Author: Lukas Tönne
Date:   Thu May 19 18:34:08 2016 +0200
Branches: object_nodes
https://developer.blender.org/rBcdda6bd19a9948731261518ee3c4f4e6eb9910eb

Fix module linking: initialize the node graph module right away to avoid repeating code.

===================================================================

M	source/blender/blenvm/llvm/llvm_codegen.cc

===================================================================

diff --git a/source/blender/blenvm/llvm/llvm_codegen.cc b/source/blender/blenvm/llvm/llvm_codegen.cc
index 0fc0940..a6d4694 100644
--- a/source/blender/blenvm/llvm/llvm_codegen.cc
+++ b/source/blender/blenvm/llvm/llvm_codegen.cc
@@ -64,7 +64,23 @@ llvm::LLVMContext &LLVMCompilerBase::context() const
 
 void LLVMCompilerBase::create_module(const string &name)
 {
+	using namespace llvm;
+	
+	std::string error;
+	
+	/* make sure the node base functions are defined */
+	if (get_nodes_module() == NULL) {
+		Module *nodes_mod = define_nodes_module();
+		set_nodes_module(nodes_mod);
+	}
+	
+	/* create an empty module */
 	m_module = new llvm::Module(name, context());
+	
+	/* link the node functions module, so we can call those functions */
+	Linker::LinkModules(module(), get_nodes_module(), Linker::LinkerMode::PreserveSource, &error);
+	
+	verifyModule(*module(), &outs());
 }
 
 void LLVMCompilerBase::destroy_module()
@@ -746,18 +762,8 @@ FunctionLLVM *LLVMCompiler::compile_function(const string &name, const NodeGraph
 {
 	using namespace llvm;
 	
-	std::string error;
-	
 	create_module(name);
 	
-	if (get_nodes_module() == NULL) {
-		Module *nodes_mod = define_nodes_module();
-		set_nodes_module(nodes_mod);
-	}
-	Linker::LinkModules(module(), get_nodes_module(), Linker::LinkerMode::PreserveSource, &error);
-	
-	verifyModule(*module(), &outs());
-	
 	Function *func = codegen_node_function(name, graph);
 	BLI_assert(module()->getFunction(name) && "Function not registered in module!");
 	BLI_assert(func != NULL && "codegen_node_function returned NULL!");
@@ -823,7 +829,6 @@ void DebugLLVMCompiler::compile_function(const string &name, const NodeGraph &gr
 	using namespace llvm;
 	
 	create_module(name);
-	llvm_link_module_full(module());
 	
 	Function *func = codegen_node_function(name, graph);
 	BLI_assert(module()->getFunction(name) && "Function not registered in module!");




More information about the Bf-blender-cvs mailing list