Skip to content

Commit

Permalink
Don't abort compilation for LLVM hint functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ltratt committed Jan 26, 2025
1 parent 01349d5 commit c42bc99
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions ykrt/src/compile/jitc_yk/codegen/x64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,9 +1499,15 @@ impl<'a> Assemble<'a> {
.collect::<Vec<_>>();

// unwrap safe on account of linker symbol names not containing internal NULL bytes.
let va = symbol_to_ptr(self.m.func_decl(func_decl_idx).name())
.map_err(|e| CompilationError::General(e.to_string()))?;
self.emit_call(iidx, fty, Some(va), None, &args)
match self.m.func_decl(func_decl_idx).name() {
"llvm.assume" => Ok(()),
"llvm.lifetime.start.p0" => Ok(()),
"llvm.lifetime.end.p0" => Ok(()),
x => {
let va = symbol_to_ptr(x).map_err(|e| CompilationError::General(e.to_string()))?;
self.emit_call(iidx, fty, Some(va), None, &args)
}
}
}

/// Codegen a indirect call.
Expand Down Expand Up @@ -3865,6 +3871,34 @@ mod tests {
);
}

#[test]
fn cg_call_hints() {
codegen_and_test(
"
func_decl llvm.assume (i1)
func_decl llvm.lifetime.start.p0 (i64, ptr)
func_decl llvm.lifetime.end.p0 (i64, ptr)
entry:
%0: i1 = param 0
%1: ptr = param 1
call @llvm.assume(%0)
call @llvm.lifetime.start.p0(16i64, %1)
call @llvm.lifetime.end.p0(16i64, %1)
%5: ptr = ptr_add %1, 1
black_box %5
",
"
...
; call @llvm.assume(%0)
; call @llvm.lifetime.start.p0(16i64, %1)
; call @llvm.lifetime.end.p0(16i64, %1)
; %5: ...
...
",
false,
);
}

#[test]
fn cg_eq() {
codegen_and_test(
Expand Down

0 comments on commit c42bc99

Please sign in to comment.