<div dir="ltr">I will have to get back to you on that. The APIs have changed enough in LLVM trunk that it will take me a bit to do the upgrade.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 12, 2017 at 10:53 AM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</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">I see that you are using the clang 4.0 release branch. Does this also reproduce with the current LLVM trunk? We had a lot of churn in the debug info handling in the function cloner in the last couple of weeks.<span class="HOEnZb"><font color="#888888"><div><br></div><div>-- adrian</div></font></span><div><br><div><blockquote type="cite"><div><div class="h5"><div>On Jun 8, 2017, at 3:07 PM, Matthew O'Connor via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="m_-6854032053357041263Apple-interchange-newline"></div></div><div><div><div class="h5"><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/carte.<wbr>git/llvm-carte/llvm-4.0.0/<wbr>llvm/lib/IR/Verifier.cpp:4500: virtual bool {anonymous}::<wbr>VerifierLegacyPass::<wbr>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/<wbr>Cloning.h"<br>#include <vector><br>using namespace llvm;<br><br>struct FunctionDuplication;<br><br>namespace llvm {<br>void initializeFunctionDuplicationP<wbr>ass(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::<wbr>getAnalysisUsage(AnalysisUsage &AU) const {<br> ModulePass::getAnalysisUsage(<wbr>AU);<br>}<br><br>Function *FunctionDuplication::<wbr>duplicate(Module &M, Function &Old,<br> <wbr> FunctionType *NewTy) const {<br> Function *New = Function::Create(NewTy, Old.getLinkage(), "", &M);<br> New->setAttributes(Old.<wbr>getAttributes());<br> New->setCallingConv(Old.<wbr>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::<wbr>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(<wbr>FunctionDuplication, "dupl", "Duplicate every function", false,<br> false)<br>ModulePass *<wbr>createFunctionDuplicationPass(<wbr>void) {<br> return new FunctionDuplication();<br>}<br></font><br></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></blockquote></div><br></div>