-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CODEGEN][LLVM] Cache packed func ptr, lift alloca #2070
Conversation
trying to understand how lifting could prevent allocating memory repeatedly? |
@tqchen The patch solves my problem, thanks a lot!
Check cache and then call it. Line 345 and so on.
Before this patch, we just call for search the function in the hashtable repeatedly
But I am not sure why the error does disappear. |
This is the compound of two problems: Here is the pseudo code of old code: void* packed_handle = nullptr;
int myfunc() {
for (int i = 0; i < n; ++i) {
alloca out;
GetFuncFromEnv(ctx, "name_of_func", &out);
CallFunc(out, ...);
}
} After the fix, it becomes void* packed_handle = nullptr;
int myfunc() {
// lift aloca
alloca out;
for (int i = 0; i < n; ++i) {
if (packed_handle == nullptr) {
GetFuncFromEnv(ctx, "name_of_func", &out);
// store the pointer
packed_handle = out;
}
CallFunc(packed_handle, ...);
}
}
But since both are actually problems, so this PR fixes both. |
This PR resolves to problems revealed by #2067, thanks to @denis0x0D.