diff --git a/ykllvm b/ykllvm index 31a6707ce..ebd46c345 160000 --- a/ykllvm +++ b/ykllvm @@ -1 +1 @@ -Subproject commit 31a6707ce76f218b7612239ede3db4081a769621 +Subproject commit ebd46c345e22f094a5e42e92a8187400a33262bc diff --git a/ykrt/src/mt.rs b/ykrt/src/mt.rs index 7cf168567..6a5f9425f 100644 --- a/ykrt/src/mt.rs +++ b/ykrt/src/mt.rs @@ -1345,6 +1345,24 @@ impl MTThread { true } + /// Records `val` as a value to be promoted. Returns `true` if either: no trace is being + /// recorded; or recording the promotion succeeded. + /// + /// If `false` is returned, the current trace is unable to record the promotion successfully + /// and further calls are probably pointless, though they will not cause the tracer to enter + /// undefined behaviour territory. + /// + /// # Panics + /// + /// If the stack is empty. There should always be at least one element on the stack, so a panic + /// here means that something has gone wrong elsewhere. + pub(crate) fn promote_i8(&mut self, val: i8) -> bool { + if let MTThreadState::Tracing { promotions, .. } = self.peek_mut_tstate() { + promotions.push(val.cast_unsigned()); + } + true + } + /// Records `val` as a value to be promoted. Returns `true` if either: no trace is being /// recorded; or recording the promotion succeeded. /// diff --git a/ykrt/src/promote.rs b/ykrt/src/promote.rs index 8e524c812..3ffed5b0f 100644 --- a/ykrt/src/promote.rs +++ b/ykrt/src/promote.rs @@ -92,3 +92,15 @@ pub extern "C" fn __yk_idempotent_promote_i32(val: i32) -> i32 { } val } + +/// Records an 8-bit return value of an idempotent function during trace recording. +#[unsafe(no_mangle)] +pub extern "C" fn __yk_idempotent_promote_i8(val: i8) -> i8 { + if MTThread::is_tracing() { + MTThread::with_borrow_mut(|mtt| { + // We ignore the return value as we can't really cancel tracing from this function. + mtt.promote_i8(val); + }); + } + val +}