<div dir="ltr">+ Adrian to take a look<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 8, 2017 at 4:06 PM Matthew O'Connor via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thank you. What I need to do to address this? Open an issue on <a href="http://bugs.llvm.org" target="_blank">bugs.llvm.org</a>? I'm not sure what the fix needs to be in the cloner.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 8, 2017 at 4:19 PM, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">There have in the past been bugs in the cloner involving duplicate DICompileUnits (see e.g. <a href="https://reviews.llvm.org/D29240" target="_blank">https://reviews.llvm.org/D29240</a>), this one may need a similar fix.<div><br></div><div>Peter</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_405528762710614078h5">On Thu, Jun 8, 2017 at 3:07 PM, Matthew O'Connor 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></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_405528762710614078h5"><div dir="ltr"><div><div><div>All,<br><br></div>I'm seeing duplication of DICompileUnits in a pass that worked in 3.8. I assume I'm doing something wrong. Would someone be willing to point me in the right direction?<br><br></div>The below minimized pass reproduces my issue in 4.0 with the following error:<br><br><span style="font-family:monospace,monospace">DICompileUnit not listed in <a href="http://llvm.dbg.cu" target="_blank">llvm.dbg.cu</a><br>!1707 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 4.0.0 (tags/RELEASE_400/final)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, imports: !1708)<br>dsc-opt: /home/moconnor/Source/<a href="http://carte.gi" target="_blank">carte.gi</a>t/llvm-carte/llvm-4.0.0/llvm/lib/IR/Verifier.cpp:4500: virtual bool {anonymous}::VerifierLegacyPass::doFinalization(llvm::Module&): Assertion `!V->hasBrokenDebugInfo() && "Module contains invalid debug info"' failed.</span><br><br></div>Pass implementation:<br><div><br><font face="monospace,monospace">#define DEBUG_TYPE "dupl"<br>#include "llvm/Pass.h"<br>#include "llvm/Support/Debug.h"<br>#include "llvm/Support/raw_ostream.h"<br>#include "llvm/Transforms/Utils/Cloning.h"<br>#include <vector><br>using namespace llvm;<br><br>struct FunctionDuplication;<br><br>namespace llvm {<br>void initializeFunctionDuplicationPass(PassRegistry &);<br>}<br><br>struct FunctionDuplication : public ModulePass {<br>  static char ID;<br>  FunctionDuplication() : ModulePass(ID) {}<br><br>  virtual StringRef getPassName() const override {<br>    return "Duplicate every function";<br>  }<br><br>  virtual void getAnalysisUsage(AnalysisUsage &) const override;<br><br>  virtual bool runOnModule(Module &) override;<br><br>  Function *duplicate(Module &, Function &Old, FunctionType *NewTy) const;<br>};<br><br>void FunctionDuplication::getAnalysisUsage(AnalysisUsage &AU) const {<br>  ModulePass::getAnalysisUsage(AU);<br>}<br><br>Function *FunctionDuplication::duplicate(Module &M, Function &Old,<br>                                         FunctionType *NewTy) const {<br>  Function *New = Function::Create(NewTy, Old.getLinkage(), "", &M);<br>  New->setAttributes(Old.getAttributes());<br>  New->setCallingConv(Old.getCallingConv());<br><br>  // Map old arguments to the new arguments.<br>  ValueToValueMapTy VMap;<br>  for (auto OldFI = Old.arg_begin(), OldFE = Old.arg_end(),<br>            NewFI = New->arg_begin();<br>       OldFI != OldFE; ++OldFI, ++NewFI) {<br>    Argument &OldA = *OldFI;<br>    Argument &NewA = *NewFI;<br>    NewA.setName(OldA.getName());<br>    VMap[&OldA] = &NewA;<br>  }<br><br>  SmallVector<ReturnInst *, 16> Returns;<br>  CloneAndPruneFunctionInto(New, &Old, VMap, true, Returns);<br><br>  return New;<br>}<br><br>bool FunctionDuplication::runOnModule(Module &M) {<br>  DataLayout const &DL = M.getDataLayout();<br>  bool Modified = false;<br><br>  std::vector<Function *> Functions;<br>  for (auto &Fn : M.functions()) {<br>    Functions.push_back(&Fn);<br>  }<br><br>  for (auto *F : Functions) {<br>    if (F->size() > 0) {<br>      dbgs() << "duplicating " << F->getName() << "\n";<br><br>      duplicate(M, *F, F->getFunctionType());<br>      Modified = true;<br>    }<br>  }<br><br>  return Modified;<br>}<br><br>char FunctionDuplication::ID = 0;<br>INITIALIZE_PASS(FunctionDuplication, "dupl", "Duplicate every function", false,<br>                false)<br>ModulePass *createFunctionDuplicationPass(void) {<br>  return new FunctionDuplication();<br>}<br></font><br></div></div>
<br></div></div>_______________________________________________<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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><span class="m_405528762710614078HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_405528762710614078m_6430319760989812094gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</font></span></div>
</blockquote></div><br></div>
_______________________________________________<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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>