大脚趾头疼是什么原因| Years什么意思| 利可君片是治什么病| 诺诗兰属于什么档次| 朋友搬家送什么礼物好| 二级医院是什么意思| 十月九号什么星座| 牙龈肿痛吃什么药最见效| 嬴政和芈月是什么关系| 热射病是什么症状| 芥末油是什么提炼出来的| 暹什么意思| 舌头上有齿痕是什么原因| 舌头溃疡用什么药| 什么是理数| 特警属于什么编制| 虚张声势是什么生肖| 直率是什么意思| 做梦梦见出车祸是什么征兆| 怕金病帕金森是什么症状| 11月30号什么星座| 全虫是什么中药| 得过且过什么意思| 什么时候量血压最准确| 湖水蓝是什么颜色| 云南什么族| 怀孕前壁和后壁有什么区别| 来月经前有什么症状| 250为什么是骂人的话| sage是什么颜色| 杜仲有什么作用| 黄腔是什么意思| 比熊吃什么牌子的狗粮好| 毒龙是什么意思啊| 麦乳精是什么| 北方五行属什么| 什么是高脂血症| 梦见蛇蛋是什么意思啊| 三昧什么意思| 武则天叫什么名字| 号召是什么意思| 男生什么情况想种草莓| 看肛门挂什么科| 强肉弱食是什么意思| 下午两点属于什么时辰| 什么是正月| 眼皮发肿是什么原因| 孩子鼻子出血什么原因造成的| b型钠尿肽高说明什么| 狐臭是什么人种的后代| 淋巴结是什么引起的| 自怨自艾是什么意思| 小便发黄什么原因| 男人阴虚吃什么药最好| 汪字五行属什么| 奕什么意思| 双乳增生什么意思| 贵妃是什么意思| 干咳挂什么科| 支气管炎咳嗽吃什么药好得快| 敲木鱼是什么意思| 葡萄糖为什么叫葡萄糖| 软下疳是什么症状| 不胜感激是什么意思| 出来混迟早要还的什么意思| 酉鬼念什么| 什么什么多彩| tp什么意思| 厦门房价为什么那么高| 博物馆里有什么| 甲虫吃什么| 宫颈柱状上皮异位是什么意思| 婚检查什么| 肝郁吃什么食物好| 眼皮肿是什么原因| 什么什么不平| 宫颈活检cin1级是什么意思| 试管进周期是什么意思| 裹小脚是什么时候开始的| 什么首阔步| 柳字五行属什么| 什么什么不舍| 阿华田是什么饮料| 被电击后身体会有什么后遗症| 木鱼是什么意思| 什么是人工智能| z世代是什么意思| 吴亦凡为什么退出exo| 间断性是什么意思| 肌钙蛋白高是什么意思| 月经头疼是什么原因| 人设崩塌是什么意思| 飞鸟集讲的是什么| 上皮细胞高是什么原因| 找对象什么最重要| 什么石头最值钱| 第一次同房是什么感觉| 晕车吃什么药| slc是什么意思| 斯文败类是什么意思| 手总是发麻是什么原因| 秘诀是什么意思| MECT是什么| 蜂王浆什么时间吃最好| 蠕动什么意思| 营长是什么军衔| 糖粉和白糖有什么区别| 生意是什么意思| 胃痉挛是什么症状| 白带增多是什么原因| 梦见刺猬是什么意思| 建档挂什么科| 喝什么解酒| 颈椎病有什么特效药| 鳞状上皮增生什么意思| 话唠是什么意思| 3月14日是什么星座| 梦到掉头发是什么意思| 大脚趾头疼是什么原因| 为什么生气会胃疼| 刚愎自用是什么意思| 龟头瘙痒是什么原因| 牙齿吃甜的就会疼什么原因| 前列腺在什么地方| captain是什么意思| 一班三检是指什么| 6月24日什么星座| 痔疮是什么样的图片| 什么是断掌| 手掌纹路多且杂乱是为什么| 网络绿茶是什么意思| 皮肤病用什么药膏好| 什么叫尿毒症| 羊肠小道什么意思| 生冷辛辣指的是什么| 送哥们什么礼物好| 行政管理是做什么的| 中暑发烧吃什么药| 大舅哥是什么意思| 叶绿素是什么| 心肌酶高是什么意思| 涧是什么意思| 元旦北京有什么好玩的| 胃看什么科室| 开业送什么礼物好| 小孩上火了吃什么降火最快| 蟑螂有什么危害| 99足银是什么意思| 小猫咪能吃什么| GOLF是什么品牌| 尿检4个加号什么意思| 送奶奶什么礼物好| 1963年发生了什么| 七夕送什么礼物好| examine什么意思| 老年痴呆症挂什么科| 眼压高滴什么眼药水| 女人梦见老鼠什么征兆| 舌苔开裂是什么原因呢| 拉肚子适合吃什么| 今年22岁属什么| 君山银针属于什么茶| 铁剂不能和什么一起吃| 风湿病是什么引起的| 维生素c补什么| 想什么| 胸部dr是什么| 一什么柳树| 封建思想是什么意思| 喝什么睡眠效果最好| lo是什么意思| 安吉白茶属于什么茶| 女性长期缺维d会带来什么病| 阴道里面长什么样| 土鳖吃什么| 阴沟肠杆菌是什么病| 故事是什么意思| 双鱼座有什么特点| 看心理医生挂什么科| 万能受血者是什么血型| 大小脸是什么原因造成的| 黄鼠狼进屋是什么兆头| 什么腿| 马叉虫是什么意思| 产后腰疼是什么原因| 糖耐筛查主要检查什么| 时光荏苒的意思是什么| 中华田园犬为什么禁养| 儿童发烧挂什么科| 宫外孕破裂有什么症状| 板鞋配什么裤子好看| 囧是什么意思| 抗缪勒氏管激素是检查什么的| 喝什么饮料对身体好| 网球大满贯什么意思| 皮脂腺囊肿吃什么消炎药| 加德纳菌阳性是什么意思| 心脏跳的慢吃什么好| 项羽为什么会失败| 什么海翻江| 上将是什么级别| bbox是什么意思| 跑完步喝什么水最好| 老年人吃什么增强免疫力| 喝什么睡眠效果最好| 舌苔黄腻是什么原因| 逼长什么样| 星五行属性是什么| 脾胃湿热吃什么药好| 三点水者念什么意思| 什么是靶向药| 乳房疼挂什么科室| 手掌发紫是什么原因| 双鱼座的幸运石是什么| 什么是义眼| 睡醒后口苦是什么原因| 肠道功能紊乱吃什么药效果好| 周期性是什么意思| may是什么意思| 雪人是什么生肖| 什么疾什么快| 肩周炎吃什么药好得快| 产后屁多是什么原因| 慢性浅表性胃炎是什么意思| 潇字五行属什么| 什么的事物| 口腔溃疡挂什么科就诊| 血清胃功能检测是什么| 小郡肝是什么部位| 桃花什么季节开| 腋下疼痛挂什么科| 多五行属什么| 财五行属什么| 太阳穴疼什么原因| 颈椎退行性变是什么意思| 肛门里面痒是什么情况| 步步为营是什么意思| 冰箱冷藏室结冰是什么原因| 狂犬疫苗打在什么部位| 中国最大的湖泊是什么湖| 附属国是什么意思| 查激素挂什么科| 撕脱性骨折是什么意思| 为什么会高血压| 美国全称是什么| 蛋白粉有什么功效| 铁杵是什么| 梦见在水里游泳是什么意思| 瑛字五行属什么| 锦鲤跳缸是什么原因| 试商是什么意思| 宸字五行属什么| 风邪是什么意思| 17点到19点是什么时辰| 眼睛充血用什么药| nsnm什么意思| 没有什么| 值神是什么意思| 孕妇胆固醇高对胎儿有什么影响| 什么是心脏造影| 回阳救逆什么意思| 预包装食品指的是什么| 中班小朋友应该学什么| 你真狗是什么意思| 百度Jump to content

特斯拉现金储备或不足5个月 专家称马斯克盈利信心来自中国

From Wikipedia, the free encyclopedia
Some CFG examples:
(a) an if-then-else
(b) a while loop
(c) a natural loop with two exits, e.g. while with an if...break in the middle; non-structured but reducible
(d) an irreducible CFG: a loop with two entry points, e.g. goto into a while or for loop
A control-flow graph used by the Rust compiler to perform codegen.
百度 下学人人可能,只要下学,便已在上达路上了。

In computer science, a control-flow graph (CFG) is a representation, using graph notation, of all paths that might be traversed through a program during its execution. The control-flow graph was conceived by Frances E. Allen,[1] who noted that Reese T. Prosser used boolean connectivity matrices for flow analysis before.[2]

The CFG is essential to many compiler optimizations and static-analysis tools.

Definition

[edit]

In a control-flow graph each node in the graph represents a basic block, i.e. a straight-line sequence of code with a single entry point and a single exit point, where no branches or jumps occur within the block. Basic blocks start with jump targets and end with jumps or branch instructions. Directed edges are used to represent jumps in the control flow. There are, in most presentations, two specially designated blocks: the entry block, through which control enters into the flow graph, and the exit block, through which all control flow leaves.[3]

Because of its construction procedure, in a CFG, every edge A→B has the property that:

