[llvm-dev] No remapping of clone instruction in CloneBasicBlock

Nema, Ashutosh via llvm-dev llvm-dev at lists.llvm.org
Thu May 5 01:47:33 PDT 2016


Hi,

Found CloneBasicBlock utility only does the cloning without any remapping.

Consider below example:

Input block:
sw.epilog:                                        ; preds = %sw.bb20, %sw.bb15, %sw.bb10, %sw.bb6, %sw.bb2, %sw.bb, %while.body, %if.end29
  %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 ]
  %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 ]
  %next30 = getelementptr inbounds %struct.Node, %struct.Node* %scan.056, i64 0, i32 0, !dbg !91
  %8 = load %struct.Node*, %struct.Node** %next30, align 8, !dbg !91, !tbaa !92
  tail call void @llvm.dbg.value(metadata %struct.Node* %8, i64 0, metadata !28, metadata !34), !dbg !41
  %cmp = icmp eq %struct.Node* %8, null, !dbg !52
  br i1 %cmp, label %no_silent.loopexit, label %while.body, !dbg !54

Clone Block:
sw.epilog.jl:                                     ; No predecessors!
  %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 ]
  %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 ]
  %next30.jl = getelementptr inbounds %struct.Node, %struct.Node* %scan.056, i64 0, i32 0, !dbg !91
  %9 = load %struct.Node*, %struct.Node** %next30, align 8, !dbg !91, !tbaa !92
  tail call void @llvm.dbg.value(metadata %struct.Node* %8, i64 0, metadata !28, metadata !34), !dbg !41
  %cmp.jl = icmp eq %struct.Node* %8, null, !dbg !52
  br i1 %cmp, label %no_silent.loopexit, label %while.body, !dbg !54

Highlighted instruction should be:
%9 = load %struct.Node*, %struct.Node** %next30.jl, align 8, !dbg !91, !tbaa !92
%cmp.jl = icmp eq %struct.Node* %9, null, !dbg !52
br i1 %cmp.jl, label %no_silent.loopexit, label %while.body, !dbg !54

I can see in the comments of this function it clearly mentioned it doesn't remap the clone instructions.
Wondering why its kept like this, is there any specific reason, cloning without remapping may not be correct always.

Is there any other utility which does both cloning and remapping ?

Thanks,
Ashutosh

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160505/ba3b5c1f/attachment.html>


More information about the llvm-dev mailing list