Mesa (10.0): radeon/compute: Unconditionally inline all functions v2

Ian Romanick idr at kemper.freedesktop.org
Wed Nov 27 06:16:23 UTC 2013


Module: Mesa
Branch: 10.0
Commit: bab6f40b29e77d00bf3dbc898c3547470fe3a4fe
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bab6f40b29e77d00bf3dbc898c3547470fe3a4fe

Author: Tom Stellard <thomas.stellard at amd.com>
Date:   Wed Nov 13 18:52:14 2013 -0800

radeon/compute: Unconditionally inline all functions v2

We need to do this until function calls are supported.

v2:
  - Fix loop conditional

https://bugs.freedesktop.org/show_bug.cgi?id=64225

CC: "10.0" <mesa-stable at lists.freedesktop.org>
(cherry picked from commit ddc77c5092b6f782327a7014b320f31f5f4e8e93)

---

 src/gallium/drivers/radeon/radeon_llvm_util.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c b/src/gallium/drivers/radeon/radeon_llvm_util.c
index f2b3e13..3ba0acc 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_util.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_util.c
@@ -30,6 +30,7 @@
 #include <llvm-c/BitReader.h>
 #include <llvm-c/Core.h>
 #include <llvm-c/Target.h>
+#include <llvm-c/Transforms/IPO.h>
 #include <llvm-c/Transforms/PassManagerBuilder.h>
 
 LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode,
@@ -59,9 +60,26 @@ static void radeon_llvm_optimize(LLVMModuleRef mod)
 	LLVMTargetDataRef TD = LLVMCreateTargetData(data_layout);
 	LLVMPassManagerBuilderRef builder = LLVMPassManagerBuilderCreate();
 	LLVMPassManagerRef pass_manager = LLVMCreatePassManager();
-	LLVMAddTargetData(TD, pass_manager);
 
-	LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 1000000000);
+	/* Functions calls are not supported yet, so we need to inline
+	 * everything.  The most efficient way to do this is to add
+	 * the always_inline attribute to all non-kernel functions
+	 * and then run the Always Inline pass.  The Always Inline
+	 * pass will automaically inline functions with this attribute
+	 * and does not perform the expensive cost analysis that the normal
+	 * inliner does.
+	 */
+
+	LLVMValueRef fn;
+	for (fn = LLVMGetFirstFunction(mod); fn; fn = LLVMGetNextFunction(fn)) {
+		/* All the non-kernel functions have internal linkage */
+		if (LLVMGetLinkage(fn) == LLVMInternalLinkage) {
+			LLVMAddFunctionAttr(fn, LLVMAlwaysInlineAttribute);
+		}
+	}
+
+	LLVMAddTargetData(TD, pass_manager);
+	LLVMAddAlwaysInlinerPass(pass_manager);
 	LLVMPassManagerBuilderPopulateModulePassManager(builder, pass_manager);
 
 	LLVMRunPassManager(pass_manager, mod);




More information about the mesa-commit mailing list