From d264d0dc2713e9093076a613a8032fed3b572377 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 13 Nov 2013 18:52:14 -0800 Subject: [PATCH] radeon/compute: Unconditionally inline all functions We need to do this until function calls are supported. --- src/gallium/drivers/radeon/radeon_llvm_util.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c b/src/gallium/drivers/radeon/radeon_llvm_util.c index 7192dee..02a11b5 100644 --- a/src/gallium/drivers/radeon/radeon_llvm_util.c +++ b/src/gallium/drivers/radeon/radeon_llvm_util.c @@ -30,6 +30,7 @@ #include #include #include +#include #include LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode, @@ -58,9 +59,28 @@ 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; + LLVMValueRef last_fn = LLVMGetLastFunction(mod); + for (fn = LLVMGetFirstFunction(mod); fn != last_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); -- 1.8.1.4