<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:11pt;">
<div>Hi,</div>
<div> </div>
<div>Found CloneBasicBlock utility only does the cloning without any remapping.</div>
<div> </div>
<div>Consider below example:</div>
<div> </div>
<div><b><u>Input block:</u></b></div>
<div>sw.epilog:                                        ; preds = %sw.bb20, %sw.bb15, %sw.bb10, %sw.bb6, %sw.bb2, %sw.bb, %while.body, %if.end29</div>
<div>  %no_final.1 = phi i32 [ %no_final.055, %while.body ], [ 1, %if.end29 ], [ %no_final.055, %sw.bb20 ], [ %no_final.055, %sw.bb15 ], [ %no_final.055, %sw.bb10 ], [ %no_final.055, %sw.bb6 ], [ %no_final.055, %sw.bb2 ], [ %no_final.055, %sw.bb ]</div>
<div>  %locinput.1 = phi i8* [ %locinput.057, %while.body ], [ %incdec.ptr, %if.end29 ], [ %locinput.057, %sw.bb20 ], [ %locinput.057, %sw.bb15 ], [ %locinput.057, %sw.bb10 ], [ %locinput.057, %sw.bb6 ], [ %locinput.057, %sw.bb2 ], [ %locinput.057, %sw.bb ]</div>
<div>  %next30 = getelementptr inbounds %struct.Node, %struct.Node* %scan.056, i64 0, i32 0, !dbg !91</div>
<div>  %8 = load %struct.Node*, %struct.Node** %next30, align 8, !dbg !91, !tbaa !92</div>
<div>  tail call void @llvm.dbg.value(metadata %struct.Node* %8, i64 0, metadata !28, metadata !34), !dbg !41</div>
<div>  %cmp = icmp eq %struct.Node* %8, null, !dbg !52</div>
<div>  br i1 %cmp, label %no_silent.loopexit, label %while.body, !dbg !54</div>
<div> </div>
<div><b><u>Clone Block:</u></b></div>
<div>sw.epilog.jl:                                     ; No predecessors!</div>
<div>  %no_final.1.jl = phi i32 [ %no_final.055, %while.body ], [ 1, %if.end29 ], [ %no_final.055, %sw.bb20 ], [ %no_final.055, %sw.bb15 ], [ %no_final.055, %sw.bb10 ], [ %no_final.055, %sw.bb6 ], [ %no_final.055, %sw.bb2 ], [ %no_final.055, %sw.bb ]</div>
<div>  %locinput.1.jl = phi i8* [ %locinput.057, %while.body ], [ %incdec.ptr, %if.end29 ], [ %locinput.057, %sw.bb20 ], [ %locinput.057, %sw.bb15 ], [ %locinput.057, %sw.bb10 ], [ %locinput.057, %sw.bb6 ], [ %locinput.057, %sw.bb2 ], [ %locinput.057, %sw.bb
]</div>
<div>  %next30.jl = getelementptr inbounds %struct.Node, %struct.Node* %scan.056, i64 0, i32 0, !dbg !91</div>
<div>  <span style="background-color:silver;">%9 = load %struct.Node*, %struct.Node** </span><font color="red"><span style="background-color:silver;">%next30</span></font><span style="background-color:silver;">, align 8, !dbg !91, !tbaa !92</span></div>
<div>  tail call void @llvm.dbg.value(metadata %struct.Node* %8, i64 0, metadata !28, metadata !34), !dbg !41</div>
<div>  <span style="background-color:silver;">%cmp.jl = icmp eq %struct.Node* </span><font color="red"><span style="background-color:silver;">%8</span></font><span style="background-color:silver;">, null, !dbg !52</span></div>
<div>  <span style="background-color:silver;">br i1 %</span><font color="red"><span style="background-color:silver;">cmp</span></font><span style="background-color:silver;">, label %no_silent.loopexit, label %while.body, !dbg !54</span></div>
<div> </div>
<div><b><u>Highlighted instruction should be:</u></b></div>
<div>%9 = load %struct.Node*, %struct.Node** <font color="red">%next30.jl</font>, align 8, !dbg !91, !tbaa !92</div>
<div>%cmp.jl = icmp eq %struct.Node* <font color="red">%9</font>, null, !dbg !52</div>
<div>br i1 <font color="red">%cmp.jl</font>, label %no_silent.loopexit, label %while.body, !dbg !54</div>
<div> </div>
<div>I can see in the comments of this function it clearly mentioned it doesn’t remap the clone instructions.</div>
<div>Wondering why its kept like this, is there any specific reason, cloning without remapping may not be correct always.</div>
<div> </div>
<div>Is there any other utility which does both cloning and remapping ?</div>
<div> </div>
<div>Thanks,</div>
<div>Ashutosh</div>
<div> </div>
</span></font>
</body>
</html>