Nema, Ashutosh via llvm-dev
2016-May-05 08:47 UTC
[llvm-dev] No remapping of clone instruction in CloneBasicBlock
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>
James Molloy via llvm-dev
2016-May-05 10:36 UTC
[llvm-dev] No remapping of clone instruction in CloneBasicBlock
Hi Ashuntosh, Indeed, this is deliberate. When performing cloning operations, often the user requires quite a lot of flexibility. Perhaps by editing the remapping map before remapping is performed (clone with remapping, but change so that %A -> %B). The RemapInstructionsInBlocks function does what you want: ValueToValueMapTy VM; CloneBasicBlock(BB, VM, ...); RemapInstructionsInBlocks({BB}, VM); Cheers, James On Thu, 5 May 2016 at 09:48 Nema, Ashutosh via llvm-dev < llvm-dev at lists.llvm.org> wrote:> 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 > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160505/583c5650/attachment.html>
Nema, Ashutosh via llvm-dev
2016-May-05 11:20 UTC
[llvm-dev] No remapping of clone instruction in CloneBasicBlock
Thanks James, it helps. Regards, Ashutosh From: James Molloy [mailto:james at jamesmolloy.co.uk] Sent: Thursday, May 05, 2016 4:06 PM To: Nema, Ashutosh <Ashutosh.Nema at amd.com>; llvm-dev <llvm-dev at lists.llvm.org> Subject: Re: [llvm-dev] No remapping of clone instruction in CloneBasicBlock Hi Ashuntosh, Indeed, this is deliberate. When performing cloning operations, often the user requires quite a lot of flexibility. Perhaps by editing the remapping map before remapping is performed (clone with remapping, but change so that %A -> %B). The RemapInstructionsInBlocks function does what you want: ValueToValueMapTy VM; CloneBasicBlock(BB, VM, ...); RemapInstructionsInBlocks({BB}, VM); Cheers, James On Thu, 5 May 2016 at 09:48 Nema, Ashutosh via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: 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<http://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<http://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<http://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<http://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<http://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 _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160505/3fa9537b/attachment.html>
Reasonably Related Threads
- [LLVMdev] dominator, post-dominator and memory leak
- [LLVMdev] dominator, post-dominator and memory leak
- [LLVMdev] dominator, post-dominator and memory leak
- [LLVMdev] dominator, post-dominator and memory leak
- [LLVMdev] dominator, post-dominator and memory leak