<div dir="ltr">Hi Dean<div><br></div><div>Thank you very much for you very quick reply. I am still a little bit confused and below is some of my questions.</div><div><br></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">In LLVM, basic blocks can contain function calls. This allows partial and/or full code inlining.</span></div><div>=======</div><div>So the reason why basic blocks can contain function calls is because of code inlining?<br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">The control flow graph (CFG) referred to in LLVM passes only include the LLVM basic blocks inside a function. In LLVM, only tail-call exits are considered terminator instructions (and thus will delineate the basic block boundaries).</span></div><div>=======</div><div>If so, the control flow graph generated with opt -dot-cfg should not be the real control flow graph. Because LLVM doesn't think function call is a jump, thus the control flow graph is not accurate. Can I say like this? Or any option to help me to split a basic block in LLVM into several real basic blocks.<br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:14px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">If you want to see function-call graphs, you may want to look at CallGraphSCCPass instead of FunctionPass.</span><br></div><div><span style="font-size:14px">======</span></div><div><span style="font-size:14px">What does function-call graphs mean? Does it mean the callgraph? Many Thanks</span></div><div><span style="font-size:14px"><br></span></div><div><span style="font-size:14px">Regards</span></div><div><span style="font-size:14px">Muhui</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-05-29 20:50 GMT+08:00 Dean Michael Berris <span dir="ltr"><<a href="mailto:dean.berris@gmail.com" target="_blank">dean.berris@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
> On 29 May 2018, at 22:40, Muhui Jiang via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> <br>
> Hi <br>
> <br>
> Sorry, that the previous email is sent out before I complete it due to my mistake. Please read this<br>
> <br>
> I am using the LLVM function pass to help me to do code analysis. However, I found that the block LLVM identified will ignore the function call.<br>
> <br>
> For example, the below IR should not be a basic block. <br>
> <br>
> <br>
>   %call17 = call i32* @__errno_location() #14, !dbg !1384<br>
>   %18 = load i32, i32* %call17, align 4, !dbg !1384<br>
>   %19 = load i8*, i8** %dest_dirname, align 4, !dbg !1386<br>
>   call void (i32, i32, i8*, ...) @error(i32 1, i32 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.389, i32 0, i    32 0), i8* %19), !dbg !1387<br>
>   br label %if.end18, !dbg !1388<br>
> <br>
> The corresponding binary i s below<br>
> <br>
> .text:0001A530                 BL      __errno_location<br>
> .text:0001A534                 LDR     R1, [R0]        ; errnum<br>
> .text:0001A538                 LDR     R3, [SP,#0x100+var_100]<br>
> .text:0001A53C                 LDR     R2, =aS_1       ; "%s"<br>
> .text:0001A540                 MOV     R0, #1          ; status<br>
> .text:0001A544                 BL      error<br>
> .text:0001A548                 B       loc_1A54C<br>
> <br>
> Here you can see it obviously should not be a basic block because you called two functions! So the control flow graph LLVM generated is also not the real control flow graph, right? Do anyone know why or give me some suggestions?<br>
> <br>
<br>
</span>In LLVM, basic blocks can contain function calls. This allows partial and/or full code inlining.<br>
<br>
The control flow graph (CFG) referred to in LLVM passes only include the LLVM basic blocks inside a function. In LLVM, only tail-call exits are considered terminator instructions (and thus will delineate the basic block boundaries).<br>
<br>
If you want to see function-call graphs, you may want to look at CallGraphSCCPass instead of FunctionPass.<br>
<br>
<a href="http://llvm.org/docs/WritingAnLLVMPass.html#the-callgraphsccpass-class" rel="noreferrer" target="_blank">http://llvm.org/docs/<wbr>WritingAnLLVMPass.html#the-<wbr>callgraphsccpass-class</a><br>
<br>
Cheers<br>
<span class="HOEnZb"><font color="#888888"><br>
-- Dean<br>
<br>
</font></span></blockquote></div><br></div>