-
Notifications
You must be signed in to change notification settings - Fork 61
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
builder::do_not_inline #87
Comments
Mind if I take this? I think the best way is to add this function: void gcc_jit_function_add_attribute(gcc_jit_function *func, const char *attr); And apply |
I already have a gcc branch locally and a codegen branch locally adding support for the inline attribute. |
I pushed a PR in gcc with early support for inlining. The codegen part was pushed in a branch (now having an unrelated history, sorry :) ) there. |
I've just realized that this is actually telling a function call to not be inlined, not the function itself. Two ideas (requiring a change in the API):
|
Some quick reseach suggests that it might be false: Here's how this method defined in LLVM backend: fn do_not_inline(&mut self, llret: &'ll Value) {
llvm::Attribute::NoInline.apply_callsite(llvm::AttributePlace::Function, llret);
}
// impl Attribute
pub fn apply_callsite(&self, idx: AttributePlace, callsite: &Value) {
unsafe { LLVMRustAddCallSiteAttribute(callsite, idx.as_uint(), *self) }
}
impl AttributePlace {
pub fn as_uint(self) -> c_uint {
match self {
AttributePlace::ReturnValue => 0,
AttributePlace::Argument(i) => 1 + i,
AttributePlace::Function => !0,
}
}
} extern "C" void LLVMRustAddCallSiteAttribute(LLVMValueRef Instr, unsigned Index,
LLVMRustAttribute RustAttr) {
CallBase *Call = unwrap<CallBase>(Instr);
Attribute Attr = Attribute::get(Call->getContext(), fromRust(RustAttr));
Call->AddAttributeAtIndex(Index, Attr);
} The trick here is the Anyway, I don't think a pointer call is a good idea. It may be inlined anyway in some circumstances, and it wastes a register. The wrapper option looks better to me. You can even attribute it with |
This method is only called for one thing: to prevent exponential inlining of drop glue in landing pads, see rust-lang/rust#41696 and rust-lang/rust#41920 Even though this looks LLVM specific, I suspect GCC may suffer from this issue as well. Anyway, it'll be a while before we get to unwind support, so for now I'll get back to crashing |
To be honest, I might start working on landing pads soon, as it seems most UI tests that fail are because they're not implemented. |
No description provided.
The text was updated successfully, but these errors were encountered: