[Bf-blender-cvs] [8259f921104] functions: don't cache llvm type per context

Jacques Lucke noreply at git.blender.org
Thu Mar 28 17:51:02 CET 2019


Commit: 8259f921104f509b162f3cfbe3c948ef8f387e8f
Author: Jacques Lucke
Date:   Thu Mar 28 17:48:41 2019 +0100
Branches: functions
https://developer.blender.org/rB8259f921104f509b162f3cfbe3c948ef8f387e8f

don't cache llvm type per context

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

M	source/blender/functions/backends/llvm/llvm_types.cpp
M	source/blender/functions/backends/llvm/llvm_types.hpp
M	source/blender/functions/types/boolean.cpp

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

diff --git a/source/blender/functions/backends/llvm/llvm_types.cpp b/source/blender/functions/backends/llvm/llvm_types.cpp
index 3a67b003ded..a5cf8e31abc 100644
--- a/source/blender/functions/backends/llvm/llvm_types.cpp
+++ b/source/blender/functions/backends/llvm/llvm_types.cpp
@@ -6,37 +6,6 @@ namespace FN {
 
 	BLI_COMPOSITION_IMPLEMENTATION(LLVMTypeInfo);
 
-	llvm::Type *LLVMTypeInfo::get_type(
-		llvm::LLVMContext &context) const
-	{
-		this->ensure_type_exists_for_context(context);
-		return m_type_per_context.lookup(&context);
-	}
-
-	llvm::Type *LLVMTypeInfo::get_type_ptr(
-		llvm::LLVMContext &context) const
-	{
-		return this->get_type(context)->getPointerTo();
-	}
-
-	void LLVMTypeInfo::ensure_type_exists_for_context(llvm::LLVMContext &context) const
-	{
-		if (m_type_per_context.contains(&context)) {
-			return;
-		}
-
-		std::lock_guard<std::mutex> lock(m_type_per_context_mutex);
-
-		if (m_type_per_context.contains(&context)) {
-			return;
-		}
-
-		llvm::Type *type = this->create_type(context);
-		BLI_assert(type);
-		m_type_per_context.add(&context, type);
-		BLI_assert(m_type_per_context.contains(&context));
-	}
-
 
 	/******************** SimpleLLVMTypeInfo ********************/
 
diff --git a/source/blender/functions/backends/llvm/llvm_types.hpp b/source/blender/functions/backends/llvm/llvm_types.hpp
index a2ab6821051..0b1121a3b50 100644
--- a/source/blender/functions/backends/llvm/llvm_types.hpp
+++ b/source/blender/functions/backends/llvm/llvm_types.hpp
@@ -15,11 +15,8 @@ namespace FN {
 
 		virtual ~LLVMTypeInfo() {}
 
-		llvm::Type *get_type(
-			llvm::LLVMContext &context) const;
-
-		llvm::Type *get_type_ptr(
-			llvm::LLVMContext &context) const;
+		virtual llvm::Type *get_type(
+			llvm::LLVMContext &context) const = 0;
 
 		virtual llvm::Value *build_copy_ir(
 			CodeBuilder &builder,
@@ -41,15 +38,6 @@ namespace FN {
 		virtual llvm::Value *build_load_ir__relocate(
 			CodeBuilder &builder,
 			llvm::Value *byte_addr) const = 0;
-
-	private:
-		mutable SmallMap<llvm::LLVMContext *, llvm::Type *> m_type_per_context;
-		mutable std::mutex m_type_per_context_mutex;
-
-		void ensure_type_exists_for_context(llvm::LLVMContext &context) const;
-
-		virtual llvm::Type *create_type(
-			llvm::LLVMContext &context) const = 0;
 	};
 
 	class SimpleLLVMTypeInfo : public LLVMTypeInfo {
@@ -57,15 +45,15 @@ namespace FN {
 		typedef std::function<llvm::Type *(llvm::LLVMContext &context)> CreateFunc;
 		CreateFunc m_create_func;
 
-		llvm::Type *create_type(llvm::LLVMContext &context) const override
-		{
-			return m_create_func(context);
-		}
-
 	public:
 		SimpleLLVMTypeInfo(CreateFunc create_func)
 			: m_create_func(create_func) {}
 
+		llvm::Type *get_type(llvm::LLVMContext &context) const override
+		{
+			return m_create_func(context);
+		}
+
 		llvm::Value *build_copy_ir(
 			CodeBuilder &builder,
 			llvm::Value *value) const override;
@@ -98,11 +86,6 @@ namespace FN {
 		FreeFunc m_free_func;
 		DefaultFunc m_default_func;
 
-		llvm::Type *create_type(llvm::LLVMContext &context) const override
-		{
-			return llvm::Type::getVoidTy(context)->getPointerTo();
-		}
-
 		static void *copy_value(PointerLLVMTypeInfo *info, void *value);
 		static void free_value(PointerLLVMTypeInfo *info, void *value);
 		static void *default_value(PointerLLVMTypeInfo *info);
@@ -113,6 +96,11 @@ namespace FN {
 			  m_free_func(free_func),
 			  m_default_func(default_func) {}
 
+		llvm::Type *get_type(llvm::LLVMContext &context) const override
+		{
+			return llvm::Type::getVoidTy(context)->getPointerTo();
+		}
+
 		llvm::Value *build_copy_ir(
 			CodeBuilder &builder,
 			llvm::Value *value) const override;
diff --git a/source/blender/functions/types/boolean.cpp b/source/blender/functions/types/boolean.cpp
index 00a82b6d3ea..08d1fce4c70 100644
--- a/source/blender/functions/types/boolean.cpp
+++ b/source/blender/functions/types/boolean.cpp
@@ -9,7 +9,7 @@ namespace FN { namespace Types {
 
 	class LLVMBool : public LLVMTypeInfo {
 
-		llvm::Type *create_type(
+		llvm::Type *get_type(
 			llvm::LLVMContext &context) const override
 		{
 			return llvm::Type::getInt1Ty(context);



More information about the Bf-blender-cvs mailing list