mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 17:10:11 +01:00
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@lists.freedesktop.org>
This commit is contained in:
parent
ad542a10c5
commit
ddc77c5092
1 changed files with 20 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue