gcc源代码分析,expand_call()函数和printf(Hello, world!\n);的关系

2024-01-02 22:58

本文主要是介绍gcc源代码分析,expand_call()函数和printf(Hello, world!\n);的关系,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

expand_call()函数在expr.c文件中。

下面是expand_call()函数的主要调试结果,记录之。

主要是加入了debug_tree()函数和debug_rtx()函数。

debug_tree()函数加入到了expand_expr()函数的开始。

debug_rtx()函数加入到了gen_rtx()函数的结束处。

emit_call_1()函数是何时调用的也能看出。emit_call_insn()是何时调用的也能看出。

主要的调试目的是expand_call()函数是如何生成rtx的?

既是如何一步步调用,在哪里调用gen_rtx()函数的?

当然只是针对hello.c文件中的:

printf("Hello, world!\n");

这一函数调用来分析的。


call_expr

expand_call
expand_expr code = 71
 <nop_expr 830d8
    type <pointer_type 9017c
        type <integer_type 90130 char readonly permanent QI
            size <integer_cst 81638 literal permanent 1
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 81608 literal permanent -128 precision 8 min <integer_cst 81608 -128>
            max <integer_cst 81620 literal permanent 127
            pointer_to_this <pointer_type 9017c>
        permanent unsigned SI
        size <integer_cst 8154c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        chain <function_type 902c0>
    literal
    arg 0 <nop_expr 830c0
        type <pointer_type 87a44 type <integer_type 815bc char>
            permanent unsigned SI size <integer_cst 8154c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
            chain <array_type 87a90>
        literal
        arg 0 <addr_expr 830a8 type <pointer_type 93f58>
            literal
            arg 0 <string_cst 83014 type <array_type 93ef4>
                static literal "Hello, world!
"
expand_expr code = 71
 <nop_expr 830c0
    type <pointer_type 87a44
        type <integer_type 815bc char permanent QI
            size <integer_cst 81638 literal permanent 1
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 81608 literal permanent -128 precision 8 min <integer_cst 81608 -128>
            max <integer_cst 81620 literal permanent 127
            pointer_to_this <pointer_type 87a44> chain <integer_type 816a8 long int>
        permanent unsigned SI
        size <integer_cst 8154c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        chain <array_type 87a90>
    literal
    arg 0 <addr_expr 830a8
        type <pointer_type 93f58 type <array_type 93ef4>
            unsigned SI size <integer_cst 8154c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
        literal
        arg 0 <string_cst 83014 type <array_type 93ef4>
            static literal "Hello, world!
"
expand_expr code = 74
 <addr_expr 830a8
    type <pointer_type 93f58
        type <array_type 93ef4 type <integer_type 815bc char>
            BLK
            size <integer_cst 93f40 literal 15
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 81638 literal permanent 1 domain <integer_type 93ea8>
            pointer_to_this <pointer_type 93f58> chain <pointer_type 93f58>
        unsigned SI
        size <integer_cst 8154c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
    literal
    arg 0 <string_cst 83014 type <array_type 93ef4>
        static literal "Hello, world!
"
expand_expr code = 26
 <string_cst 83014
    type <array_type 93ef4
        type <integer_type 815bc char permanent QI
            size <integer_cst 81638 literal permanent 1
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 81608 literal permanent -128 precision 8 min <integer_cst 81608 -128>
            max <integer_cst 81620 literal permanent 127
            pointer_to_this <pointer_type 87a44> chain <integer_type 816a8 long int>
        BLK
        size <integer_cst 93f40 literal 15
        align 8 size_unit 8 sep_unit 8 symtab 0 sep <integer_cst 81638 1>
        domain <integer_type 93ea8 SI
            size <integer_cst 8154c literal permanent 4
            align 32 size_unit 8 sep_unit 32 symtab 0
            sep <integer_cst 83048 literal 0 precision 32 min <integer_cst 83048 0>
            max <integer_cst 83078 literal 14
        pointer_to_this <pointer_type 93f58> chain <pointer_type 93f58>
    static literal "Hello, world!
"
output_constant_def

(symbol_ref:SI ("*LC0"))

(mem:BLK (symbol_ref:SI ("*LC0")))
this this
addr_expr
force_operand 27
end addr_expr

(pre_dec:SI (reg:SI 7))

(mem:SI (pre_dec:SI (reg:SI 7)))

(set (mem:SI (pre_dec:SI (reg:SI 7)))
   (symbol_ref:SI ("*LC0")))

(insn_list 6 (nil))

(insn_list 2 (insn_list 6 (nil)))

(sequence[ ] )

(reg:SI 0)

(const_int 4)
emit_call_1 funexp symbol_ref

