<div dir="ltr">On Tue, Dec 23, 2014 at 5:38 PM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I think I have a great reduction of this bug:<div><br></div><div>%clang -target i686-linux-gnu -c %s -g -o /dev/null</div><div><br></div><div>double _Complex f(void) {</div><div> double _Complex c;</div><div> return c;</div><div>}</div><div><br></div><div>It is somewhat flaky (okay pretty flaky), but, does reproduce the issue enough that you can bang r-enter until $debugger traps on the fault.</div><div><br></div><div>The issue seems to be related to the emission of the debug loc in the epilogue, where it has an invalid sloc for the returned value. I've not done a full analysis of the issue, but throwing the reproduction<span></span> out there in case someone more familiar with this code path can immediately see the issue.</div><div><br></div><div>Thanks to David for the pointer to the thread!<br></div></blockquote><div><br></div><div><a href="http://reviews.llvm.org/D6775">http://reviews.llvm.org/D6775</a> seems to resolve the issue for me. The patch itself is not ready to be committed, but, it should be in a reasonable shape for testing.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>On Sunday, December 21, 2014, Yaron Keren <<a href="mailto:yaron.keren@gmail.com" target="_blank">yaron.keren@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="rtl"><div dir="ltr">Ok, the last revision this example passes is r223801.</div><div dir="ltr"><br></div><div dir="ltr">r223802 (Metadata/Value split) until r223823 (including) don't compile with Visual C++. </div><div dir="ltr">r223824 until r223857 (including) do compile but the example crashes, in a different location than the LexicalBlockStack assert.</div><div dir="ltr">r223858 does not crash and fails the LexicalBlockStack assertion.</div><div dir="ltr"><br></div><div dir="ltr">so we first see the problem with r223858 but it may have been introduced as early as r223802.</div><div dir="ltr"><br></div></div><div><div dir="ltr"><br><div>2014-12-20 1:00 GMT+02:00 Yaron Keren <span dir="ltr"><<a>yaron.keren@gmail.com</a>></span>:<br><blockquote style="margin:0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;border-right-width:1px;border-right-color:rgb(204,204,204);border-right-style:solid;padding-left:1ex;padding-right:1ex"><div dir="rtl"><div dir="ltr">I suspect r223828 - DebugInfo: Accurate location information for complex assignment, before it EmitStoreOfComplex was passing invalid SourceLocation() into CGDebugInfo::EmitLocation which would return immediately and the code path would not be exercised at all. </div><div dir="ltr"><br></div><div dir="ltr">It's also possible r223828 just exposed some other hidden bug.</div><div dir="ltr"><br></div><div dir="ltr">I won't have time for two builds to verify this today, if needed I'll build first thing tommorrow.<br></div><div dir="ltr"><br></div></div><div><div dir="ltr"><br><div>2014-12-20 0:36 GMT+02:00 David Blaikie <span dir="ltr"><<a>dblaikie@gmail.com</a>></span>:<br><blockquote style="margin:0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;border-right-width:1px;border-right-color:rgb(204,204,204);border-right-style:solid;padding-left:1ex;padding-right:1ex"><br><div><br><div>On Fri, Dec 19, 2014 at 2:21 PM, Yaron Keren <span dir="ltr"><<a>yaron.keren@gmail.com</a>></span> wrote:<blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="rtl"><div dir="ltr">I will look into creduce, looks like a very useful tool.</div><div dir="ltr"><br></div><div dir="ltr">The assert failing is not a clang assert but a Visual C++ header assert (in debug mode only) checking empty std::vector every back() access to the vector.</div><div dir="ltr">Maybe the libstdc++ std::vector runtime header does not have this assert or it's not enabled?</div><div dir="ltr"><br></div><div dir="ltr">If I add an explicit assert for LexicalBlockStack:</div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr"><b> assert(LexicalBlockStack.size());</b></div><div dir="ltr"> if (CurLoc == PrevLoc ||</div><div dir="ltr"> SM.getExpansionLoc(CurLoc) == SM.getExpansionLoc(PrevLoc))</div><div dir="ltr"> // New Builder may not be in sync with CGDebugInfo.</div><div dir="ltr"> if (!Builder.getCurrentDebugLocation().isUnknown() &&</div><div dir="ltr"> Builder.getCurrentDebugLocation().getScope(CGM.getLLVMContext()) ==</div><div dir="ltr"> LexicalBlockStack.back())</div><div><br></div><div>it gets triggered with toT r224610:</div><div><br></div><div> Assertion failed: LexicalBlockStack.size(), file ..\..\..\..\..\tools\clang\lib\CodeGen\CGDebugInfo.cpp, line 2648<br></div><div><br></div><div>Could you try with this assert?<br></div></div></div></blockquote><div><br>Yep, I can reproduce that, but don't know when it was introduced. Do you have a revision range for when you started seeing this?<br> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="rtl"><div dir="ltr"><div></div><div><br></div></div></div><div><br><div><div dir="ltr">2014-12-19 23:49 GMT+02:00 Yaron Keren <span dir="ltr"><<a>yaron.keren@gmail.com</a>></span>:</div><blockquote style="margin:0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;border-right-width:1px;border-right-color:rgb(204,204,204);border-right-style:solid;padding-left:1ex;padding-right:1ex"><div dir="rtl"><div dir="ltr">Thanks for checking so quickly, svn info shows r224610, I'll investigate what's going on.</div><div><div><div dir="ltr"><br></div><div><div dir="ltr"><br><div>2014-12-19 23:39 GMT+02:00 David Blaikie <span dir="ltr"><<a>dblaikie@gmail.com</a>></span>:<br><blockquote style="margin:0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;border-right-width:1px;border-right-color:rgb(204,204,204);border-right-style:solid;padding-left:1ex;padding-right:1ex"><br><div><br><div>On Fri, Dec 19, 2014 at 1:18 PM, Yaron Keren <span dir="ltr"><<a>yaron.keren@gmail.com</a>></span> wrote:<blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="rtl"><div dir="ltr">Hi,</div><div dir="ltr"><br></div><div dir="ltr">I have filed a C++ example triggering this.</div></div></blockquote><div><br>Is this triggering on ToT clang? My patch (not this one from Duncan) <span style="font-family:monospace">r224385</span> was reverted in r224441.</div><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="rtl"><div dir="ltr"> It's using boost... the source code is not long after preprocessed is almost 25MB.</div></div></blockquote><div><br>Just for future reference - the unpreprocessed source code length isn't usually terribly important (so if you can't reduce the preprocessed source, it's probably not too important to spend time reducing the unpreprocessed source - you'll only be removing maybe a few hundred lines, out of the many thousands that need to be reduced). Tools like creduce can help reduce the preprocessed source without so much manual effort.<br><br>In any case, I can't seem to reproduce the assertion failure from your preprocessed file, nor from Francois example... (even with my patch reapplied)... <br><br>- David<br> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="rtl"><div dir="ltr"><br></div><div dir="ltr"> <a href="http://llvm.org/PR21987" target="_blank">http://llvm.org/PR21987</a><br></div><div dir="ltr"><br></div><div dir="ltr">Yaron<br></div><div dir="ltr"><br></div></div><div><br><div><div dir="ltr">2014-12-17 22:21 GMT+02:00 David Blaikie <span dir="ltr"><<a>dblaikie@gmail.com</a>></span>:</div><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Yeah, still sounds likely that that was my change, not this one.</div><div><br><div>On Wed, Dec 17, 2014 at 12:19 PM, Duncan P. N. Exon Smith <span dir="ltr"><<a>dexonsmith@apple.com</a>></span> wrote:<blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">So r223803 (and r223802) should have been effectively NFC (at least once<br>
the follow-up bugfixes were applied).<br>
<br>
I didn't change the logic around LexicalBlockStack -- just changed some<br>
`push_back`s to `emplace_back`s because I changed the type being held in<br>
it -- and I honestly don't know how it's supposed to work. (And I don't<br>
know anything about ABIs.)<br>
<br>
If I'm going to help you debug this, I'll need some more guidance.<br>
Ideally, you'd give me a patch and a reproduction to expose the problem<br>
on ToT. (Or maybe David has some ideas?)<br>
<br>
(BTW, have you done a bisection? Are you sure this is the problematic<br>
commit?)<br>
<br>
> On 2014-Dec-17, at 08:43, Francois Pichet <<a>pichet2000@gmail.com</a>> wrote:<br>
><br>
> Hi, the assert will occur for a target that use DefaultABIInfo where Complex types are returned via the ABIArgInfo::Indirect mechanism. This is the case for my out of tree target.<br>
><br>
> EmitFunctionEnd will make LexicalBlockStack empty.<br>
> EmitStoreOfComplex called from EmitFunctionEpilog will eventually assume a non empty LexicalBlockStack.<br>
><br>
> On Tue, Dec 16, 2014 at 6:15 PM, Duncan P. N. Exon Smith <<a>dexonsmith@apple.com</a>> wrote:<br>
> It's not reproducing for me:<br>
><br>
> clang -g test.c<br>
> test.c:3:8: warning: implicitly declaring library function 'casin' with type '_Complex double<br>
> (_Complex double)'<br>
> z = casin(z);<br>
> ^<br>
> test.c:3:8: note: include the header <complex.h> or explicitly provide a declaration for 'casin'<br>
> 1 warning generated.<br>
> Undefined symbols for architecture x86_64:<br>
> "_main", referenced from:<br>
> implicit entry/start for main executable<br>
> ld: symbol(s) not found for architecture x86_64<br>
> clang-3.6: error: linker command failed with exit code 1 (use -v to see invocation)<br>
> lrun: error: failed: /Users/dexonsmith/data/llvm.debug/debug-info/bin/clang -g test.c<br>
><br>
> If you can reproduce this ToT, please file a PR with preprocessed source and<br>
> the -cc1 command (usually the driver will produce these files for you) and<br>
> CC me.<br>
><br>
> > On 2014 Dec 16, at 12:24, Francois Pichet <<a>pichet2000@gmail.com</a>> wrote:<br>
> ><br>
> > Hi, I re-synced a private repo of clang/llvm lately and I am getting an assert when compiling musl-libc with clang in debug mode, I suspect this commit. Basically LexicalBlockStack is empty when CGDebugInfo::EmitLocation is called.<br>
> ><br>
> > clang -g test.c<br>
> ><br>
> > here is the test.c: <a href="http://pastebin.com/zXyAknCf" target="_blank">http://pastebin.com/zXyAknCf</a><br>
> ><br>
> > Thanks,<br>
<div><div>> ><br>
> > On Tue, Dec 9, 2014 at 1:39 PM, Duncan P. N. Exon Smith <<a>dexonsmith@apple.com</a>> wrote:<br>
> > Author: dexonsmith<br>
> > Date: Tue Dec 9 12:39:32 2014<br>
> > New Revision: 223803<br>
> ><br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=223803&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=223803&view=rev</a><br>
> > Log:<br>
> > IR: Update clang for Metadata/Value split in r223802<br>
> ><br>
> > Match LLVM API changes from r223802.<br>
> ><br>
> > Modified:<br>
> > cfe/trunk/lib/CodeGen/CGBuiltin.cpp<br>
> > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
> > cfe/trunk/lib/CodeGen/CGDebugInfo.h<br>
> > cfe/trunk/lib/CodeGen/CGExpr.cpp<br>
> > cfe/trunk/lib/CodeGen/CGLoopInfo.cpp<br>
> > cfe/trunk/lib/CodeGen/CGObjC.cpp<br>
> > cfe/trunk/lib/CodeGen/CGObjCGNU.cpp<br>
> > cfe/trunk/lib/CodeGen/CGObjCMac.cpp<br>
> > cfe/trunk/lib/CodeGen/CGStmt.cpp<br>
> > cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br>
> > cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
> > cfe/trunk/lib/CodeGen/CodeGenModule.h<br>
> > cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp<br>
> > cfe/trunk/lib/CodeGen/TargetInfo.cpp<br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Dec 9 12:39:32 2014<br>
> > @@ -5932,8 +5932,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx<br>
> > case X86::BI__builtin_ia32_movntdq256:<br>
> > case X86::BI__builtin_ia32_movnti:<br>
> > case X86::BI__builtin_ia32_movnti64: {<br>
> > - llvm::MDNode *Node = llvm::MDNode::get(getLLVMContext(),<br>
> > - Builder.getInt32(1));<br>
> > + llvm::MDNode *Node = llvm::MDNode::get(<br>
> > + getLLVMContext(), llvm::ConstantAsMetadata::get(Builder.getInt32(1)));<br>
> ><br>
> > // Convert the type of the pointer to a pointer to the stored type.<br>
> > Value *BC = Builder.CreateBitCast(Ops[0],<br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Dec 9 12:39:32 2014<br>
> > @@ -126,13 +126,13 @@ void CGDebugInfo::setLocation(SourceLoca<br>
> > LBF.getScope(), getOrCreateFile(CurLoc));<br>
> > llvm::MDNode *N = D;<br>
> > LexicalBlockStack.pop_back();<br>
> > - LexicalBlockStack.push_back(N);<br>
> > + LexicalBlockStack.emplace_back(N);<br>
> > } else if (Scope.isLexicalBlock() || Scope.isSubprogram()) {<br>
> > llvm::DIDescriptor D =<br>
> > DBuilder.createLexicalBlockFile(Scope, getOrCreateFile(CurLoc));<br>
> > llvm::MDNode *N = D;<br>
> > LexicalBlockStack.pop_back();<br>
> > - LexicalBlockStack.push_back(N);<br>
> > + LexicalBlockStack.emplace_back(N);<br>
> > }<br>
> > }<br>
> ><br>
> > @@ -141,10 +141,9 @@ llvm::DIScope CGDebugInfo::getContextDes<br>
> > if (!Context)<br>
> > return TheCU;<br>
> ><br>
> > - llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator I =<br>
> > - RegionMap.find(Context);<br>
> > + auto I = RegionMap.find(Context);<br>
> > if (I != RegionMap.end()) {<br>
> > - llvm::Value *V = I->second;<br>
> > + llvm::Metadata *V = I->second;<br>
> > return llvm::DIScope(dyn_cast_or_null<llvm::MDNode>(V));<br>
> > }<br>
> ><br>
> > @@ -256,18 +255,17 @@ llvm::DIFile CGDebugInfo::getOrCreateFil<br>
> ><br>
> > // Cache the results.<br>
> > const char *fname = PLoc.getFilename();<br>
> > - llvm::DenseMap<const char *, llvm::WeakVH>::iterator it =<br>
> > - DIFileCache.find(fname);<br>
> > + auto it = DIFileCache.find(fname);<br>
> ><br>
> > if (it != DIFileCache.end()) {<br>
> > // Verify that the information still exists.<br>
> > - if (llvm::Value *V = it->second)<br>
> > + if (llvm::Metadata *V = it->second)<br>
> > return llvm::DIFile(cast<llvm::MDNode>(V));<br>
> > }<br>
> ><br>
> > llvm::DIFile F = DBuilder.createFile(PLoc.getFilename(), getCurrentDirname());<br>
> ><br>
> > - DIFileCache[fname] = F;<br>
> > + DIFileCache[fname].reset(F);<br>
> > return F;<br>
> > }<br>
> ><br>
> > @@ -641,7 +639,9 @@ CGDebugInfo::getOrCreateRecordFwdDecl(co<br>
> > SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);<br>
> > llvm::DICompositeType RetTy = DBuilder.createReplaceableForwardDecl(<br>
> > Tag, RDName, Ctx, DefUnit, Line, 0, 0, 0, FullName);<br>
> > - ReplaceMap.push_back(std::make_pair(Ty, static_cast<llvm::Value *>(RetTy)));<br>
> > + ReplaceMap.emplace_back(<br>
> > + std::piecewise_construct, std::make_tuple(Ty),<br>
> > + std::make_tuple(static_cast<llvm::Metadata *>(RetTy)));<br>
> > return RetTy;<br>
> > }<br>
> ><br>
> > @@ -680,7 +680,7 @@ llvm::DIType CGDebugInfo::CreateType(con<br>
> > if (BlockLiteralGeneric)<br>
> > return BlockLiteralGeneric;<br>
> ><br>
> > - SmallVector<llvm::Value *, 8> EltTys;<br>
> > + SmallVector<llvm::Metadata *, 8> EltTys;<br>
> > llvm::DIType FieldTy;<br>
> > QualType FType;<br>
> > uint64_t FieldSize, FieldOffset;<br>
> > @@ -784,7 +784,7 @@ llvm::DIType CGDebugInfo::CreateType(con<br>
> ><br>
> > llvm::DIType CGDebugInfo::CreateType(const FunctionType *Ty,<br>
> > llvm::DIFile Unit) {<br>
> > - SmallVector<llvm::Value *, 16> EltTys;<br>
> > + SmallVector<llvm::Metadata *, 16> EltTys;<br>
> ><br>
> > // Add the result type at least.<br>
> > EltTys.push_back(getOrCreateType(Ty->getReturnType(), Unit));<br>
> > @@ -857,10 +857,9 @@ llvm::DIType CGDebugInfo::createFieldTyp<br>
> > }<br>
> ><br>
> > /// CollectRecordLambdaFields - Helper for CollectRecordFields.<br>
> > -void<br>
> > -CGDebugInfo::CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl,<br>
> > - SmallVectorImpl<llvm::Value *> &elements,<br>
> > - llvm::DIType RecordTy) {<br>
> > +void CGDebugInfo::CollectRecordLambdaFields(<br>
> > + const CXXRecordDecl *CXXDecl, SmallVectorImpl<llvm::Metadata *> &elements,<br>
> > + llvm::DIType RecordTy) {<br>
> > // For C++11 Lambdas a Field will be the same as a Capture, but the Capture<br>
> > // has the name and the location of the variable so we should iterate over<br>
> > // both concurrently.<br>
> > @@ -928,14 +927,14 @@ llvm::DIDerivedType CGDebugInfo::CreateR<br>
> > unsigned Flags = getAccessFlag(Var->getAccess(), RD);<br>
> > llvm::DIDerivedType GV = DBuilder.createStaticMemberType(<br>
> > RecordTy, VName, VUnit, LineNumber, VTy, Flags, C);<br>
> > - StaticDataMemberCache[Var->getCanonicalDecl()] = llvm::WeakVH(GV);<br>
> > + StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);<br>
> > return GV;<br>
> > }<br>
> ><br>
> > /// CollectRecordNormalField - Helper for CollectRecordFields.<br>
> > void CGDebugInfo::CollectRecordNormalField(<br>
> > const FieldDecl *field, uint64_t OffsetInBits, llvm::DIFile tunit,<br>
> > - SmallVectorImpl<llvm::Value *> &elements, llvm::DIType RecordTy,<br>
> > + SmallVectorImpl<llvm::Metadata *> &elements, llvm::DIType RecordTy,<br>
> > const RecordDecl *RD) {<br>
> > StringRef name = field->getName();<br>
> > QualType type = field->getType();<br>
> > @@ -959,10 +958,10 @@ void CGDebugInfo::CollectRecordNormalFie<br>
> ><br>
> > /// CollectRecordFields - A helper function to collect debug info for<br>
> > /// record fields. This is used while creating debug info entry for a Record.<br>
> > -void CGDebugInfo::CollectRecordFields(const RecordDecl *record,<br>
> > - llvm::DIFile tunit,<br>
> > - SmallVectorImpl<llvm::Value *> &elements,<br>
> > - llvm::DICompositeType RecordTy) {<br>
> > +void CGDebugInfo::CollectRecordFields(<br>
> > + const RecordDecl *record, llvm::DIFile tunit,<br>
> > + SmallVectorImpl<llvm::Metadata *> &elements,<br>
> > + llvm::DICompositeType RecordTy) {<br>
> > const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(record);<br>
> ><br>
> > if (CXXDecl && CXXDecl->isLambda())<br>
> > @@ -978,8 +977,7 @@ void CGDebugInfo::CollectRecordFields(co<br>
> > for (const auto *I : record->decls())<br>
> > if (const auto *V = dyn_cast<VarDecl>(I)) {<br>
> > // Reuse the existing static member declaration if one exists<br>
> > - llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator MI =<br>
> > - StaticDataMemberCache.find(V->getCanonicalDecl());<br>
> > + auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());<br>
> > if (MI != StaticDataMemberCache.end()) {<br>
> > assert(MI->second &&<br>
> > "Static data member declaration should still exist");<br>
> > @@ -1019,7 +1017,7 @@ llvm::DICompositeType CGDebugInfo::getOr<br>
> > getOrCreateType(QualType(Func, 0), Unit)).getTypeArray();<br>
> > assert(Args.getNumElements() && "Invalid number of arguments!");<br>
> ><br>
> > - SmallVector<llvm::Value *, 16> Elts;<br>
> > + SmallVector<llvm::Metadata *, 16> Elts;<br>
> ><br>
> > // First element is always return type. For 'void' functions it is NULL.<br>
> > Elts.push_back(Args.getElement(0));<br>
> > @@ -1036,7 +1034,7 @@ llvm::DICompositeType CGDebugInfo::getOr<br>
> > llvm::DIType PointeeType = getOrCreateType(PointeeTy, Unit);<br>
> > llvm::DIType ThisPtrType =<br>
> > DBuilder.createPointerType(PointeeType, Size, Align);<br>
> > - TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType;<br>
> > + TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);<br>
> > // TODO: This and the artificial type below are misleading, the<br>
> > // types aren't artificial the argument is, but the current<br>
> > // metadata doesn't represent that.<br>
> > @@ -1044,7 +1042,7 @@ llvm::DICompositeType CGDebugInfo::getOr<br>
> > Elts.push_back(ThisPtrType);<br>
> > } else {<br>
> > llvm::DIType ThisPtrType = getOrCreateType(ThisPtr, Unit);<br>
> > - TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType;<br>
> > + TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);<br>
> > ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);<br>
> > Elts.push_back(ThisPtrType);<br>
> > }<br>
> > @@ -1147,7 +1145,7 @@ CGDebugInfo::CreateCXXMemberFunction(con<br>
> > /* isDefinition=*/false, Virtuality, VIndex, ContainingType, Flags,<br>
> > CGM.getLangOpts().Optimize, nullptr, TParamsArray);<br>
> ><br>
> > - SPCache[Method->getCanonicalDecl()] = llvm::WeakVH(SP);<br>
> > + SPCache[Method->getCanonicalDecl()].reset(SP);<br>
> ><br>
> > return SP;<br>
> > }<br>
> > @@ -1157,7 +1155,7 @@ CGDebugInfo::CreateCXXMemberFunction(con<br>
> > /// a Record.<br>
> > void CGDebugInfo::CollectCXXMemberFunctions(<br>
> > const CXXRecordDecl *RD, llvm::DIFile Unit,<br>
> > - SmallVectorImpl<llvm::Value *> &EltTys, llvm::DIType RecordTy) {<br>
> > + SmallVectorImpl<llvm::Metadata *> &EltTys, llvm::DIType RecordTy) {<br>
> ><br>
> > // Since we want more than just the individual member decls if we<br>
> > // have templated functions iterate over every declaration to gather<br>
> > @@ -1188,7 +1186,7 @@ void CGDebugInfo::CollectCXXMemberFuncti<br>
> > auto MI = SPCache.find(Method->getCanonicalDecl());<br>
> > EltTys.push_back(MI == SPCache.end()<br>
> > ? CreateCXXMemberFunction(Method, Unit, RecordTy)<br>
> > - : static_cast<llvm::Value *>(MI->second));<br>
> > + : static_cast<llvm::Metadata *>(MI->second));<br>
> > }<br>
> > }<br>
> ><br>
> > @@ -1196,7 +1194,7 @@ void CGDebugInfo::CollectCXXMemberFuncti<br>
> > /// C++ base classes. This is used while creating debug info entry for<br>
> > /// a Record.<br>
> > void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile Unit,<br>
> > - SmallVectorImpl<llvm::Value *> &EltTys,<br>
> > + SmallVectorImpl<llvm::Metadata *> &EltTys,<br>
> > llvm::DIType RecordTy) {<br>
> ><br>
> > const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);<br>
> > @@ -1238,7 +1236,7 @@ llvm::DIArray<br>
> > CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList,<br>
> > ArrayRef<TemplateArgument> TAList,<br>
> > llvm::DIFile Unit) {<br>
> > - SmallVector<llvm::Value *, 16> TemplateParams;<br>
> > + SmallVector<llvm::Metadata *, 16> TemplateParams;<br>
> > for (unsigned i = 0, e = TAList.size(); i != e; ++i) {<br>
> > const TemplateArgument &TA = TAList[i];<br>
> > StringRef Name;<br>
> > @@ -1263,7 +1261,7 @@ CGDebugInfo::CollectTemplateParams(const<br>
> > const ValueDecl *D = TA.getAsDecl();<br>
> > QualType T = TA.getParamTypeForDecl().getDesugaredType(CGM.getContext());<br>
> > llvm::DIType TTy = getOrCreateType(T, Unit);<br>
> > - llvm::Value *V = nullptr;<br>
> > + llvm::Constant *V = nullptr;<br>
> > const CXXMethodDecl *MD;<br>
> > // Variable pointer template parameters have a value that is the address<br>
> > // of the variable.<br>
> > @@ -1295,7 +1293,7 @@ CGDebugInfo::CollectTemplateParams(const<br>
> > case TemplateArgument::NullPtr: {<br>
> > QualType T = TA.getNullPtrType();<br>
> > llvm::DIType TTy = getOrCreateType(T, Unit);<br>
> > - llvm::Value *V = nullptr;<br>
> > + llvm::Constant *V = nullptr;<br>
> > // Special case member data pointer null values since they're actually -1<br>
> > // instead of zero.<br>
> > if (const MemberPointerType *MPT =<br>
> > @@ -1332,7 +1330,7 @@ CGDebugInfo::CollectTemplateParams(const<br>
> > QualType T = E->getType();<br>
> > if (E->isGLValue())<br>
> > T = CGM.getContext().getLValueReferenceType(T);<br>
> > - llvm::Value *V = CGM.EmitConstantExpr(E, T);<br>
> > + llvm::Constant *V = CGM.EmitConstantExpr(E, T);<br>
> > assert(V && "Expression in template argument isn't constant");<br>
> > llvm::DIType TTy = getOrCreateType(T, Unit);<br>
> > llvm::DITemplateValueParameter TVP =<br>
> > @@ -1385,7 +1383,7 @@ llvm::DIType CGDebugInfo::getOrCreateVTa<br>
> > ASTContext &Context = CGM.getContext();<br>
> ><br>
> > /* Function type */<br>
> > - llvm::Value *STy = getOrCreateType(Context.IntTy, Unit);<br>
> > + llvm::Metadata *STy = getOrCreateType(Context.IntTy, Unit);<br>
> > llvm::DITypeArray SElements = DBuilder.getOrCreateTypeArray(STy);<br>
> > llvm::DIType SubTy = DBuilder.createSubroutineType(Unit, SElements);<br>
> > unsigned Size = Context.getTypeSize(Context.VoidPtrTy);<br>
> > @@ -1404,7 +1402,7 @@ StringRef CGDebugInfo::getVTableName(con<br>
> > /// CollectVTableInfo - If the C++ class has vtable info then insert appropriate<br>
> > /// debug info entry in EltTys vector.<br>
> > void CGDebugInfo::CollectVTableInfo(const CXXRecordDecl *RD, llvm::DIFile Unit,<br>
> > - SmallVectorImpl<llvm::Value *> &EltTys) {<br>
> > + SmallVectorImpl<llvm::Metadata *> &EltTys) {<br>
> > const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);<br>
> ><br>
> > // If there is a primary base then it will hold vtable info.<br>
> > @@ -1447,12 +1445,11 @@ void CGDebugInfo::completeType(const Enu<br>
> > void *TyPtr = Ty.getAsOpaquePtr();<br>
> > auto I = TypeCache.find(TyPtr);<br>
> > if (I == TypeCache.end() ||<br>
> > - !llvm::DIType(cast<llvm::MDNode>(static_cast<llvm::Value *>(I->second)))<br>
> > - .isForwardDecl())<br>
> > + !llvm::DIType(cast<llvm::MDNode>(I->second)).isForwardDecl())<br>
> > return;<br>
> > llvm::DIType Res = CreateTypeDefinition(Ty->castAs<EnumType>());<br>
> > assert(!Res.isForwardDecl());<br>
> > - TypeCache[TyPtr] = Res;<br>
> > + TypeCache[TyPtr].reset(Res);<br>
> > }<br>
> ><br>
> > void CGDebugInfo::completeType(const RecordDecl *RD) {<br>
> > @@ -1482,12 +1479,11 @@ void CGDebugInfo::completeClassData(cons<br>
> > void *TyPtr = Ty.getAsOpaquePtr();<br>
> > auto I = TypeCache.find(TyPtr);<br>
> > if (I != TypeCache.end() &&<br>
> > - !llvm::DIType(cast<llvm::MDNode>(static_cast<llvm::Value *>(I->second)))<br>
> > - .isForwardDecl())<br>
> > + !llvm::DIType(cast<llvm::MDNode>(I->second)).isForwardDecl())<br>
> > return;<br>
> > llvm::DIType Res = CreateTypeDefinition(Ty->castAs<RecordType>());<br>
> > assert(!Res.isForwardDecl());<br>
> > - TypeCache[TyPtr] = Res;<br>
> > + TypeCache[TyPtr].reset(Res);<br>
> > }<br>
> ><br>
> > static bool hasExplicitMemberDefinition(CXXRecordDecl::method_iterator I,<br>
> > @@ -1571,11 +1567,11 @@ llvm::DIType CGDebugInfo::CreateTypeDefi<br>
> > CollectContainingType(CXXDecl, FwdDecl);<br>
> ><br>
> > // Push the struct on region stack.<br>
> > - LexicalBlockStack.push_back(&*FwdDecl);<br>
> > - RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl);<br>
> > + LexicalBlockStack.emplace_back(&*FwdDecl);<br>
> > + RegionMap[Ty->getDecl()].reset(FwdDecl);<br>
> ><br>
> > // Convert all the elements.<br>
> > - SmallVector<llvm::Value *, 16> EltTys;<br>
> > + SmallVector<llvm::Metadata *, 16> EltTys;<br>
> > // what about nested types?<br>
> ><br>
> > // Note: The split of CXXDecl information here is intentional, the<br>
> > @@ -1599,7 +1595,7 @@ llvm::DIType CGDebugInfo::CreateTypeDefi<br>
> > llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);<br>
> > FwdDecl.setArrays(Elements);<br>
> ><br>
> > - RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl);<br>
> > + RegionMap[Ty->getDecl()].reset(FwdDecl);<br>
> > return FwdDecl;<br>
> > }<br>
> ><br>
> > @@ -1680,14 +1676,14 @@ llvm::DIType CGDebugInfo::CreateTypeDefi<br>
> > llvm::DIArray(), RuntimeLang);<br>
> ><br>
> > QualType QTy(Ty, 0);<br>
> > - TypeCache[QTy.getAsOpaquePtr()] = RealDecl;<br>
> > + TypeCache[QTy.getAsOpaquePtr()].reset(RealDecl);<br>
> ><br>
> > // Push the struct on region stack.<br>
> > - LexicalBlockStack.push_back(static_cast<llvm::MDNode *>(RealDecl));<br>
> > - RegionMap[Ty->getDecl()] = llvm::WeakVH(RealDecl);<br>
> > + LexicalBlockStack.emplace_back(static_cast<llvm::MDNode *>(RealDecl));<br>
> > + RegionMap[Ty->getDecl()].reset(RealDecl);<br>
> ><br>
> > // Convert all the elements.<br>
> > - SmallVector<llvm::Value *, 16> EltTys;<br>
> > + SmallVector<llvm::Metadata *, 16> EltTys;<br>
> ><br>
> > ObjCInterfaceDecl *SClass = ID->getSuperClass();<br>
> > if (SClass) {<br>
> > @@ -1813,7 +1809,7 @@ llvm::DIType CGDebugInfo::CreateType(con<br>
> > // Use Count == -1 to express such arrays.<br>
> > Count = -1;<br>
> ><br>
> > - llvm::Value *Subscript = DBuilder.getOrCreateSubrange(0, Count);<br>
> > + llvm::Metadata *Subscript = DBuilder.getOrCreateSubrange(0, Count);<br>
> > llvm::DIArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);<br>
> ><br>
> > uint64_t Size = CGM.getContext().getTypeSize(Ty);<br>
> > @@ -1849,7 +1845,7 @@ llvm::DIType CGDebugInfo::CreateType(con<br>
> > // Add the dimensions of the array. FIXME: This loses CV qualifiers from<br>
> > // interior arrays, do we care? Why aren't nested arrays represented the<br>
> > // obvious/recursive way?<br>
> > - SmallVector<llvm::Value *, 8> Subscripts;<br>
> > + SmallVector<llvm::Metadata *, 8> Subscripts;<br>
> > QualType EltTy(Ty, 0);<br>
> > while ((Ty = dyn_cast<ArrayType>(EltTy))) {<br>
> > // If the number of elements is known, then count is that number. Otherwise,<br>
> > @@ -1932,7 +1928,9 @@ llvm::DIType CGDebugInfo::CreateEnumType<br>
> > llvm::DIType RetTy = DBuilder.createReplaceableForwardDecl(<br>
> > llvm::dwarf::DW_TAG_enumeration_type, EDName, EDContext, DefUnit, Line,<br>
> > 0, Size, Align, FullName);<br>
> > - ReplaceMap.push_back(std::make_pair(Ty, static_cast<llvm::Value *>(RetTy)));<br>
> > + ReplaceMap.emplace_back(<br>
> > + std::piecewise_construct, std::make_tuple(Ty),<br>
> > + std::make_tuple(static_cast<llvm::Metadata *>(RetTy)));<br>
> > return RetTy;<br>
> > }<br>
> ><br>
> > @@ -1951,7 +1949,7 @@ llvm::DIType CGDebugInfo::CreateTypeDefi<br>
> > SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);<br>
> ><br>
> > // Create DIEnumerator elements for each enumerator.<br>
> > - SmallVector<llvm::Value *, 16> Enumerators;<br>
> > + SmallVector<llvm::Metadata *, 16> Enumerators;<br>
> > ED = ED->getDefinition();<br>
> > for (const auto *Enum : ED->enumerators()) {<br>
> > Enumerators.push_back(DBuilder.createEnumerator(<br>
> > @@ -2039,7 +2037,7 @@ llvm::DIType CGDebugInfo::getTypeOrNull(<br>
> > auto it = TypeCache.find(Ty.getAsOpaquePtr());<br>
> > if (it != TypeCache.end()) {<br>
> > // Verify that the debug info still exists.<br>
> > - if (llvm::Value *V = it->second)<br>
> > + if (llvm::Metadata *V = it->second)<br>
> > return llvm::DIType(cast<llvm::MDNode>(V));<br>
> > }<br>
> ><br>
> > @@ -2074,7 +2072,7 @@ llvm::DIType CGDebugInfo::getOrCreateTyp<br>
> > void *TyPtr = Ty.getAsOpaquePtr();<br>
> ><br>
> > // And update the type cache.<br>
> > - TypeCache[TyPtr] = Res;<br>
> > + TypeCache[TyPtr].reset(Res);<br>
> ><br>
> > return Res;<br>
> > }<br>
> > @@ -2209,7 +2207,7 @@ llvm::DIType CGDebugInfo::getOrCreateLim<br>
> > Res.setArrays(T.getElements());<br>
> ><br>
> > // And update the type cache.<br>
> > - TypeCache[QTy.getAsOpaquePtr()] = Res;<br>
> > + TypeCache[QTy.getAsOpaquePtr()].reset(Res);<br>
> > return Res;<br>
> > }<br>
> ><br>
> > @@ -2257,8 +2255,8 @@ llvm::DICompositeType CGDebugInfo::Creat<br>
> > RDContext, RDName, DefUnit, Line, Size, Align, 0, llvm::DIType(),<br>
> > llvm::DIArray(), 0, llvm::DIType(), FullName);<br>
> ><br>
> > - RegionMap[Ty->getDecl()] = llvm::WeakVH(RealDecl);<br>
> > - TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl;<br>
> > + RegionMap[Ty->getDecl()].reset(RealDecl);<br>
> > + TypeCache[QualType(Ty, 0).getAsOpaquePtr()].reset(RealDecl);<br>
> ><br>
> > if (const ClassTemplateSpecializationDecl *TSpecial =<br>
> > dyn_cast<ClassTemplateSpecializationDecl>(RD))<br>
> > @@ -2401,8 +2399,9 @@ CGDebugInfo::getFunctionForwardDeclarati<br>
> > CGM.getLangOpts().Optimize, nullptr,<br>
> > TParamsArray, getFunctionDeclaration(FD));<br>
> > const FunctionDecl *CanonDecl = cast<FunctionDecl>(FD->getCanonicalDecl());<br>
> > - FwdDeclReplaceMap.push_back(std::make_pair(CanonDecl,<br>
> > - static_cast<llvm::Value *>(SP)));<br>
> > + FwdDeclReplaceMap.emplace_back(<br>
> > + std::piecewise_construct, std::make_tuple(CanonDecl),<br>
> > + std::make_tuple(static_cast<llvm::Metadata *>(SP)));<br>
> > return SP;<br>
> > }<br>
> ><br>
> > @@ -2421,8 +2420,10 @@ CGDebugInfo::getGlobalVariableForwardDec<br>
> > Line, getOrCreateType(T, Unit),<br>
> > !VD->isExternallyVisible(),<br>
> > nullptr, nullptr);<br>
> > - FwdDeclReplaceMap.push_back(std::make_pair(cast<VarDecl>(VD->getCanonicalDecl()),<br>
> > - static_cast<llvm::Value *>(GV)));<br>
> > + FwdDeclReplaceMap.emplace_back(<br>
> > + std::piecewise_construct,<br>
> > + std::make_tuple(cast<VarDecl>(VD->getCanonicalDecl())),<br>
> > + std::make_tuple(static_cast<llvm::Metadata *>(GV)));<br>
> > return GV;<br>
> > }<br>
> ><br>
> > @@ -2434,13 +2435,10 @@ llvm::DIDescriptor CGDebugInfo::getDecla<br>
> > if (const TypeDecl *TD = dyn_cast<TypeDecl>(D))<br>
> > return getOrCreateType(CGM.getContext().getTypeDeclType(TD),<br>
> > getOrCreateFile(TD->getLocation()));<br>
> > - llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator I =<br>
> > - DeclCache.find(D->getCanonicalDecl());<br>
> > + auto I = DeclCache.find(D->getCanonicalDecl());<br>
> ><br>
> > - if (I != DeclCache.end()) {<br>
> > - llvm::Value *V = I->second;<br>
> > - return llvm::DIDescriptor(dyn_cast_or_null<llvm::MDNode>(V));<br>
> > - }<br>
> > + if (I != DeclCache.end())<br>
> > + return llvm::DIDescriptor(dyn_cast_or_null<llvm::MDNode>(I->second));<br>
> ><br>
> > // No definition for now. Emit a forward definition that might be<br>
> > // merged with a potential upcoming definition.<br>
> > @@ -2465,8 +2463,7 @@ llvm::DISubprogram CGDebugInfo::getFunct<br>
> > // Setup context.<br>
> > llvm::DIScope S = getContextDescriptor(cast<Decl>(D->getDeclContext()));<br>
> ><br>
> > - llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator MI =<br>
> > - SPCache.find(FD->getCanonicalDecl());<br>
> > + auto MI = SPCache.find(FD->getCanonicalDecl());<br>
> > if (MI == SPCache.end()) {<br>
> > if (const CXXMethodDecl *MD =<br>
> > dyn_cast<CXXMethodDecl>(FD->getCanonicalDecl())) {<br>
> > @@ -2477,18 +2474,15 @@ llvm::DISubprogram CGDebugInfo::getFunct<br>
> > }<br>
> > }<br>
> > if (MI != SPCache.end()) {<br>
> > - llvm::Value *V = MI->second;<br>
> > - llvm::DISubprogram SP(dyn_cast_or_null<llvm::MDNode>(V));<br>
> > + llvm::DISubprogram SP(dyn_cast_or_null<llvm::MDNode>(MI->second));<br>
> > if (SP.isSubprogram() && !SP.isDefinition())<br>
> > return SP;<br>
> > }<br>
> ><br>
> > for (auto NextFD : FD->redecls()) {<br>
> > - llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator MI =<br>
> > - SPCache.find(NextFD->getCanonicalDecl());<br>
> > + auto MI = SPCache.find(NextFD->getCanonicalDecl());<br>
> > if (MI != SPCache.end()) {<br>
> > - llvm::Value *V = MI->second;<br>
> > - llvm::DISubprogram SP(dyn_cast_or_null<llvm::MDNode>(V));<br>
> > + llvm::DISubprogram SP(dyn_cast_or_null<llvm::MDNode>(MI->second));<br>
> > if (SP.isSubprogram() && !SP.isDefinition())<br>
> > return SP;<br>
> > }<br>
> > @@ -2513,7 +2507,7 @@ llvm::DICompositeType CGDebugInfo::getOr<br>
> > return getOrCreateMethodType(Method, F);<br>
> > if (const ObjCMethodDecl *OMethod = dyn_cast<ObjCMethodDecl>(D)) {<br>
> > // Add "self" and "_cmd"<br>
> > - SmallVector<llvm::Value *, 16> Elts;<br>
> > + SmallVector<llvm::Metadata *, 16> Elts;<br>
> ><br>
> > // First element is always return type. For 'void' functions it is NULL.<br>
> > QualType ResultTy = OMethod->getReturnType();<br>
> > @@ -2546,7 +2540,7 @@ llvm::DICompositeType CGDebugInfo::getOr<br>
> > // unspecified parameter.<br>
> > if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))<br>
> > if (FD->isVariadic()) {<br>
> > - SmallVector<llvm::Value *, 16> EltTys;<br>
> > + SmallVector<llvm::Metadata *, 16> EltTys;<br>
> > EltTys.push_back(getOrCreateType(FD->getReturnType(), F));<br>
> > if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FnType))<br>
> > for (unsigned i = 0, e = FPT->getNumParams(); i != e; ++i)<br>
> > @@ -2581,15 +2575,13 @@ void CGDebugInfo::EmitFunctionStart(Glob<br>
> > LinkageName = Fn->getName();<br>
> > } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {<br>
> > // If there is a DISubprogram for this function available then use it.<br>
> > - llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator FI =<br>
> > - SPCache.find(FD->getCanonicalDecl());<br>
> > + auto FI = SPCache.find(FD->getCanonicalDecl());<br>
> > if (FI != SPCache.end()) {<br>
> > - llvm::Value *V = FI->second;<br>
> > - llvm::DIDescriptor SP(dyn_cast_or_null<llvm::MDNode>(V));<br>
> > + llvm::DIDescriptor SP(dyn_cast_or_null<llvm::MDNode>(FI->second));<br>
> > if (SP.isSubprogram() && llvm::DISubprogram(SP).isDefinition()) {<br>
> > llvm::MDNode *SPN = SP;<br>
> > - LexicalBlockStack.push_back(SPN);<br>
> > - RegionMap[D] = llvm::WeakVH(SP);<br>
> > + LexicalBlockStack.emplace_back(SPN);<br>
> > + RegionMap[D].reset(SP);<br>
> > return;<br>
> > }<br>
> > }<br>
> > @@ -2629,14 +2621,14 @@ void CGDebugInfo::EmitFunctionStart(Glob<br>
> > // code for the initialization of globals. Do not record these decls<br>
> > // as they will overwrite the actual VarDecl Decl in the cache.<br>
> > if (HasDecl && isa<FunctionDecl>(D))<br>
> > - DeclCache.insert(std::make_pair(D->getCanonicalDecl(), llvm::WeakVH(SP)));<br>
> > + DeclCache[D->getCanonicalDecl()].reset(static_cast<llvm::Metadata *>(SP));<br>
> ><br>
> > // Push the function onto the lexical block stack.<br>
> > llvm::MDNode *SPN = SP;<br>
> > - LexicalBlockStack.push_back(SPN);<br>
> > + LexicalBlockStack.emplace_back(SPN);<br>
> ><br>
> > if (HasDecl)<br>
> > - RegionMap[D] = llvm::WeakVH(SP);<br>
> > + RegionMap[D].reset(SP);<br>
> > }<br>
> ><br>
> > /// EmitLocation - Emit metadata to indicate a change in line/column<br>
> > @@ -2676,7 +2668,7 @@ void CGDebugInfo::CreateLexicalBlock(Sou<br>
> > : LexicalBlockStack.back()),<br>
> > getOrCreateFile(CurLoc), getLineNumber(CurLoc), getColumnNumber(CurLoc));<br>
> > llvm::MDNode *DN = D;<br>
> > - LexicalBlockStack.push_back(DN);<br>
> > + LexicalBlockStack.emplace_back(DN);<br>
> > }<br>
> ><br>
> > /// EmitLexicalBlockStart - Constructs the debug code for entering a declarative<br>
> > @@ -2732,7 +2724,7 @@ void CGDebugInfo::EmitFunctionEnd(CGBuil<br>
> > llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,<br>
> > uint64_t *XOffset) {<br>
> ><br>
> > - SmallVector<llvm::Value *, 5> EltTys;<br>
> > + SmallVector<llvm::Metadata *, 5> EltTys;<br>
> > QualType FType;<br>
> > uint64_t FieldSize, FieldOffset;<br>
> > unsigned FieldAlign;<br>
> > @@ -3047,7 +3039,7 @@ void CGDebugInfo::EmitDeclareOfBlockLite<br>
> > const llvm::StructLayout *blockLayout =<br>
> > CGM.getDataLayout().getStructLayout(block.StructureType);<br>
> ><br>
> > - SmallVector<llvm::Value *, 16> fields;<br>
> > + SmallVector<llvm::Metadata *, 16> fields;<br>
> > fields.push_back(createFieldType("__isa", C.VoidPtrTy, 0, loc, AS_public,<br>
> > blockLayout->getElementOffsetInBits(0),<br>
> > tunit, tunit));<br>
> > @@ -3181,8 +3173,7 @@ llvm::DIDerivedType<br>
> > CGDebugInfo::getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D) {<br>
> > if (!D->isStaticDataMember())<br>
> > return llvm::DIDerivedType();<br>
> > - llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator MI =<br>
> > - StaticDataMemberCache.find(D->getCanonicalDecl());<br>
> > + auto MI = StaticDataMemberCache.find(D->getCanonicalDecl());<br>
> > if (MI != StaticDataMemberCache.end()) {<br>
> > assert(MI->second && "Static data member declaration should still exist");<br>
> > return llvm::DIDerivedType(cast<llvm::MDNode>(MI->second));<br>
> > @@ -3255,7 +3246,7 @@ void CGDebugInfo::EmitGlobalVariable(llv<br>
> > Var->hasInternalLinkage(), Var,<br>
> > getOrCreateStaticDataMemberDeclarationOrNull(D));<br>
> > }<br>
> > - DeclCache.insert(std::make_pair(D->getCanonicalDecl(), llvm::WeakVH(GV)));<br>
> > + DeclCache[D->getCanonicalDecl()].reset(static_cast<llvm::Metadata *>(GV));<br>
> > }<br>
> ><br>
> > /// EmitGlobalVariable - Emit global variable's debug info.<br>
> > @@ -3291,13 +3282,12 @@ void CGDebugInfo::EmitGlobalVariable(con<br>
> > llvm::DIDescriptor DContext =<br>
> > getContextDescriptor(dyn_cast<Decl>(VD->getDeclContext()));<br>
> ><br>
> > - auto pair = DeclCache.insert(std::make_pair(VD, llvm::WeakVH()));<br>
> > - if (!pair.second)<br>
> > + auto &GV = DeclCache[VD];<br>
> > + if (GV)<br>
> > return;<br>
> > - llvm::DIGlobalVariable GV = DBuilder.createGlobalVariable(<br>
> > + GV.reset(DBuilder.createGlobalVariable(<br>
> > DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty,<br>
> > - true, Init, getOrCreateStaticDataMemberDeclarationOrNull(VarD));<br>
> > - pair.first->second = llvm::WeakVH(GV);<br>
> > + true, Init, getOrCreateStaticDataMemberDeclarationOrNull(VarD)));<br>
> > }<br>
> ><br>
> > llvm::DIScope CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {<br>
> > @@ -3334,7 +3324,7 @@ llvm::DIImportedEntity<br>
> > CGDebugInfo::EmitNamespaceAlias(const NamespaceAliasDecl &NA) {<br>
> > if (CGM.getCodeGenOpts().getDebugInfo() < CodeGenOptions::LimitedDebugInfo)<br>
> > return llvm::DIImportedEntity(nullptr);<br>
> > - llvm::WeakVH &VH = NamespaceAliasCache[&NA];<br>
> > + auto &VH = NamespaceAliasCache[&NA];<br>
> > if (VH)<br>
> > return llvm::DIImportedEntity(cast<llvm::MDNode>(VH));<br>
> > llvm::DIImportedEntity R(nullptr);<br>
> > @@ -3350,7 +3340,7 @@ CGDebugInfo::EmitNamespaceAlias(const Na<br>
> > getCurrentContextDescriptor(cast<Decl>(NA.getDeclContext())),<br>
> > getOrCreateNameSpace(cast<NamespaceDecl>(NA.getAliasedNamespace())),<br>
> > getLineNumber(NA.getLocation()), NA.getName());<br>
> > - VH = R;<br>
> > + VH.reset(R);<br>
> > return R;<br>
> > }<br>
> ><br>
> > @@ -3359,8 +3349,7 @@ CGDebugInfo::EmitNamespaceAlias(const Na<br>
> > llvm::DINameSpace<br>
> > CGDebugInfo::getOrCreateNameSpace(const NamespaceDecl *NSDecl) {<br>
> > NSDecl = NSDecl->getCanonicalDecl();<br>
> > - llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH>::iterator I =<br>
> > - NameSpaceCache.find(NSDecl);<br>
> > + auto I = NameSpaceCache.find(NSDecl);<br>
> > if (I != NameSpaceCache.end())<br>
> > return llvm::DINameSpace(cast<llvm::MDNode>(I->second));<br>
> ><br>
> > @@ -3370,7 +3359,7 @@ CGDebugInfo::getOrCreateNameSpace(const<br>
> > getContextDescriptor(dyn_cast<Decl>(NSDecl->getDeclContext()));<br>
> > llvm::DINameSpace NS =<br>
> > DBuilder.createNameSpace(Context, NSDecl->getName(), FileD, LineNo);<br>
> > - NameSpaceCache[NSDecl] = llvm::WeakVH(NS);<br>
> > + NameSpaceCache[NSDecl].reset(NS);<br>
> > return NS;<br>
> > }<br>
> ><br>
> > @@ -3401,19 +3390,19 @@ void CGDebugInfo::finalize() {<br>
> > for (const auto &p : FwdDeclReplaceMap) {<br>
> > assert(p.second);<br>
> > llvm::DIDescriptor FwdDecl(cast<llvm::MDNode>(p.second));<br>
> > - llvm::WeakVH VH;<br>
> > + llvm::Metadata *Repl;<br>
> ><br>
> > auto it = DeclCache.find(p.first);<br>
> > // If there has been no definition for the declaration, call RAUV<br>
> > // with ourselves, that will destroy the temporary MDNode and<br>
> > // replace it with a standard one, avoiding leaking memory.<br>
> > if (it == DeclCache.end())<br>
> > - VH = p.second;<br>
> > + Repl = p.second;<br>
> > else<br>
> > - VH = it->second;<br>
> > + Repl = it->second;<br>
> ><br>
> > FwdDecl.replaceAllUsesWith(CGM.getLLVMContext(),<br>
> > - llvm::DIDescriptor(cast<llvm::MDNode>(VH)));<br>
> > + llvm::DIDescriptor(cast<llvm::MDNode>(Repl)));<br>
> > }<br>
> ><br>
> > // We keep our own list of retained types, because we need to look<br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Dec 9 12:39:32 2014<br>
> > @@ -65,7 +65,7 @@ class CGDebugInfo {<br>
> > llvm::DIType BlockLiteralGeneric;<br>
> ><br>
> > /// TypeCache - Cache of previously constructed Types.<br>
> > - llvm::DenseMap<const void *, llvm::WeakVH> TypeCache;<br>
> > + llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;<br>
> ><br>
> > struct ObjCInterfaceCacheEntry {<br>
> > const ObjCInterfaceType *Type;<br>
> > @@ -85,15 +85,16 @@ class CGDebugInfo {<br>
> ><br>
> > /// ReplaceMap - Cache of forward declared types to RAUW at the end of<br>
> > /// compilation.<br>
> > - std::vector<std::pair<const TagType *, llvm::WeakVH>> ReplaceMap;<br>
> > + std::vector<std::pair<const TagType *, llvm::TrackingMDRef>> ReplaceMap;<br>
> ><br>
> > /// \brief Cache of replaceable forward declarartions (functions and<br>
> > /// variables) to RAUW at the end of compilation.<br>
> > - std::vector<std::pair<const DeclaratorDecl *, llvm::WeakVH>> FwdDeclReplaceMap;<br>
> > + std::vector<std::pair<const DeclaratorDecl *, llvm::TrackingMDRef>><br>
> > + FwdDeclReplaceMap;<br>
> ><br>
> > // LexicalBlockStack - Keep track of our current nested lexical block.<br>
> > - std::vector<llvm::TrackingVH<llvm::MDNode> > LexicalBlockStack;<br>
> > - llvm::DenseMap<const Decl *, llvm::WeakVH> RegionMap;<br>
> > + std::vector<llvm::TrackingMDNodeRef> LexicalBlockStack;<br>
> > + llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;<br>
> > // FnBeginRegionCount - Keep track of LexicalBlockStack counter at the<br>
> > // beginning of a function. This is used to pop unbalanced regions at<br>
> > // the end of a function.<br>
> > @@ -104,14 +105,15 @@ class CGDebugInfo {<br>
> > llvm::BumpPtrAllocator DebugInfoNames;<br>
> > StringRef CWDName;<br>
> ><br>
> > - llvm::DenseMap<const char *, llvm::WeakVH> DIFileCache;<br>
> > - llvm::DenseMap<const FunctionDecl *, llvm::WeakVH> SPCache;<br>
> > + llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;<br>
> > + llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;<br>
> > /// \brief Cache declarations relevant to DW_TAG_imported_declarations (C++<br>
> > /// using declarations) that aren't covered by other more specific caches.<br>
> > - llvm::DenseMap<const Decl *, llvm::WeakVH> DeclCache;<br>
> > - llvm::DenseMap<const NamespaceDecl *, llvm::WeakVH> NameSpaceCache;<br>
> > - llvm::DenseMap<const NamespaceAliasDecl *, llvm::WeakVH> NamespaceAliasCache;<br>
> > - llvm::DenseMap<const Decl *, llvm::WeakVH> StaticDataMemberCache;<br>
> > + llvm::DenseMap<const Decl *, llvm::TrackingMDRef> DeclCache;<br>
> > + llvm::DenseMap<const NamespaceDecl *, llvm::TrackingMDRef> NameSpaceCache;<br>
> > + llvm::DenseMap<const NamespaceAliasDecl *, llvm::TrackingMDRef><br>
> > + NamespaceAliasCache;<br>
> > + llvm::DenseMap<const Decl *, llvm::TrackingMDRef> StaticDataMemberCache;<br>
> ><br>
> > /// Helper functions for getOrCreateType.<br>
> > unsigned Checksum(const ObjCInterfaceDecl *InterfaceDecl);<br>
> > @@ -162,14 +164,12 @@ class CGDebugInfo {<br>
> > llvm::DIFile F,<br>
> > llvm::DIType RecordTy);<br>
> ><br>
> > - void CollectCXXMemberFunctions(const CXXRecordDecl *Decl,<br>
> > - llvm::DIFile F,<br>
> > - SmallVectorImpl<llvm::Value *> &E,<br>
> > + void CollectCXXMemberFunctions(const CXXRecordDecl *Decl, llvm::DIFile F,<br>
> > + SmallVectorImpl<llvm::Metadata *> &E,<br>
> > llvm::DIType T);<br>
> ><br>
> > - void CollectCXXBases(const CXXRecordDecl *Decl,<br>
> > - llvm::DIFile F,<br>
> > - SmallVectorImpl<llvm::Value *> &EltTys,<br>
> > + void CollectCXXBases(const CXXRecordDecl *Decl, llvm::DIFile F,<br>
> > + SmallVectorImpl<llvm::Metadata *> &EltTys,<br>
> > llvm::DIType RecordTy);<br>
> ><br>
> > llvm::DIArray<br>
> > @@ -192,23 +192,21 @@ class CGDebugInfo {<br>
> ><br>
> > // Helpers for collecting fields of a record.<br>
> > void CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl,<br>
> > - SmallVectorImpl<llvm::Value *> &E,<br>
> > + SmallVectorImpl<llvm::Metadata *> &E,<br>
> > llvm::DIType RecordTy);<br>
> > llvm::DIDerivedType CreateRecordStaticField(const VarDecl *Var,<br>
> > llvm::DIType RecordTy,<br>
> > const RecordDecl* RD);<br>
> > void CollectRecordNormalField(const FieldDecl *Field, uint64_t OffsetInBits,<br>
> > llvm::DIFile F,<br>
> > - SmallVectorImpl<llvm::Value *> &E,<br>
> > - llvm::DIType RecordTy,<br>
> > - const RecordDecl* RD);<br>
> > + SmallVectorImpl<llvm::Metadata *> &E,<br>
> > + llvm::DIType RecordTy, const RecordDecl *RD);<br>
> > void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile F,<br>
> > - SmallVectorImpl<llvm::Value *> &E,<br>
> > + SmallVectorImpl<llvm::Metadata *> &E,<br>
> > llvm::DICompositeType RecordTy);<br>
> ><br>
> > - void CollectVTableInfo(const CXXRecordDecl *Decl,<br>
> > - llvm::DIFile F,<br>
> > - SmallVectorImpl<llvm::Value *> &EltTys);<br>
> > + void CollectVTableInfo(const CXXRecordDecl *Decl, llvm::DIFile F,<br>
> > + SmallVectorImpl<llvm::Metadata *> &EltTys);<br>
> ><br>
> > // CreateLexicalBlock - Create a new lexical block node and push it on<br>
> > // the stack.<br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Dec 9 12:39:32 2014<br>
> > @@ -1415,8 +1415,8 @@ llvm::Value *CodeGenFunction::EmitExtVec<br>
> > RValue CodeGenFunction::EmitLoadOfGlobalRegLValue(LValue LV) {<br>
> > assert((LV.getType()->isIntegerType() || LV.getType()->isPointerType()) &&<br>
> > "Bad type for register variable");<br>
> > - llvm::MDNode *RegName = dyn_cast<llvm::MDNode>(LV.getGlobalReg());<br>
> > - assert(RegName && "Register LValue is not metadata");<br>
> > + llvm::MDNode *RegName = cast<llvm::MDNode>(<br>
> > + cast<llvm::MetadataAsValue>(LV.getGlobalReg())->getMetadata());<br>
> ><br>
> > // We accept integer and pointer types only<br>
> > llvm::Type *OrigTy = CGM.getTypes().ConvertType(LV.getType());<br>
> > @@ -1426,7 +1426,8 @@ RValue CodeGenFunction::EmitLoadOfGlobal<br>
> > llvm::Type *Types[] = { Ty };<br>
> ><br>
> > llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::read_register, Types);<br>
> > - llvm::Value *Call = Builder.CreateCall(F, RegName);<br>
> > + llvm::Value *Call = Builder.CreateCall(<br>
> > + F, llvm::MetadataAsValue::get(Ty->getContext(), RegName));<br>
> > if (OrigTy->isPointerTy())<br>
> > Call = Builder.CreateIntToPtr(Call, OrigTy);<br>
> > return RValue::get(Call);<br>
> > @@ -1680,7 +1681,8 @@ void CodeGenFunction::EmitStoreThroughEx<br>
> > void CodeGenFunction::EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst) {<br>
> > assert((Dst.getType()->isIntegerType() || Dst.getType()->isPointerType()) &&<br>
> > "Bad type for register variable");<br>
> > - llvm::MDNode *RegName = dyn_cast<llvm::MDNode>(Dst.getGlobalReg());<br>
> > + llvm::MDNode *RegName = cast<llvm::MDNode>(<br>
> > + cast<llvm::MetadataAsValue>(Dst.getGlobalReg())->getMetadata());<br>
> > assert(RegName && "Register LValue is not metadata");<br>
> ><br>
> > // We accept integer and pointer types only<br>
> > @@ -1694,7 +1696,8 @@ void CodeGenFunction::EmitStoreThroughGl<br>
> > llvm::Value *Value = Src.getScalarVal();<br>
> > if (OrigTy->isPointerTy())<br>
> > Value = Builder.CreatePtrToInt(Value, Ty);<br>
> > - Builder.CreateCall2(F, RegName, Value);<br>
> > + Builder.CreateCall2(F, llvm::MetadataAsValue::get(Ty->getContext(), RegName),<br>
> > + Value);<br>
> > }<br>
> ><br>
> > // setObjCGCLValueClass - sets class of the lvalue for the purpose of<br>
> > @@ -1889,10 +1892,12 @@ static LValue EmitGlobalNamedRegister(co<br>
> > if (M->getNumOperands() == 0) {<br>
> > llvm::MDString *Str = llvm::MDString::get(CGM.getLLVMContext(),<br>
> > Asm->getLabel());<br>
> > - llvm::Value *Ops[] = { Str };<br>
> > + llvm::Metadata *Ops[] = {Str};<br>
> > M->addOperand(llvm::MDNode::get(CGM.getLLVMContext(), Ops));<br>
> > }<br>
> > - return LValue::MakeGlobalReg(M->getOperand(0), VD->getType(), Alignment);<br>
> > + return LValue::MakeGlobalReg(<br>
> > + llvm::MetadataAsValue::get(CGM.getLLVMContext(), M->getOperand(0)),<br>
> > + VD->getType(), Alignment);<br>
> > }<br>
> ><br>
> > LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {<br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CGLoopInfo.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.cpp?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CGLoopInfo.cpp (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CGLoopInfo.cpp Tue Dec 9 12:39:32 2014<br>
> > @@ -24,40 +24,39 @@ static MDNode *createMetadata(LLVMContex<br>
> > Attrs.VectorizerEnable == LoopAttributes::VecUnspecified)<br>
> > return nullptr;<br>
> ><br>
> > - SmallVector<Value *, 4> Args;<br>
> > + SmallVector<Metadata *, 4> Args;<br>
> > // Reserve operand 0 for loop id self reference.<br>
> > MDNode *TempNode = MDNode::getTemporary(Ctx, None);<br>
> > Args.push_back(TempNode);<br>
> ><br>
> > // Setting vectorizer.width<br>
> > if (Attrs.VectorizerWidth > 0) {<br>
> > - Value *Vals[] = { MDString::get(Ctx, "llvm.loop.vectorize.width"),<br>
> > - ConstantInt::get(Type::getInt32Ty(Ctx),<br>
> > - Attrs.VectorizerWidth) };<br>
> > + Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.vectorize.width"),<br>
> > + ConstantAsMetadata::get(ConstantInt::get(<br>
> > + Type::getInt32Ty(Ctx), Attrs.VectorizerWidth))};<br>
> > Args.push_back(MDNode::get(Ctx, Vals));<br>
> > }<br>
> ><br>
> > // Setting vectorizer.unroll<br>
> > if (Attrs.VectorizerUnroll > 0) {<br>
> > - Value *Vals[] = { MDString::get(Ctx, "llvm.loop.interleave.count"),<br>
> > - ConstantInt::get(Type::getInt32Ty(Ctx),<br>
> > - Attrs.VectorizerUnroll) };<br>
> > + Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.interleave.count"),<br>
> > + ConstantAsMetadata::get(ConstantInt::get(<br>
> > + Type::getInt32Ty(Ctx), Attrs.VectorizerUnroll))};<br>
> > Args.push_back(MDNode::get(Ctx, Vals));<br>
> > }<br>
> ><br>
> > // Setting vectorizer.enable<br>
> > if (Attrs.VectorizerEnable != LoopAttributes::VecUnspecified) {<br>
> > - Value *Vals[] = { MDString::get(Ctx, "llvm.loop.vectorize.enable"),<br>
> > - ConstantInt::get(Type::getInt1Ty(Ctx),<br>
> > - (Attrs.VectorizerEnable ==<br>
> > - LoopAttributes::VecEnable)) };<br>
> > + Metadata *Vals[] = {<br>
> > + MDString::get(Ctx, "llvm.loop.vectorize.enable"),<br>
> > + ConstantAsMetadata::get(ConstantInt::get(<br>
> > + Type::getInt1Ty(Ctx),<br>
> > + (Attrs.VectorizerEnable == LoopAttributes::VecEnable)))};<br>
> > Args.push_back(MDNode::get(Ctx, Vals));<br>
> > }<br>
> ><br>
> > - MDNode *LoopID = MDNode::get(Ctx, Args);<br>
> > - assert(LoopID->use_empty() && "LoopID should not be used");<br>
> > -<br>
> > // Set the first operand to itself.<br>
> > + MDNode *LoopID = MDNode::get(Ctx, Args);<br>
> > LoopID->replaceOperandWith(0, LoopID);<br>
> > MDNode::deleteTemporary(TempNode);<br>
> > return LoopID;<br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CGObjC.cpp Tue Dec 9 12:39:32 2014<br>
> > @@ -1938,9 +1938,8 @@ llvm::Value *CodeGenFunction::EmitARCRet<br>
> > = cast<llvm::CallInst>(result->stripPointerCasts());<br>
> > assert(call->getCalledValue() == CGM.getARCEntrypoints().objc_retainBlock);<br>
> ><br>
> > - SmallVector<llvm::Value*,1> args;<br>
> > call->setMetadata("clang.arc.copy_on_escape",<br>
> > - llvm::MDNode::get(Builder.getContext(), args));<br>
> > + llvm::MDNode::get(Builder.getContext(), None));<br>
> > }<br>
> ><br>
> > return result;<br>
> > @@ -1982,8 +1981,8 @@ CodeGenFunction::EmitARCRetainAutoreleas<br>
> > "clang.arc.retainAutoreleasedReturnValueMarker");<br>
> > assert(metadata->getNumOperands() <= 1);<br>
> > if (metadata->getNumOperands() == 0) {<br>
> > - llvm::Value *string = llvm::MDString::get(getLLVMContext(), assembly);<br>
> > - metadata->addOperand(llvm::MDNode::get(getLLVMContext(), string));<br>
> > + metadata->addOperand(llvm::MDNode::get(<br>
> > + getLLVMContext(), llvm::MDString::get(getLLVMContext(), assembly)));<br>
> > }<br>
> > }<br>
> > }<br>
> > @@ -2016,9 +2015,8 @@ void CodeGenFunction::EmitARCRelease(llv<br>
> > llvm::CallInst *call = EmitNounwindRuntimeCall(fn, value);<br>
> ><br>
> > if (precise == ARCImpreciseLifetime) {<br>
> > - SmallVector<llvm::Value*,1> args;<br>
> > call->setMetadata("clang.imprecise_release",<br>
> > - llvm::MDNode::get(Builder.getContext(), args));<br>
> > + llvm::MDNode::get(Builder.getContext(), None));<br>
> > }<br>
> > }<br>
> ><br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Tue Dec 9 12:39:32 2014<br>
> > @@ -1296,11 +1296,11 @@ CGObjCGNU::GenerateMessageSendSuper(Code<br>
> > llvm::Value *imp = LookupIMPSuper(CGF, ObjCSuper, cmd, MSI);<br>
> > imp = EnforceType(Builder, imp, MSI.MessengerType);<br>
> ><br>
> > - llvm::Value *impMD[] = {<br>
> > + llvm::Metadata *impMD[] = {<br>
> > llvm::MDString::get(VMContext, Sel.getAsString()),<br>
> > llvm::MDString::get(VMContext, Class->getSuperClass()->getNameAsString()),<br>
> > - llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), IsClassMessage)<br>
> > - };<br>
> > + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(<br>
> > + llvm::Type::getInt1Ty(VMContext), IsClassMessage))};<br>
> > llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD);<br>
> ><br>
> > llvm::Instruction *call;<br>
> > @@ -1371,12 +1371,11 @@ CGObjCGNU::GenerateMessageSend(CodeGenFu<br>
> > cmd = EnforceType(Builder, cmd, SelectorTy);<br>
> > Receiver = EnforceType(Builder, Receiver, IdTy);<br>
> ><br>
> > - llvm::Value *impMD[] = {<br>
> > - llvm::MDString::get(VMContext, Sel.getAsString()),<br>
> > - llvm::MDString::get(VMContext, Class ? Class->getNameAsString() :""),<br>
> > - llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext),<br>
> > - Class!=nullptr)<br>
> > - };<br>
> > + llvm::Metadata *impMD[] = {<br>
> > + llvm::MDString::get(VMContext, Sel.getAsString()),<br>
> > + llvm::MDString::get(VMContext, Class ? Class->getNameAsString() : ""),<br>
> > + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(<br>
> > + llvm::Type::getInt1Ty(VMContext), Class != nullptr))};<br>
> > llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD);<br>
> ><br>
> > CallArgList ActualArgs;<br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Dec 9 12:39:32 2014<br>
> > @@ -4278,11 +4278,10 @@ void CGObjCCommonMac::EmitImageInfo() {<br>
> > eImageInfo_GCOnly);<br>
> ><br>
> > // Require that GC be specified and set to eImageInfo_GarbageCollected.<br>
> > - llvm::Value *Ops[2] = {<br>
> > - llvm::MDString::get(VMContext, "Objective-C Garbage Collection"),<br>
> > - llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),<br>
> > - eImageInfo_GarbageCollected)<br>
> > - };<br>
> > + llvm::Metadata *Ops[2] = {<br>
> > + llvm::MDString::get(VMContext, "Objective-C Garbage Collection"),<br>
> > + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(<br>
> > + llvm::Type::getInt32Ty(VMContext), eImageInfo_GarbageCollected))};<br>
> > Mod.addModuleFlag(llvm::Module::Require, "Objective-C GC Only",<br>
> > llvm::MDNode::get(VMContext, Ops));<br>
> > }<br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Dec 9 12:39:32 2014<br>
> > @@ -591,7 +591,9 @@ void CodeGenFunction::EmitCondBrHints(ll<br>
> > return;<br>
> ><br>
> > // Add vectorize and unroll hints to the metadata on the conditional branch.<br>
> > - SmallVector<llvm::Value *, 2> Metadata(1);<br>
> > + //<br>
> > + // FIXME: Should this really start with a size of 1?<br>
> > + SmallVector<llvm::Metadata *, 2> Metadata(1);<br>
> > for (const auto *Attr : Attrs) {<br>
> > const LoopHintAttr *LH = dyn_cast<LoopHintAttr>(Attr);<br>
> ><br>
> > @@ -629,7 +631,7 @@ void CodeGenFunction::EmitCondBrHints(ll<br>
> > ValueInt = static_cast<int>(ValueAPS.getSExtValue());<br>
> > }<br>
> ><br>
> > - llvm::Value *Value;<br>
> > + llvm::Constant *Value;<br>
> > llvm::MDString *Name;<br>
> > switch (Option) {<br>
> > case LoopHintAttr::Vectorize:<br>
> > @@ -656,15 +658,16 @@ void CodeGenFunction::EmitCondBrHints(ll<br>
> > break;<br>
> > }<br>
> ><br>
> > - SmallVector<llvm::Value *, 2> OpValues;<br>
> > + SmallVector<llvm::Metadata *, 2> OpValues;<br>
> > OpValues.push_back(Name);<br>
> > if (Value)<br>
> > - OpValues.push_back(Value);<br>
> > + OpValues.push_back(llvm::ConstantAsMetadata::get(Value));<br>
> ><br>
> > // Set or overwrite metadata indicated by Name.<br>
> > Metadata.push_back(llvm::MDNode::get(Context, OpValues));<br>
> > }<br>
> ><br>
> > + // FIXME: This condition is never false. Should it be an assert?<br>
> > if (!Metadata.empty()) {<br>
> > // Add llvm.loop MDNode to CondBr.<br>
> > llvm::MDNode *LoopID = llvm::MDNode::get(Context, Metadata);<br>
> > @@ -1766,10 +1769,10 @@ llvm::Value* CodeGenFunction::EmitAsmInp<br>
> > /// asm.<br>
> > static llvm::MDNode *getAsmSrcLocInfo(const StringLiteral *Str,<br>
> > CodeGenFunction &CGF) {<br>
> > - SmallVector<llvm::Value *, 8> Locs;<br>
> > + SmallVector<llvm::Metadata *, 8> Locs;<br>
> > // Add the location of the first line to the MDNode.<br>
> > - Locs.push_back(llvm::ConstantInt::get(CGF.Int32Ty,<br>
> > - Str->getLocStart().getRawEncoding()));<br>
> > + Locs.push_back(llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(<br>
> > + CGF.Int32Ty, Str->getLocStart().getRawEncoding())));<br>
> > StringRef StrVal = Str->getString();<br>
> > if (!StrVal.empty()) {<br>
> > const SourceManager &SM = CGF.CGM.getContext().getSourceManager();<br>
> > @@ -1781,8 +1784,8 @@ static llvm::MDNode *getAsmSrcLocInfo(co<br>
> > if (StrVal[i] != '\n') continue;<br>
> > SourceLocation LineLoc = Str->getLocationOfByte(i+1, SM, LangOpts,<br>
> > CGF.getTarget());<br>
> > - Locs.push_back(llvm::ConstantInt::get(CGF.Int32Ty,<br>
> > - LineLoc.getRawEncoding()));<br>
> > + Locs.push_back(llvm::ConstantAsMetadata::get(<br>
> > + llvm::ConstantInt::get(CGF.Int32Ty, LineLoc.getRawEncoding())));<br>
> > }<br>
> > }<br>
> ><br>
> > @@ -2052,7 +2055,9 @@ void CodeGenFunction::EmitAsmStmt(const<br>
> > } else {<br>
> > // At least put the line number on MS inline asm blobs.<br>
> > auto Loc = llvm::ConstantInt::get(Int32Ty, S.getAsmLoc().getRawEncoding());<br>
> > - Result->setMetadata("srcloc", llvm::MDNode::get(getLLVMContext(), Loc));<br>
> > + Result->setMetadata("srcloc",<br>
> > + llvm::MDNode::get(getLLVMContext(),<br>
> > + llvm::ConstantAsMetadata::get(Loc)));<br>
> > }<br>
> ><br>
> > // Extract all of the register value results from the asm.<br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Dec 9 12:39:32 2014<br>
> > @@ -349,9 +349,9 @@ void CodeGenFunction::EmitMCountInstrume<br>
> > // information in the program executable. The argument information stored<br>
> > // includes the argument name, its type, the address and access qualifiers used.<br>
> > static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn,<br>
> > - CodeGenModule &CGM,llvm::LLVMContext &Context,<br>
> > - SmallVector <llvm::Value*, 5> &kernelMDArgs,<br>
> > - CGBuilderTy& Builder, ASTContext &ASTCtx) {<br>
> > + CodeGenModule &CGM, llvm::LLVMContext &Context,<br>
> > + SmallVector<llvm::Metadata *, 5> &kernelMDArgs,<br>
> > + CGBuilderTy &Builder, ASTContext &ASTCtx) {<br>
> > // Create MDNodes that represent the kernel arg metadata.<br>
> > // Each MDNode is a list in the form of "key", N number of values which is<br>
> > // the same number of values as their are kernel arguments.<br>
> > @@ -359,28 +359,28 @@ static void GenOpenCLArgMetadata(const F<br>
> > const PrintingPolicy &Policy = ASTCtx.getPrintingPolicy();<br>
> ><br>
> > // MDNode for the kernel argument address space qualifiers.<br>
> > - SmallVector<llvm::Value*, 8> addressQuals;<br>
> > + SmallVector<llvm::Metadata *, 8> addressQuals;<br>
> > addressQuals.push_back(llvm::MDString::get(Context, "kernel_arg_addr_space"));<br>
> ><br>
> > // MDNode for the kernel argument access qualifiers (images only).<br>
> > - SmallVector<llvm::Value*, 8> accessQuals;<br>
> > + SmallVector<llvm::Metadata *, 8> accessQuals;<br>
> > accessQuals.push_back(llvm::MDString::get(Context, "kernel_arg_access_qual"));<br>
> ><br>
> > // MDNode for the kernel argument type names.<br>
> > - SmallVector<llvm::Value*, 8> argTypeNames;<br>
> > + SmallVector<llvm::Metadata *, 8> argTypeNames;<br>
> > argTypeNames.push_back(llvm::MDString::get(Context, "kernel_arg_type"));<br>
> ><br>
> > // MDNode for the kernel argument base type names.<br>
> > - SmallVector<llvm::Value*, 8> argBaseTypeNames;<br>
> > + SmallVector<llvm::Metadata *, 8> argBaseTypeNames;<br>
> > argBaseTypeNames.push_back(<br>
> > llvm::MDString::get(Context, "kernel_arg_base_type"));<br>
> ><br>
> > // MDNode for the kernel argument type qualifiers.<br>
> > - SmallVector<llvm::Value*, 8> argTypeQuals;<br>
> > + SmallVector<llvm::Metadata *, 8> argTypeQuals;<br>
> > argTypeQuals.push_back(llvm::MDString::get(Context, "kernel_arg_type_qual"));<br>
> ><br>
> > // MDNode for the kernel argument names.<br>
> > - SmallVector<llvm::Value*, 8> argNames;<br>
> > + SmallVector<llvm::Metadata *, 8> argNames;<br>
> > argNames.push_back(llvm::MDString::get(Context, "kernel_arg_name"));<br>
> ><br>
> > for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) {<br>
> > @@ -392,8 +392,8 @@ static void GenOpenCLArgMetadata(const F<br>
> > QualType pointeeTy = ty->getPointeeType();<br>
> ><br>
> > // Get address qualifier.<br>
> > - addressQuals.push_back(Builder.getInt32(ASTCtx.getTargetAddressSpace(<br>
> > - pointeeTy.getAddressSpace())));<br>
> > + addressQuals.push_back(llvm::ConstantAsMetadata::get(Builder.getInt32(<br>
> > + ASTCtx.getTargetAddressSpace(pointeeTy.getAddressSpace()))));<br>
> ><br>
> > // Get argument type name.<br>
> > std::string typeName =<br>
> > @@ -432,7 +432,8 @@ static void GenOpenCLArgMetadata(const F<br>
> > AddrSpc =<br>
> > CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);<br>
> ><br>
> > - addressQuals.push_back(Builder.getInt32(AddrSpc));<br>
> > + addressQuals.push_back(<br>
> > + llvm::ConstantAsMetadata::get(Builder.getInt32(AddrSpc)));<br>
> ><br>
> > // Get argument type name.<br>
> > std::string typeName = ty.getUnqualifiedType().getAsString(Policy);<br>
> > @@ -495,8 +496,8 @@ void CodeGenFunction::EmitOpenCLKernelMe<br>
> ><br>
> > llvm::LLVMContext &Context = getLLVMContext();<br>
> ><br>
> > - SmallVector <llvm::Value*, 5> kernelMDArgs;<br>
> > - kernelMDArgs.push_back(Fn);<br>
> > + SmallVector<llvm::Metadata *, 5> kernelMDArgs;<br>
> > + kernelMDArgs.push_back(llvm::ConstantAsMetadata::get(Fn));<br>
> ><br>
> > GenOpenCLArgMetadata(FD, Fn, CGM, Context, kernelMDArgs, Builder,<br>
> > getContext());<br>
> > @@ -507,33 +508,31 @@ void CodeGenFunction::EmitOpenCLKernelMe<br>
> > bool isSignedInteger =<br>
> > hintQTy->isSignedIntegerType() ||<br>
> > (hintEltQTy && hintEltQTy->getElementType()->isSignedIntegerType());<br>
> > - llvm::Value *attrMDArgs[] = {<br>
> > - llvm::MDString::get(Context, "vec_type_hint"),<br>
> > - llvm::UndefValue::get(CGM.getTypes().ConvertType(A->getTypeHint())),<br>
> > - llvm::ConstantInt::get(<br>
> > - llvm::IntegerType::get(Context, 32),<br>
> > - llvm::APInt(32, (uint64_t)(isSignedInteger ? 1 : 0)))<br>
> > - };<br>
> > + llvm::Metadata *attrMDArgs[] = {<br>
> > + llvm::MDString::get(Context, "vec_type_hint"),<br>
> > + llvm::ConstantAsMetadata::get(llvm::UndefValue::get(<br>
> > + CGM.getTypes().ConvertType(A->getTypeHint()))),<br>
> > + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(<br>
> > + llvm::IntegerType::get(Context, 32),<br>
> > + llvm::APInt(32, (uint64_t)(isSignedInteger ? 1 : 0))))};<br>
> > kernelMDArgs.push_back(llvm::MDNode::get(Context, attrMDArgs));<br>
> > }<br>
> ><br>
> > if (const WorkGroupSizeHintAttr *A = FD->getAttr<WorkGroupSizeHintAttr>()) {<br>
> > - llvm::Value *attrMDArgs[] = {<br>
> > - llvm::MDString::get(Context, "work_group_size_hint"),<br>
> > - Builder.getInt32(A->getXDim()),<br>
> > - Builder.getInt32(A->getYDim()),<br>
> > - Builder.getInt32(A->getZDim())<br>
> > - };<br>
> > + llvm::Metadata *attrMDArgs[] = {<br>
> > + llvm::MDString::get(Context, "work_group_size_hint"),<br>
> > + llvm::ConstantAsMetadata::get(Builder.getInt32(A->getXDim())),<br>
> > + llvm::ConstantAsMetadata::get(Builder.getInt32(A->getYDim())),<br>
> > + llvm::ConstantAsMetadata::get(Builder.getInt32(A->getZDim()))};<br>
> > kernelMDArgs.push_back(llvm::MDNode::get(Context, attrMDArgs));<br>
> > }<br>
> ><br>
> > if (const ReqdWorkGroupSizeAttr *A = FD->getAttr<ReqdWorkGroupSizeAttr>()) {<br>
> > - llvm::Value *attrMDArgs[] = {<br>
> > - llvm::MDString::get(Context, "reqd_work_group_size"),<br>
> > - Builder.getInt32(A->getXDim()),<br>
> > - Builder.getInt32(A->getYDim()),<br>
> > - Builder.getInt32(A->getZDim())<br>
> > - };<br>
> > + llvm::Metadata *attrMDArgs[] = {<br>
> > + llvm::MDString::get(Context, "reqd_work_group_size"),<br>
> > + llvm::ConstantAsMetadata::get(Builder.getInt32(A->getXDim())),<br>
> > + llvm::ConstantAsMetadata::get(Builder.getInt32(A->getYDim())),<br>
> > + llvm::ConstantAsMetadata::get(Builder.getInt32(A->getZDim()))};<br>
> > kernelMDArgs.push_back(llvm::MDNode::get(Context, attrMDArgs));<br>
> > }<br>
> ><br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Dec 9 12:39:32 2014<br>
> > @@ -952,29 +952,28 @@ void CodeGenModule::emitLLVMUsed() {<br>
> > }<br>
> ><br>
> > void CodeGenModule::AppendLinkerOptions(StringRef Opts) {<br>
> > - llvm::Value *MDOpts = llvm::MDString::get(getLLVMContext(), Opts);<br>
> > + auto *MDOpts = llvm::MDString::get(getLLVMContext(), Opts);<br>
> > LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts));<br>
> > }<br>
> ><br>
> > void CodeGenModule::AddDetectMismatch(StringRef Name, StringRef Value) {<br>
> > llvm::SmallString<32> Opt;<br>
> > getTargetCodeGenInfo().getDetectMismatchOption(Name, Value, Opt);<br>
> > - llvm::Value *MDOpts = llvm::MDString::get(getLLVMContext(), Opt);<br>
> > + auto *MDOpts = llvm::MDString::get(getLLVMContext(), Opt);<br>
> > LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts));<br>
> > }<br>
> ><br>
> > void CodeGenModule::AddDependentLib(StringRef Lib) {<br>
> > llvm::SmallString<24> Opt;<br>
> > getTargetCodeGenInfo().getDependentLibraryOption(Lib, Opt);<br>
> > - llvm::Value *MDOpts = llvm::MDString::get(getLLVMContext(), Opt);<br>
> > + auto *MDOpts = llvm::MDString::get(getLLVMContext(), Opt);<br>
> > LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts));<br>
> > }<br>
> ><br>
> > /// \brief Add link options implied by the given module, including modules<br>
> > /// it depends on, using a postorder walk.<br>
> > -static void addLinkOptionsPostorder(CodeGenModule &CGM,<br>
> > - Module *Mod,<br>
> > - SmallVectorImpl<llvm::Value *> &Metadata,<br>
> > +static void addLinkOptionsPostorder(CodeGenModule &CGM, Module *Mod,<br>
> > + SmallVectorImpl<llvm::Metadata *> &Metadata,<br>
> > llvm::SmallPtrSet<Module *, 16> &Visited) {<br>
> > // Import this module's parent.<br>
> > if (Mod->Parent && Visited.insert(Mod->Parent).second) {<br>
> > @@ -994,10 +993,9 @@ static void addLinkOptionsPostorder(Code<br>
> > // Link against a framework. Frameworks are currently Darwin only, so we<br>
> > // don't to ask TargetCodeGenInfo for the spelling of the linker option.<br>
> > if (Mod->LinkLibraries[I-1].IsFramework) {<br>
> > - llvm::Value *Args[2] = {<br>
> > - llvm::MDString::get(Context, "-framework"),<br>
> > - llvm::MDString::get(Context, Mod->LinkLibraries[I-1].Library)<br>
> > - };<br>
> > + llvm::Metadata *Args[2] = {<br>
> > + llvm::MDString::get(Context, "-framework"),<br>
> > + llvm::MDString::get(Context, Mod->LinkLibraries[I - 1].Library)};<br>
> ><br>
> > Metadata.push_back(llvm::MDNode::get(Context, Args));<br>
> > continue;<br>
> > @@ -1007,7 +1005,7 @@ static void addLinkOptionsPostorder(Code<br>
> > llvm::SmallString<24> Opt;<br>
> > CGM.getTargetCodeGenInfo().getDependentLibraryOption(<br>
> > Mod->LinkLibraries[I-1].Library, Opt);<br>
> > - llvm::Value *OptString = llvm::MDString::get(Context, Opt);<br>
> > + auto *OptString = llvm::MDString::get(Context, Opt);<br>
> > Metadata.push_back(llvm::MDNode::get(Context, OptString));<br>
> > }<br>
> > }<br>
> > @@ -1060,7 +1058,7 @@ void CodeGenModule::EmitModuleLinkOption<br>
> > // Add link options for all of the imported modules in reverse topological<br>
> > // order. We don't do anything to try to order import link flags with respect<br>
> > // to linker options inserted by things like #pragma comment().<br>
> > - SmallVector<llvm::Value *, 16> MetadataArgs;<br>
> > + SmallVector<llvm::Metadata *, 16> MetadataArgs;<br>
> > Visited.clear();<br>
> > for (llvm::SetVector<clang::Module *>::iterator M = LinkModules.begin(),<br>
> > MEnd = LinkModules.end();<br>
> > @@ -3396,10 +3394,9 @@ static void EmitGlobalDeclMetadata(CodeG<br>
> > CGM.getModule().getOrInsertNamedMetadata("clang.global.decl.ptrs");<br>
> ><br>
> > // TODO: should we report variant information for ctors/dtors?<br>
> > - llvm::Value *Ops[] = {<br>
> > - Addr,<br>
> > - GetPointerConstant(CGM.getLLVMContext(), D.getDecl())<br>
> > - };<br>
> > + llvm::Metadata *Ops[] = {llvm::ConstantAsMetadata::get(Addr),<br>
> > + llvm::ConstantAsMetadata::get(GetPointerConstant(<br>
> > + CGM.getLLVMContext(), D.getDecl()))};<br>
> > GlobalMetadata->addOperand(llvm::MDNode::get(CGM.getLLVMContext(), Ops));<br>
> > }<br>
> ><br>
> > @@ -3462,7 +3459,9 @@ void CodeGenFunction::EmitDeclMetadata()<br>
> > llvm::Value *Addr = I.second;<br>
> > if (auto *Alloca = dyn_cast<llvm::AllocaInst>(Addr)) {<br>
> > llvm::Value *DAddr = GetPointerConstant(getLLVMContext(), D);<br>
> > - Alloca->setMetadata(DeclPtrKind, llvm::MDNode::get(Context, DAddr));<br>
> > + Alloca->setMetadata(<br>
> > + DeclPtrKind, llvm::MDNode::get(<br>
> > + Context, llvm::ValueAsMetadata::getConstant(DAddr)));<br>
> > } else if (auto *GV = dyn_cast<llvm::GlobalValue>(Addr)) {<br>
> > GlobalDecl GD = GlobalDecl(cast<VarDecl>(D));<br>
> > EmitGlobalDeclMetadata(CGM, GlobalMetadata, GD, GV);<br>
> > @@ -3476,9 +3475,7 @@ void CodeGenModule::EmitVersionIdentMeta<br>
> > std::string Version = getClangFullVersion();<br>
> > llvm::LLVMContext &Ctx = TheModule.getContext();<br>
> ><br>
> > - llvm::Value *IdentNode[] = {<br>
> > - llvm::MDString::get(Ctx, Version)<br>
> > - };<br>
> > + llvm::Metadata *IdentNode[] = {llvm::MDString::get(Ctx, Version)};<br>
> > IdentMetadata->addOperand(llvm::MDNode::get(Ctx, IdentNode));<br>
> > }<br>
> ><br>
> > @@ -3506,9 +3503,8 @@ void CodeGenModule::EmitCoverageFile() {<br>
> > llvm::MDString::get(Ctx, getCodeGenOpts().CoverageFile);<br>
> > for (int i = 0, e = CUNode->getNumOperands(); i != e; ++i) {<br>
> > llvm::MDNode *CU = CUNode->getOperand(i);<br>
> > - llvm::Value *node[] = { CoverageFile, CU };<br>
> > - llvm::MDNode *N = llvm::MDNode::get(Ctx, node);<br>
> > - GCov->addOperand(N);<br>
> > + llvm::Metadata *Elts[] = {CoverageFile, CU};<br>
> > + GCov->addOperand(llvm::MDNode::get(Ctx, Elts));<br>
> > }<br>
> > }<br>
> > }<br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=223803&r1=223802&r2=223803&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=223803&r1=223802&r2=223803&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)<br>
> > +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Tue Dec 9 12:39:32 2014<br>
> > @@ -421,7 +421,7 @@ class CodeGenModule : public CodeGenType<br>
> > llvm::SetVector<clang::Module *> ImportedModules;<br>
> ><br>
> > /// \brief A vector of metadata strings.<br>
> > - SmallVector<llvm::Value *, 16> LinkerOptionsMetadata;<br>
> > + SmallVector<llvm::Metadata *, 16> LinkerOptionsMetadata;<br>
> ><br>
> > /// @name Cache for Objective-C runtime types<br>
> > /// @{<br>
> > @@ -591,9 +591,7 @@ public:<br>
> ><br>
> > llvm::MDNode *getNoObjCARCExceptionsMetadata() {<br>
> > if (!NoObjCARCExceptionsMetadata)<br>
> > - NoObjCARCExceptionsMetadata =<br>
> > - llvm::MDNode::get(getLLVMContext(),<br>
> > - SmallVector<llvm::Value*,1>());<br>
> > + NoObjCARCExceptionsMetadata = llvm::MDNode::get(getLLVMContext(), None);<br>
> > return NoObjCARCExceptionsMetadata;<br>
> > }<br>
> ><br>
> ><br>
> > Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp<br>
> > URL: <span class=""><font color="#888888"><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp?rev=223803&r1=223802&r2=223803&view=diff" target="_blank"></a></font></span></div></div></blockquote></div></div></blockquote></div></div></blockquote></div></div></blockquote></div></div></div></div></div></div></blockquote></div></div></blockquote></div></div></blockquote></div></div></div></blockquote></div></div></div></blockquote></div><span class=""><font color="#888888"><br><br>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</div></div>