IR: Update clang for Metadata/Value split in r223802

Match LLVM API changes from r223802.

llvm-svn: 223803
This commit is contained in:
Duncan P. N. Exon Smith 2014-12-09 18:39:32 +00:00
parent 5bf8fef580
commit fb49491477
14 changed files with 266 additions and 274 deletions

View File

@ -5932,8 +5932,8 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
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],

View File

@ -126,13 +126,13 @@ void CGDebugInfo::setLocation(SourceLocation Loc) {
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::getContextDescriptor(const Decl *Context) {
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::getOrCreateFile(SourceLocation Loc) {
// 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(const RecordType *Ty,
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(const BlockPointerType *Ty,
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(const TypedefType *Ty, llvm::DIFile Unit) {
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::createFieldType(
}
/// 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::CreateRecordStaticField(const VarDecl *Var,
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::CollectRecordNormalField(
/// 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(const RecordDecl *record,
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::getOrCreateInstanceMethodType(
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::getOrCreateInstanceMethodType(
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::getOrCreateInstanceMethodType(
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(const CXXMethodDecl *Method,
/* 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(const CXXMethodDecl *Method,
/// 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::CollectCXXMemberFunctions(
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::CollectCXXMemberFunctions(
/// 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 TemplateParameterList *TPList,
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 TemplateParameterList *TPList,
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 TemplateParameterList *TPList,
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::getOrCreateVTablePtrType(llvm::DIFile Unit) {
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(const CXXRecordDecl *RD) {
/// 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 EnumDecl *ED) {
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(const RecordDecl *RD) {
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::CreateTypeDefinition(const RecordType *Ty) {
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::CreateTypeDefinition(const RecordType *Ty) {
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::CreateTypeDefinition(const ObjCInterfaceType *Ty,
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(const VectorType *Ty, llvm::DIFile Unit) {
// 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(const ArrayType *Ty, llvm::DIFile Unit) {
// 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(const EnumType *Ty) {
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::CreateTypeDefinition(const EnumType *Ty) {
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(QualType Ty) {
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::getOrCreateType(QualType Ty, llvm::DIFile Unit) {
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::getOrCreateLimitedType(const RecordType *Ty,
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::CreateLimitedType(const RecordType *Ty) {
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::getFunctionForwardDeclaration(const FunctionDecl *FD) {
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::getGlobalVariableForwardDeclaration(const VarDecl *VD) {
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::getDeclarationOrDefinition(const Decl *D) {
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::getFunctionDeclaration(const Decl *D) {
// 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::getFunctionDeclaration(const Decl *D) {
}
}
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::getOrCreateFunctionType(const Decl *D,
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::getOrCreateFunctionType(const Decl *D,
// 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(GlobalDecl GD, SourceLocation Loc,
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(GlobalDecl GD, SourceLocation Loc,
// 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(SourceLocation Loc) {
: 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(CGBuilderTy &Builder) {
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::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
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(llvm::GlobalVariable *Var,
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(const ValueDecl *VD,
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 NamespaceAliasDecl &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 NamespaceAliasDecl &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 NamespaceDecl *NSDecl) {
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

View File

@ -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.

View File

@ -1415,8 +1415,8 @@ llvm::Value *CodeGenFunction::EmitExtVectorElementLValue(LValue LV) {
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::EmitLoadOfGlobalRegLValue(LValue LV) {
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::EmitStoreThroughExtVectorComponentLValue(RValue Src,
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::EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst) {
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(const VarDecl *VD,
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) {

View File

@ -24,40 +24,39 @@ static MDNode *createMetadata(LLVMContext &Ctx, const LoopAttributes &Attrs) {
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;

View File

@ -1938,9 +1938,8 @@ llvm::Value *CodeGenFunction::EmitARCRetainBlock(llvm::Value *value,
= 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::EmitARCRetainAutoreleasedReturnValue(llvm::Value *value) {
"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(llvm::Value *value,
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));
}
}

View File

@ -1296,11 +1296,11 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF,
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(CodeGenFunction &CGF,
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;

View File

@ -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));
}

View File

@ -591,7 +591,9 @@ void CodeGenFunction::EmitCondBrHints(llvm::LLVMContext &Context,
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(llvm::LLVMContext &Context,
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(llvm::LLVMContext &Context,
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::EmitAsmInput(
/// 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(const StringLiteral *Str,
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 AsmStmt &S) {
} 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.

View File

@ -349,9 +349,9 @@ void CodeGenFunction::EmitMCountInstrumentation() {
// 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 FunctionDecl *FD, llvm::Function *Fn,
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 FunctionDecl *FD, llvm::Function *Fn,
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 FunctionDecl *FD, llvm::Function *Fn,
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::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
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::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
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));
}

View File

@ -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(CodeGenModule &CGM,
// 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(CodeGenModule &CGM,
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::EmitModuleLinkOptions() {
// 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(CodeGenModule &CGM,
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::EmitVersionIdentMetadata() {
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));
}
}
}

View File

@ -421,7 +421,7 @@ class CodeGenModule : public CodeGenTypeCache {
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;
}

View File

@ -30,8 +30,8 @@ void SanitizerMetadata::reportGlobalToASan(llvm::GlobalVariable *GV,
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::reportGlobalToASan(llvm::GlobalVariable *GV,
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::disableSanitizerForGlobal(llvm::GlobalVariable *GV) {
}
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::getLocationMetadata(SourceLocation Loc) {
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);
}

View File

@ -5214,9 +5214,10 @@ void NVPTXTargetCodeGenInfo::addNVVMMetadata(llvm::Function *F, StringRef Name,
// 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::SetTargetAttributes(const Decl *D,
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::emitTargetMD(const Decl *D, llvm::GlobalValue *GV,
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");