如何在linux上内联string.h函数?

我想优化一些代码,以便string.h中的所有函数都被内联。我在x86_64上。 我试过-O3,-minline-all-stringops,当我做“nm a.out”时,它表明它正在调用glibc版本。 用gcc -S检查,我看到了这些电话。 我错过了什么? string.h中有几十个#ifdef _SOME_SETTING_,而bits / string3.h显示了内联版本,但我不知道如何到达那里。 例如:
$ cat test.c
#include <string.h>

main() {
    char *a, *b;
    strcpy(b,a);
}
/*

When compiled with:

gcc -minline-all-stringops -O6 -I. -S -o test.S test.c

Produces:

    .file   "test.c"
    .text
    .p2align 4,,15
.globl main
    .type   main, @function
main:
.LFB12:
    .cfi_startproc
    subq    $8, %rsp
    .cfi_def_cfa_offset 16
    xorl    %esi, %esi
    xorl    %edi, %edi
    call    strcpy
    addq    $8, %rsp
    .cfi_def_cfa_offset 8
    ret
    .cfi_endproc
.LFE12:
    .size   main, .-main
    .ident  "GCC: (GNU) 4.5.1 20100924 (Red Hat 4.5.1-4)"
    .section    .note.GNU-stack,"",@progbits
*/
    
已邀请:
如果函数实现不在头文件和单独的编译单元中,则除非您有可以执行LTCG的编译器,否则不能内联它。 听起来你需要自己编写实现。     

要回复问题请先登录注册