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