@@ -1565,9 +1565,17 @@ extern "C" LLVMValueRef LLVMRustBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst,
15651565 unsigned SrcAlign,
15661566 LLVMValueRef Size,
15671567 bool IsVolatile) {
1568- return wrap (unwrap (B)->CreateMemCpy (unwrap (Dst), MaybeAlign (DstAlign),
1569- unwrap (Src), MaybeAlign (SrcAlign),
1570- unwrap (Size), IsVolatile));
1568+ if (unwrap (B)->GetInsertBlock ()->getParent ()->hasFnAttribute (" no-builtins" ) ||
1569+ unwrap (B)->GetInsertBlock ()->getParent ()->hasFnAttribute (
1570+ " no-builtin-memcpy" )) {
1571+ return wrap (unwrap (B)->CreateMemCpyInline (unwrap (Dst), MaybeAlign (DstAlign),
1572+ unwrap (Src), MaybeAlign (SrcAlign),
1573+ unwrap (Size), IsVolatile));
1574+ } else {
1575+ return wrap (unwrap (B)->CreateMemCpy (unwrap (Dst), MaybeAlign (DstAlign),
1576+ unwrap (Src), MaybeAlign (SrcAlign),
1577+ unwrap (Size), IsVolatile));
1578+ }
15711579}
15721580
15731581extern " C" LLVMValueRef
@@ -1583,8 +1591,16 @@ extern "C" LLVMValueRef LLVMRustBuildMemSet(LLVMBuilderRef B, LLVMValueRef Dst,
15831591 unsigned DstAlign, LLVMValueRef Val,
15841592 LLVMValueRef Size,
15851593 bool IsVolatile) {
1586- return wrap (unwrap (B)->CreateMemSet (unwrap (Dst), unwrap (Val), unwrap (Size),
1587- MaybeAlign (DstAlign), IsVolatile));
1594+ if (unwrap (B)->GetInsertBlock ()->getParent ()->hasFnAttribute (" no-builtins" ) ||
1595+ unwrap (B)->GetInsertBlock ()->getParent ()->hasFnAttribute (
1596+ " no-builtin-memset" )) {
1597+ return wrap (unwrap (B)->CreateMemSetInline (unwrap (Dst), MaybeAlign (DstAlign),
1598+ unwrap (Val), unwrap (Size),
1599+ IsVolatile));
1600+ } else {
1601+ return wrap (unwrap (B)->CreateMemSet (unwrap (Dst), unwrap (Val), unwrap (Size),
1602+ MaybeAlign (DstAlign), IsVolatile));
1603+ }
15881604}
15891605
15901606// Polyfill for `LLVMBuildCallBr`, which was added in LLVM 19.
0 commit comments