From c42bc99683cdaf964bf9e9e45523cf210471a528 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Sun, 26 Jan 2025 09:00:59 +0000 Subject: [PATCH] Don't abort compilation for LLVM hint functions. --- ykrt/src/compile/jitc_yk/codegen/x64/mod.rs | 40 +++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/ykrt/src/compile/jitc_yk/codegen/x64/mod.rs b/ykrt/src/compile/jitc_yk/codegen/x64/mod.rs index 6eb49899a..9d9c16aa5 100644 --- a/ykrt/src/compile/jitc_yk/codegen/x64/mod.rs +++ b/ykrt/src/compile/jitc_yk/codegen/x64/mod.rs @@ -1499,9 +1499,15 @@ impl<'a> Assemble<'a> { .collect::>(); // 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. @@ -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(