outdegree(A) > 1 or indegree(B) > 1 (or both).[4]

The CFG can thus be obtained, at least conceptually, by starting from the program's (full) flow graph—i.e. the graph in which every node represents an individual instruction—and performing an edge contraction for every edge that falsifies the predicate above, i.e. contracting every edge whose source has a single exit and whose destination has a single entry. This contraction-based algorithm is of no practical importance, except as a visualization aid for understanding the CFG construction, because the CFG can be more efficiently constructed directly from the program by scanning it for basic blocks.[4]

Example

[edit]

Consider the following fragment of code:

0: (A) t0 = read_num
1: (A) if t0 mod 2 == 0
2: (B)     print t0 + " is even."
3: (B)     goto 5
4: (C) print t0 + " is odd."
5: (D) end program

In the above, we have 4 basic blocks: A from 0 to 1, B from 2 to 3, C at 4 and D at 5. In particular, in this case, A is the "entry block", D the "exit block" and lines 4 and 5 are jump targets. A graph for this fragment has edges from A to B, A to C, B to D and C to D.

Reachability

[edit]

Reachability is a graph property useful in optimization.

If a subgraph is not connected from the subgraph containing the entry block, that subgraph is unreachable during any execution, and so is unreachable code; under normal conditions it can be safely removed.

If the exit block is unreachable from the entry block, an infinite loop may exist. Not all infinite loops are detectable, see Halting problem. A halting order may also exist there.

Unreachable code and infinite loops are possible even if the programmer does not explicitly code them: optimizations like constant propagation and constant folding followed by jump threading can collapse multiple basic blocks into one, cause edges to be removed from a CFG, etc., thus possibly disconnecting parts of the graph.

Domination relationship

[edit]

A block M dominates a block N if every path from the entry that reaches block N has to pass through block M. The entry block dominates all blocks.

In the reverse direction, block M postdominates block N if every path from N to the exit has to pass through block M. The exit block postdominates all blocks.

It is said that a block M immediately dominates block N if M dominates N, and there is no intervening block P such that M dominates P and P dominates N. In other words, M is the last dominator on all paths from entry to N. Each block has a unique immediate dominator.

Similarly, there is a notion of immediate postdominator, analogous to immediate dominator.

The dominator tree is an ancillary data structure depicting the dominator relationships. There is an arc from Block M to Block N if M is an immediate dominator of N. This graph is a tree, since each block has a unique immediate dominator. This tree is rooted at the entry block. The dominator tree can be calculated efficiently using Lengauer–Tarjan's algorithm.

A postdominator tree is analogous to the dominator tree. This tree is rooted at the exit block.

Special edges

[edit]

A back edge is an edge that points to a block that has already been met during a depth-first (DFS) traversal of the graph. Back edges are typical of loops.

A critical edge is an edge which is neither the only edge leaving its source block, nor the only edge entering its destination block. These edges must be split: a new block must be created in the middle of the edge, in order to insert computations on the edge without affecting any other edges.

An abnormal edge is an edge whose destination is unknown. Exception handling constructs can produce them. These edges tend to inhibit optimization.

An impossible edge (also known as a fake edge) is an edge which has been added to the graph solely to preserve the property that the exit block postdominates all blocks. It cannot ever be traversed.

Loop management

[edit]

A loop header (sometimes called the entry point of the loop) is a dominator that is the target of a loop-forming back edge. The loop header dominates all blocks in the loop body. A block may be a loop header for more than one loop. A loop may have multiple entry points, in which case it has no "loop header".

Suppose block M is a dominator with several incoming edges, some of them being back edges (so M is a loop header). It is advantageous to several optimization passes to break M up into two blocks Mpre and Mloop. The contents of M and back edges are moved to Mloop, the rest of the edges are moved to point into Mpre, and a new edge from Mpre to Mloop is inserted (so that Mpre is the immediate dominator of Mloop). In the beginning, Mpre would be empty, but passes like loop-invariant code motion could populate it. Mpre is called the loop pre-header, and Mloop would be the loop header.

Reducibility

[edit]

A reducible CFG is one with edges that can be partitioned into two disjoint sets: forward edges, and back edges, such that:[5]