(mem:QI (symbol_ref/v:SI ("printf")))

(call (mem:QI (symbol_ref/v:SI ("printf")))
   (const_int 4))

(set (reg:SI 0)
   (call (mem:QI (symbol_ref/v:SI ("printf")))
       (const_int 4)))
emit_call_insn
end expand_call
c_expand_return

这篇关于gcc源代码分析,expand_call()函数和printf(Hello, world!\n);的关系的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/563884

相关文章

Springboot中分析SQL性能的两种方式详解

《Springboot中分析SQL性能的两种方式详解》文章介绍了SQL性能分析的两种方式:MyBatis-Plus性能分析插件和p6spy框架,MyBatis-Plus插件配置简单,适用于开发和测试环... 目录SQL性能分析的两种方式:功能介绍实现方式:实现步骤:SQL性能分析的两种方式:功能介绍记录

Python itertools中accumulate函数用法及使用运用详细讲解

《Pythonitertools中accumulate函数用法及使用运用详细讲解》:本文主要介绍Python的itertools库中的accumulate函数,该函数可以计算累积和或通过指定函数... 目录1.1前言:1.2定义:1.3衍生用法:1.3Leetcode的实际运用:总结 1.1前言:本文将详

最长公共子序列问题的深度分析与Java实现方式

《最长公共子序列问题的深度分析与Java实现方式》本文详细介绍了最长公共子序列(LCS)问题,包括其概念、暴力解法、动态规划解法,并提供了Java代码实现,暴力解法虽然简单,但在大数据处理中效率较低,... 目录最长公共子序列问题概述问题理解与示例分析暴力解法思路与示例代码动态规划解法DP 表的构建与意义动

轻松上手MYSQL之JSON函数实现高效数据查询与操作

《轻松上手MYSQL之JSON函数实现高效数据查询与操作》:本文主要介绍轻松上手MYSQL之JSON函数实现高效数据查询与操作的相关资料,MySQL提供了多个JSON函数,用于处理和查询JSON数... 目录一、jsON_EXTRACT 提取指定数据二、JSON_UNQUOTE 取消双引号三、JSON_KE

MySQL数据库函数之JSON_EXTRACT示例代码

《MySQL数据库函数之JSON_EXTRACT示例代码》:本文主要介绍MySQL数据库函数之JSON_EXTRACT的相关资料,JSON_EXTRACT()函数用于从JSON文档中提取值,支持对... 目录前言基本语法路径表达式示例示例 1: 提取简单值示例 2: 提取嵌套值示例 3: 提取数组中的值注意

C#使用DeepSeek API实现自然语言处理,文本分类和情感分析

《C#使用DeepSeekAPI实现自然语言处理,文本分类和情感分析》在C#中使用DeepSeekAPI可以实现多种功能,例如自然语言处理、文本分类、情感分析等,本文主要为大家介绍了具体实现步骤,... 目录准备工作文本生成文本分类问答系统代码生成翻译功能文本摘要文本校对图像描述生成总结在C#中使用Deep

Linux编译器--gcc/g++使用方式

《Linux编译器--gcc/g++使用方式》文章主要介绍了C/C++程序的编译过程,包括预编译、编译、汇编和链接四个阶段,并详细解释了每个阶段的作用和具体操作,同时,还介绍了调试和发布版本的概念... 目录一、预编译指令1.1预处理功能1.2指令1.3问题扩展二、编译(生成汇编)三、汇编(生成二进制机器语

MYSQL关联关系查询方式

《MYSQL关联关系查询方式》文章详细介绍了MySQL中如何使用内连接和左外连接进行表的关联查询,并展示了如何选择列和使用别名,文章还提供了一些关于查询优化的建议,并鼓励读者参考和支持脚本之家... 目录mysql关联关系查询关联关系查询这个查询做了以下几件事MySQL自关联查询总结MYSQL关联关系查询

Java function函数式接口的使用方法与实例

《Javafunction函数式接口的使用方法与实例》:本文主要介绍Javafunction函数式接口的使用方法与实例,函数式接口如一支未完成的诗篇,用Lambda表达式作韵脚,将代码的机械美感... 目录引言-当代码遇见诗性一、函数式接口的生物学解构1.1 函数式接口的基因密码1.2 六大核心接口的形态学

Redis主从/哨兵机制原理分析

《Redis主从/哨兵机制原理分析》本文介绍了Redis的主从复制和哨兵机制,主从复制实现了数据的热备份和负载均衡,而哨兵机制可以监控Redis集群,实现自动故障转移,哨兵机制通过监控、下线、选举和故... 目录一、主从复制1.1 什么是主从复制1.2 主从复制的作用1.3 主从复制原理1.3.1 全量复制