-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc_codegen_ssa: turn builders "unpositioned" after emitting a terminator. #84771
Changes from 2 commits
2523a29
a297a5b
0b37b58
58402a9
ce953ec
78e2ac0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,14 +40,22 @@ pub trait BuilderMethods<'a, 'tcx>: | |
+ HasParamEnv<'tcx> | ||
+ HasTargetSpec | ||
{ | ||
/// IR builder (like `Self`) that doesn't have a set (insert) position, and | ||
/// cannot be used until positioned (which converted it to `Self`). | ||
// FIXME(eddyb) maybe move this associated type to a different trait, and/or | ||
// provide an `UnpositionedBuilderMethods` trait for operations involving it. | ||
type Unpositioned; | ||
|
||
fn unpositioned(cx: &'a Self::CodegenCx) -> Self::Unpositioned; | ||
fn position_at_end(bx: Self::Unpositioned, llbb: Self::BasicBlock) -> Self; | ||
fn into_unpositioned(self) -> Self::Unpositioned; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh it's only used there as a shorthand, the main usecase would be hopping between blocks in cg_ssa. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this hopping between blocks really needed? Can't a block be codegened all at once? That would be necessary once I switch cg_clif to use cg_ssa as cranelift's builder api requires terminating a block before you can switch to the next block. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (replied in #84771 (comment) to avoid losing it once I resolve this) |
||
|
||
fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::Function, name: &'b str) -> Self; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you plan to make this return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the next step I want to take is to rework how blocks are generated and reuse builders more, but I didn't want to cram too much into one PR at once. |
||
fn with_cx(cx: &'a Self::CodegenCx) -> Self; | ||
fn build_sibling_block(&self, name: &str) -> Self; | ||
fn cx(&self) -> &Self::CodegenCx; | ||
fn llbb(&self) -> Self::BasicBlock; | ||
fn set_span(&mut self, span: Span); | ||
|
||
fn position_at_end(&mut self, llbb: Self::BasicBlock); | ||
fn ret_void(&mut self); | ||
fn ret(&mut self, v: Self::Value); | ||
fn br(&mut self, dest: Self::BasicBlock); | ||
|
@@ -245,9 +253,8 @@ pub trait BuilderMethods<'a, 'tcx>: | |
&mut self, | ||
parent: Option<Self::Value>, | ||
unwind: Option<Self::BasicBlock>, | ||
num_handlers: usize, | ||
handlers: &[Self::BasicBlock], | ||
) -> Self::Value; | ||
fn add_handler(&mut self, catch_switch: Self::Value, handler: Self::BasicBlock); | ||
fn set_personality_fn(&mut self, personality: Self::Value); | ||
|
||
fn atomic_cmpxchg( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe its been a while since the lowest version of LLVM that we support supports catchswitch (it was introduced in, like, 3.8 or something). This and the
Option
in the return value can be removed entirely, I think.