Structured programming languages are often designed such that all CFGs they produce are reducible, and common structured programming statements such as IF, FOR, WHILE, BREAK, and CONTINUE produce reducible graphs. To produce irreducible graphs, statements, such as GOTO, are needed. Irreducible CFGs can be produced by some compiler optimizations, such as tail call elimination. Many loop optimizations require reducible CFGs. In order to convert a irreducible CFG into a reducible CFG, either nodes must be duplicated or variables must be introduced. GOTO statements can sometimes produce reducible control flow graphs.

Loop connectedness

[edit]

The loop connectedness of a CFG is defined with respect to a given depth-first search tree (DFST) of the CFG. This DFST should be rooted at the start node and cover every node of the CFG.

Edges in the CFG which run from a node to one of its DFST ancestors (including itself) are called back edges.

The loop connectedness is the largest number of back edges found in any cycle-free path of the CFG. In a reducible CFG, the loop connectedness is independent of the DFST chosen.[6][7]

Loop connectedness has been used to reason about the time complexity of data-flow analysis.[6]

Inter-procedural control-flow graph

[edit]

While control-flow graphs represent the control flow of a single procedure, inter-procedural control-flow graphs represent the control flow of whole programs.[8]

See also

[edit]

References

[edit]
  1. ^ Frances E. Allen (July 1970). "Control flow analysis". SIGPLAN Notices. 5 (7): 1–19. doi:10.1145/390013.808479.
  2. ^ Reese T. Prosser (1959). "Applications of Boolean matrices to the analysis of flow diagrams". Papers presented at the December 1–3, 1959, eastern joint IRE-AIEE-ACM computer conference. pp. 133–138. doi:10.1145/1460299.1460314.
  3. ^ Yousefi, Javad (2015). "Masking wrong-successor Control Flow Errors employing data redundancy". 2015 5th International Conference on Computer and Knowledge Engineering (ICCKE). IEEE. pp. 201–205. doi:10.1109/ICCKE.2015.7365827. ISBN 978-1-4673-9280-8.
  4. ^ a b Peri L. Tarr; Alexander L. Wolf (2011). Engineering of Software: The Continuing Contributions of Leon J. Osterweil. Springer Science & Business Media. p. 58. ISBN 978-3-642-19823-6.
  5. ^ "Archived copy" (PDF). Archived from the original (PDF) on 2025-08-06. Retrieved 2025-08-06.{{cite web}}: CS1 maint: archived copy as title (link)
  6. ^ a b Kam, John B.; Ullman, Jeffrey D. (2025-08-06). "Global Data Flow Analysis and Iterative Algorithms". Journal of the ACM. 23 (1): 158–171. doi:10.1145/321921.321938. ISSN 0004-5411. S2CID 162375.
  7. ^ Offner, Carl. "Notes on Graph Algorithms Used in Optimizing Compilers" (PDF). Archived (PDF) from the original on 2025-08-06. Retrieved 13 April 2018.
  8. ^ "Control Flow Analysis" (PDF). 2016. Archived (PDF) from the original on 2025-08-06.
[edit]
Examples
肩膜炎的症状是什么 尿后余沥是什么意思 亚撒西什么意思 千钧一发是什么生肖 诺如病毒吃什么药
幽闭是什么意思 五月七号是什么星座 什么品牌的床好 led是什么意思 物理压榨油是什么意思
缘木求鱼什么意思 三是什么意思 二手房是什么意思 贫血看什么科 什么男什么女的成语
什么是流水 痛风吃什么食物 拉格啤酒是什么意思 qn医学上是什么意思 佟丽娅是什么民族
流加金念什么hcv9jop7ns2r.cn ha是什么单位hcv8jop9ns1r.cn 刷牙时牙龈出血是什么原因hcv8jop2ns8r.cn 瞬息万变什么意思hcv8jop9ns6r.cn 木兮是什么意思hcv9jop4ns8r.cn
生酮是什么fenrenren.com 女生自慰什么感觉chuanglingweilai.com 五行是什么意思hcv8jop5ns3r.cn 江浙沪是什么意思hcv9jop1ns1r.cn 7号来的月经什么时候是排卵期hcv9jop7ns1r.cn
情非得已是什么生肖hcv9jop4ns6r.cn 吞咽困难是什么原因hcv7jop5ns2r.cn 手淫多了有什么危害shenchushe.com 肺部肿瘤不能吃什么hcv9jop7ns2r.cn fdg是什么意思hcv8jop3ns7r.cn
接见是什么意思hcv9jop5ns6r.cn 台湾为什么叫4vhcv7jop9ns9r.cn 手背有痣代表什么意思hcv8jop7ns9r.cn 水痘通过什么途径传染hcv7jop4ns7r.cn 光顾是什么意思hcv8jop4ns1r.cn
百度