Skip to main content

DEPRECATED_LLVM_INTRINSIC

Static DEPRECATED_LLVM_INTRINSIC 

Source
pub static DEPRECATED_LLVM_INTRINSIC: &'static Lint
Expand description

The deprecated_llvm_intrinsic lint detects usage of deprecated LLVM intrinsics.

§Example

#![cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#![feature(link_llvm_intrinsics, abi_unadjusted)]
#![deny(deprecated_llvm_intrinsic)]

unsafe extern "unadjusted" {
    #[link_name = "llvm.x86.addcarryx.u32"]
    fn foo(a: u8, b: u32, c: u32, d: &mut u32) -> u8;
}

#[inline(never)]
#[target_feature(enable = "adx")]
pub fn bar(a: u8, b: u32, c: u32, d: &mut u32) -> u8 {
    unsafe { foo(a, b, c, d) }
}

This will produce:

error: Using deprecated intrinsic `llvm.x86.addcarryx.u32`
 --> example.rs:7:5
  |
7 |     fn foo(a: u8, b: u32, c: u32, d: &mut u32) -> u8;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |

§Explanation

LLVM periodically updates its list of intrinsics. Deprecated intrinsics are unlikely to be removed, but they may optimize less well than their new versions, so it’s best to use the new version. Also, some deprecated intrinsics might have buggy behavior.

This link_llvm_intrinsics lint is intended to be used internally only, and requires the #![feature(link_llvm_intrinsics)] internal feature gate. For more information, see its chapter in the Unstable Book and its tracking issue.