<div dir="ltr">This all looks very similar to a bug in the cloning stuff I fixed recently, so would be indeed good to know if this is still happening on master.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 15, 2017 at 2:23 PM, Adrian Prantl via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">If you are doing this work based off LLVM trunk, could you send me your patch to reproduce the problem?<div><br></div><div>-- adrian<br><div><blockquote type="cite"><div><div class="h5"><div>On Jun 15, 2017, at 8:31 AM, Matthias Bernad via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="m_-7456592251995914811Apple-interchange-newline"></div></div><div><div><div class="h5"><div dir="ltr">Hi!<div><br></div><div>We are currently working on a science project and implemented a FunctionPass that clones a function (more precisely a constructor of a struct/class) and adds a parameter.</div><div><br></div><div>First, we create a new function with a new function type, which includes the newly added parameter:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>Function *NF = Function::Create(NewFTy, F.getLinkage(), F.getName() + "Cloned", F.getParent());</div></blockquote><div><br></div><div>and after setting up the ValueToValueMapTy, we use the CloneFunctionInto method to clone the function body</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>CloneFunctionInto(NF, &F, Map, true, Returns, "Cloned");</div></div></blockquote><div><br></div><div>The code seems to work as intended, but when we try to emit debug symbols (clang -g flag) the pass fails with following message:<br><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>"All DICompileUnits must be listed in <a href="http://llvm.dbg.cu/" target="_blank">llvm.dbg.cu</a>"</div></blockquote><div><br></div><div>Nevertheless, we can dump the Module and therefore can print out the annotated IR.</div><div><br></div><div>This is what the function to be cloned looks like:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>; Function Attrs: noinline nounwind uwtable</div></div><div><div>define linkonce_odr void @_ZN12MyFunnyClassC2Ev(%<wbr>struct.MyFunnyClass* %this) unnamed_addr #4 comdat align 2 !dbg !46 {</div></div><div><div>entry:</div></div><div><div>  %this.addr = alloca %struct.MyFunnyClass*, align 8</div></div><div><div>  store %struct.MyFunnyClass* %this, %struct.MyFunnyClass** %this.addr, align 8</div></div><div><div>  call void @llvm.dbg.declare(metadata %struct.MyFunnyClass** %this.addr, metadata !49, metadata !31), !dbg !50</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>... rest of function code</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>}</div></div><div><br></div><div><div>!46 = distinct !DISubprogram(name: "MyFunnyClass", linkageName: "_ZN12MyFunnyClassC2Ev", scope: !15, file: !1, line: 1, type: !25, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !47, variables: !2)</div></div></blockquote><div><br></div><div>and the cloned function:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>; Function Attrs: noinline nounwind uwtable</div></div><div><div>define linkonce_odr void @_ZN12MyFunnyClassC2EvCloned(%<wbr>struct.MyFunnyClass* %this, { [6 x i8*] }* %newparam) unnamed_addr #4 align 2 !dbg !73 {</div></div><div><div>entry:</div></div><div><div>  %this.addr = alloca %struct.MyFunnyClass*, align 8</div></div><div><div>  store %struct.MyFunnyClass* %this, %struct.MyFunnyClass** %this.addr, align 8</div></div><div><div>  call void @llvm.dbg.declare(metadata %struct.MyFunnyClass** %this.addr, metadata !89, metadata !31), !dbg !91</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>... rest of function code</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>}<br></div></div><div><br></div><div><div>!73 = distinct !DISubprogram(name: "MyFunnyClass", linkageName: "_ZN12MyFunnyClassC2Ev", scope: !74, file: !1, line: 1, type: !81, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !87, declaration: !88, variables: !2)</div></div><div><br></div></blockquote>So the cloned function gets annotated with debug symbols as expected. We noticed that the linkageName of the cloned function is the same as the original one's. Could that cause the error mentioned above? If so, how can we fix that error?<div><br></div><div>Best regards and thanks in advance,</div><div>Matthias</div></div></div></div><span class="">
______________________________<wbr>_________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br></span></div></blockquote></div><br></div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>