static void radeon_llvm_optimize(LLVMModuleRef mod) { const char *data_layout = LLVMGetDataLayout(mod); LLVMTargetDataRef TD = LLVMCreateTargetData(data_layout); LLVMPassManagerBuilderRef builder = LLVMPassManagerBuilderCreate(); LLVMPassManagerRef pass_manager = LLVMCreatePassManager(); /* 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); LLVMPassManagerBuilderDispose(builder); LLVMDisposePassManager(pass_manager); LLVMDisposeTargetData(TD); }
SWIGEXPORT void JNICALL Java_org_jllvm_bindings_IPOJNI_LLVMAddAlwaysInlinerPass(JNIEnv *jenv, jclass jcls, jlong jarg1) { LLVMPassManagerRef arg1 = (LLVMPassManagerRef) 0 ; (void)jenv; (void)jcls; arg1 = *(LLVMPassManagerRef *)&jarg1; LLVMAddAlwaysInlinerPass(arg1); }