Index: llvm/include/llvm-c/Core.h =================================================================== --- llvm/include/llvm-c/Core.h +++ llvm/include/llvm-c/Core.h @@ -567,8 +567,8 @@ LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI); unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, - unsigned SLen); -unsigned LLVMGetMDKindID(const char *Name, unsigned SLen); + size_t SLen); +unsigned LLVMGetMDKindID(const char *Name, size_t SLen); /** * Return an unique id given the name of a enum attribute, @@ -605,8 +605,8 @@ * Create a string attribute. */ LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, - const char *K, unsigned KLength, - const char *V, unsigned VLength); + const char *K, size_t KLength, + const char *V, size_t VLength); /** * Get the string attribute's kind. @@ -765,7 +765,7 @@ */ LLVMModuleFlagBehavior LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries, - unsigned Index); + size_t Index); /** * Returns the key for a module flag entry at a specific index. @@ -773,7 +773,7 @@ * @see Module::ModuleFlagEntry::Key */ const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries, - unsigned Index, size_t *Len); + size_t Index, size_t *Len); /** * Returns the metadata for a module flag entry at a specific index. @@ -781,7 +781,7 @@ * @see Module::ModuleFlagEntry::Val */ LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries, - unsigned Index); + size_t Index); /** * Add a module-level flag to the module-level flags metadata if it doesn't @@ -1218,7 +1218,7 @@ * parameter types, and whether the function is variadic. */ LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, - LLVMTypeRef *ParamTypes, unsigned ParamCount, + LLVMTypeRef *ParamTypes, size_t ParamCount, LLVMBool IsVarArg); /** @@ -1272,14 +1272,14 @@ * @see llvm::StructType::create() */ LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, - unsigned ElementCount, LLVMBool Packed); + size_t ElementCount, LLVMBool Packed); /** * Create a new structure type in the global context. * * @see llvm::StructType::create() */ -LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, +LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, size_t ElementCount, LLVMBool Packed); /** @@ -1302,7 +1302,7 @@ * @see llvm::StructType::setBody() */ void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, - unsigned ElementCount, LLVMBool Packed); + size_t ElementCount, LLVMBool Packed); /** * Get the number of elements defined inside the structure. @@ -1395,7 +1395,7 @@ * * @see llvm::ArrayType::get() */ -LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount); +LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, uint64_t ElementCount); /** * Obtain the length of an array type. @@ -1874,8 +1874,7 @@ * @param N The value the returned instance should refer to. * @param SignExtend Whether to sign extend the produced value. */ -LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, - LLVMBool SignExtend); +LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, uint64_t N, LLVMBool SignExtend); /** * Obtain a constant value for an integer of arbitrary precision. @@ -1905,7 +1904,7 @@ * @see llvm::ConstantInt::get() */ LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text, - unsigned SLen, uint8_t Radix); + size_t SLen, uint8_t Radix); /** * Obtain a constant value referring to a double floating point value. @@ -1924,21 +1923,21 @@ * Obtain a constant for a floating point value parsed from a string. */ LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text, - unsigned SLen); + size_t SLen); /** * Obtain the zero extended value for an integer constant value. * * @see llvm::ConstantInt::getZExtValue() */ -unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal); +uint64_t LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal); /** * Obtain the sign extended value for an integer constant value. * * @see llvm::ConstantInt::getSExtValue() */ -long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal); +int64_t LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal); /** * Obtain the double value for an floating point constant value. @@ -1966,7 +1965,8 @@ * @see llvm::ConstantDataArray::getString() */ LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, - unsigned Length, LLVMBool DontNullTerminate); + size_t Length, + LLVMBool DontNullTerminate); /** * Create a ConstantDataSequential with string content in the global context. @@ -1977,7 +1977,7 @@ * @see LLVMConstStringInContext() * @see llvm::ConstantDataArray::getString() */ -LLVMValueRef LLVMConstString(const char *Str, unsigned Length, +LLVMValueRef LLVMConstString(const char *Str, size_t Length, LLVMBool DontNullTerminate); /** @@ -2000,8 +2000,8 @@ * @see llvm::ConstantStruct::getAnon() */ LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, - LLVMValueRef *ConstantVals, - unsigned Count, LLVMBool Packed); + LLVMValueRef *ConstantVals, size_t Count, + LLVMBool Packed); /** * Create a ConstantStruct in the global Context. @@ -2011,7 +2011,7 @@ * * @see LLVMConstStructInContext() */ -LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, +LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, size_t Count, LLVMBool Packed); /** @@ -2019,8 +2019,8 @@ * * @see llvm::ConstantArray::get() */ -LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, - LLVMValueRef *ConstantVals, unsigned Length); +LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, + size_t Length); /** * Create a non-anonymous ConstantStruct from values. @@ -2028,8 +2028,7 @@ * @see llvm::ConstantStruct::get() */ LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, - LLVMValueRef *ConstantVals, - unsigned Count); + LLVMValueRef *ConstantVals, size_t Count); /** * Get an element at specified index as a constant. @@ -2043,7 +2042,7 @@ * * @see llvm::ConstantVector::get() */ -LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); +LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, size_t Size); /** * @} @@ -2097,15 +2096,15 @@ LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, - LLVMValueRef *ConstantIndices, unsigned NumIndices); + LLVMValueRef *ConstantIndices, size_t NumIndices); LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, - LLVMValueRef *ConstantIndices, unsigned NumIndices); + LLVMValueRef *ConstantIndices, size_t NumIndices); LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, - unsigned NumIndices); + size_t NumIndices); LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, - unsigned NumIndices); + size_t NumIndices); LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); @@ -2142,10 +2141,10 @@ LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant); LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, - unsigned NumIdx); + size_t NumIdx); LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, LLVMValueRef ElementValueConstant, - unsigned *IdxList, unsigned NumIdx); + unsigned *IdxList, size_t NumIdx); LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB); /** Deprecated: Use LLVMGetInlineAsm instead. */ @@ -2217,7 +2216,7 @@ * @see llvm::StoreInst::setAlignment() * @see llvm::GlobalValue::setAlignment() */ -void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes); +void LLVMSetAlignment(LLVMValueRef V, uint64_t Bytes); /** * Sets a metadata attachment, erasing the existing metadata attachment if @@ -2261,7 +2260,7 @@ * Returns the kind of a value metadata entry at a specific index. */ unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries, - unsigned Index); + size_t Index); /** * Returns the underlying metadata node of a value metadata entry at a @@ -2269,7 +2268,7 @@ */ LLVMMetadataRef LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries, - unsigned Index); + size_t Index); /** * @} @@ -2525,11 +2524,11 @@ unsigned KindID); LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, - const char *K, unsigned KLen); + const char *K, size_t KLen); void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID); void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, - const char *K, unsigned KLen); + const char *K, size_t KLen); /** * Add a target-dependent attribute to a function @@ -2576,7 +2575,7 @@ * * @see llvm::Function::arg_begin() */ -LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); +LLVMValueRef LLVMGetParam(LLVMValueRef Fn, size_t Index); /** * Obtain the function to which this argument belongs. @@ -2625,7 +2624,7 @@ * @see llvm::Argument::addAttr() * @see llvm::AttrBuilder::addAlignmentAttr() */ -void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align); +void LLVMSetParamAlignment(LLVMValueRef Arg, uint64_t Align); /** * @} @@ -2807,14 +2806,14 @@ /** Deprecated: Use LLVMMDStringInContext2 instead. */ LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, - unsigned SLen); + size_t SLen); /** Deprecated: Use LLVMMDStringInContext2 instead. */ -LLVMValueRef LLVMMDString(const char *Str, unsigned SLen); +LLVMValueRef LLVMMDString(const char *Str, size_t SLen); /** Deprecated: Use LLVMMDNodeInContext2 instead. */ LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, - unsigned Count); + size_t Count); /** Deprecated: Use LLVMMDNodeInContext2 instead. */ -LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count); +LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, size_t Count); /** * @} @@ -3221,7 +3220,7 @@ unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, - unsigned Align); + size_t Align); void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef A); @@ -3233,11 +3232,11 @@ unsigned KindID); LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, - const char *K, unsigned KLen); + const char *K, size_t KLen); void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID); void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, - const char *K, unsigned KLen); + const char *K, size_t KLen); /** * Obtain the function type called by this instruction. @@ -3591,11 +3590,11 @@ // LLVMBuildInvoke is deprecated in favor of LLVMBuildInvoke2, in preparation // for opaque pointer types. LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name); LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name); LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); @@ -3610,10 +3609,10 @@ LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB); LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, const char *Name); LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, const char *Name); LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMBasicBlockRef UnwindBB, @@ -3763,15 +3762,15 @@ */ LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Val, LLVMValueRef Len, - unsigned Align); + uint64_t Align); /** * Creates and inserts a memcpy between the specified pointers. * * @see llvm::IRRBuilder::CreateMemCpy() */ LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, - LLVMValueRef Dst, unsigned DstAlign, - LLVMValueRef Src, unsigned SrcAlign, + LLVMValueRef Dst, uint64_t DstAlign, + LLVMValueRef Src, uint64_t SrcAlign, LLVMValueRef Size); /** * Creates and inserts a memmove between the specified pointers. @@ -3779,8 +3778,8 @@ * @see llvm::IRRBuilder::CreateMemMove() */ LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B, - LLVMValueRef Dst, unsigned DstAlign, - LLVMValueRef Src, unsigned SrcAlign, + LLVMValueRef Dst, uint64_t DstAlign, + LLVMValueRef Src, uint64_t SrcAlign, LLVMValueRef Size); LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); @@ -3797,19 +3796,19 @@ // LLVMBuildGEP, LLVMBuildInBoundsGEP, and LLVMBuildStructGEP are deprecated in // favor of LLVMBuild*GEP2, in preparation for opaque pointer types. LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, - LLVMValueRef *Indices, unsigned NumIndices, + LLVMValueRef *Indices, size_t NumIndices, const char *Name); LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, - LLVMValueRef *Indices, unsigned NumIndices, + LLVMValueRef *Indices, size_t NumIndices, const char *Name); LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer, unsigned Idx, const char *Name); LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, - unsigned NumIndices, const char *Name); + size_t NumIndices, const char *Name); LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, - unsigned NumIndices, const char *Name); + size_t NumIndices, const char *Name); LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, unsigned Idx, const char *Name); @@ -3886,10 +3885,10 @@ // LLVMBuildCall is deprecated in favor of LLVMBuildCall2, in preparation for // opaque pointer types. LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, const char *Name); LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, const char *Name); LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, Index: llvm/include/llvm/IR/Value.h =================================================================== --- llvm/include/llvm/IR/Value.h +++ llvm/include/llvm/IR/Value.h @@ -935,7 +935,7 @@ } template -inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { +inline T **unwrap(LLVMValueRef *Vals, size_t Length) { #ifndef NDEBUG for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I) unwrap(*I); // For side effect of calling assert on invalid usage. Index: llvm/lib/IR/Core.cpp =================================================================== --- llvm/lib/IR/Core.cpp +++ llvm/lib/IR/Core.cpp @@ -119,11 +119,11 @@ } unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, - unsigned SLen) { + size_t SLen) { return unwrap(C)->getMDKindID(StringRef(Name, SLen)); } -unsigned LLVMGetMDKindID(const char *Name, unsigned SLen) { +unsigned LLVMGetMDKindID(const char *Name, size_t SLen) { return LLVMGetMDKindIDInContext(LLVMGetGlobalContext(), Name, SLen); } @@ -161,8 +161,8 @@ } LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, - const char *K, unsigned KLength, - const char *V, unsigned VLength) { + const char *K, size_t KLength, + const char *V, size_t VLength) { return wrap(Attribute::get(*unwrap(C), StringRef(K, KLength), StringRef(V, VLength))); } @@ -332,7 +332,7 @@ LLVMOpaqueModuleFlagEntry *Result = static_cast( safe_malloc(MFEs.size() * sizeof(LLVMOpaqueModuleFlagEntry))); - for (unsigned i = 0; i < MFEs.size(); ++i) { + for (size_t i = 0; i < MFEs.size(); ++i) { const auto &ModuleFlag = MFEs[i]; Result[i].Behavior = map_from_llvmModFlagBehavior(ModuleFlag.Behavior); Result[i].Key = ModuleFlag.Key->getString().data(); @@ -349,14 +349,14 @@ LLVMModuleFlagBehavior LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries, - unsigned Index) { + size_t Index) { LLVMOpaqueModuleFlagEntry MFE = static_cast(Entries[Index]); return MFE.Behavior; } const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries, - unsigned Index, size_t *Len) { + size_t Index, size_t *Len) { LLVMOpaqueModuleFlagEntry MFE = static_cast(Entries[Index]); *Len = MFE.KeyLen; @@ -364,7 +364,7 @@ } LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries, - unsigned Index) { + size_t Index) { LLVMOpaqueModuleFlagEntry MFE = static_cast(Entries[Index]); return MFE.Metadata; @@ -639,7 +639,7 @@ /*--.. Operations on function types ........................................--*/ LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, - LLVMTypeRef *ParamTypes, unsigned ParamCount, + LLVMTypeRef *ParamTypes, size_t ParamCount, LLVMBool IsVarArg) { ArrayRef Tys(unwrap(ParamTypes), ParamCount); return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0)); @@ -667,13 +667,13 @@ /*--.. Operations on struct types ..........................................--*/ LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, - unsigned ElementCount, LLVMBool Packed) { + size_t ElementCount, LLVMBool Packed) { ArrayRef Tys(unwrap(ElementTypes), ElementCount); return wrap(StructType::get(*unwrap(C), Tys, Packed != 0)); } -LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, - unsigned ElementCount, LLVMBool Packed) { +LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, size_t ElementCount, + LLVMBool Packed) { return LLVMStructTypeInContext(LLVMGetGlobalContext(), ElementTypes, ElementCount, Packed); } @@ -692,7 +692,7 @@ } void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, - unsigned ElementCount, LLVMBool Packed) { + size_t ElementCount, LLVMBool Packed) { ArrayRef Tys(unwrap(ElementTypes), ElementCount); unwrap(StructTy)->setBody(Tys, Packed != 0); } @@ -739,7 +739,7 @@ } } -LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) { +LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, uint64_t ElementCount) { return wrap(ArrayType::get(unwrap(ElementType), ElementCount)); } @@ -904,7 +904,7 @@ LLVMOpaqueValueMetadataEntry *Result = static_cast( safe_malloc(MVEs.size() * sizeof(LLVMOpaqueValueMetadataEntry))); - for (unsigned i = 0; i < MVEs.size(); ++i) { + for (size_t i = 0; i < MVEs.size(); ++i) { const auto &ModuleFlag = MVEs[i]; Result[i].Kind = ModuleFlag.first; Result[i].Metadata = wrap(ModuleFlag.second); @@ -1057,18 +1057,18 @@ } LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, - unsigned SLen) { + size_t SLen) { LLVMContext &Context = *unwrap(C); return wrap(MetadataAsValue::get( Context, MDString::get(Context, StringRef(Str, SLen)))); } -LLVMValueRef LLVMMDString(const char *Str, unsigned SLen) { +LLVMValueRef LLVMMDString(const char *Str, size_t SLen) { return LLVMMDStringInContext(LLVMGetGlobalContext(), Str, SLen); } LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, - unsigned Count) { + size_t Count) { LLVMContext &Context = *unwrap(C); SmallVector MDs; for (auto *OV : makeArrayRef(Vals, Count)) { @@ -1094,7 +1094,7 @@ return wrap(MetadataAsValue::get(Context, MDNode::get(Context, MDs))); } -LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) { +LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, size_t Count) { return LLVMMDNodeInContext(LLVMGetGlobalContext(), Vals, Count); } @@ -1296,8 +1296,7 @@ /*--.. Operations on scalar constants ......................................--*/ -LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, - LLVMBool SignExtend) { +LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, uint64_t N, LLVMBool SignExtend) { return wrap(ConstantInt::get(unwrap(IntTy), N, SignExtend != 0)); } @@ -1317,7 +1316,7 @@ } LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char Str[], - unsigned SLen, uint8_t Radix) { + size_t SLen, uint8_t Radix) { return wrap(ConstantInt::get(unwrap(IntTy), StringRef(Str, SLen), Radix)); } @@ -1331,15 +1330,15 @@ } LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[], - unsigned SLen) { + size_t SLen) { return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen))); } -unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) { +uint64_t LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) { return unwrap(ConstantVal)->getZExtValue(); } -long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal) { +int64_t LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal) { return unwrap(ConstantVal)->getSExtValue(); } @@ -1367,7 +1366,7 @@ /*--.. Operations on composite constants ...................................--*/ LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, - unsigned Length, + size_t Length, LLVMBool DontNullTerminate) { /* Inverted the sense of AddNull because ', 0)' is a better mnemonic for null termination than ', 1)'. */ @@ -1375,7 +1374,7 @@ DontNullTerminate == 0)); } -LLVMValueRef LLVMConstString(const char *Str, unsigned Length, +LLVMValueRef LLVMConstString(const char *Str, size_t Length, LLVMBool DontNullTerminate) { return LLVMConstStringInContext(LLVMGetGlobalContext(), Str, Length, DontNullTerminate); @@ -1395,36 +1394,35 @@ return Str.data(); } -LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, - LLVMValueRef *ConstantVals, unsigned Length) { - ArrayRef V(unwrap(ConstantVals, Length), Length); +LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, + size_t Length) { + ArrayRef V(unwrap(ConstantVals, Length), Length); return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V)); } LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, - LLVMValueRef *ConstantVals, - unsigned Count, LLVMBool Packed) { + LLVMValueRef *ConstantVals, size_t Count, + LLVMBool Packed) { Constant **Elements = unwrap(ConstantVals, Count); return wrap(ConstantStruct::getAnon(*unwrap(C), makeArrayRef(Elements, Count), Packed != 0)); } -LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, +LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, size_t Count, LLVMBool Packed) { return LLVMConstStructInContext(LLVMGetGlobalContext(), ConstantVals, Count, Packed); } LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, - LLVMValueRef *ConstantVals, - unsigned Count) { + LLVMValueRef *ConstantVals, size_t Count) { Constant **Elements = unwrap(ConstantVals, Count); StructType *Ty = cast(unwrap(StructTy)); return wrap(ConstantStruct::get(Ty, makeArrayRef(Elements, Count))); } -LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) { +LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, size_t Size) { return wrap(ConstantVector::get(makeArrayRef( unwrap(ScalarConstantVals, Size), Size))); } @@ -1639,7 +1637,7 @@ } LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, - LLVMValueRef *ConstantIndices, unsigned NumIndices) { + LLVMValueRef *ConstantIndices, size_t NumIndices) { ArrayRef IdxList(unwrap(ConstantIndices, NumIndices), NumIndices); Constant *Val = unwrap(ConstantVal); @@ -1650,7 +1648,7 @@ LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, - unsigned NumIndices) { + size_t NumIndices) { ArrayRef IdxList(unwrap(ConstantIndices, NumIndices), NumIndices); Constant *Val = unwrap(ConstantVal); @@ -1793,17 +1791,17 @@ } LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, - unsigned NumIdx) { + size_t NumIdx) { return wrap(ConstantExpr::getExtractValue(unwrap(AggConstant), makeArrayRef(IdxList, NumIdx))); } LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, LLVMValueRef ElementValueConstant, - unsigned *IdxList, unsigned NumIdx) { - return wrap(ConstantExpr::getInsertValue(unwrap(AggConstant), - unwrap(ElementValueConstant), - makeArrayRef(IdxList, NumIdx))); + unsigned *IdxList, size_t NumIdx) { + return wrap(ConstantExpr::getInsertValue( + unwrap(AggConstant), unwrap(ElementValueConstant), + makeArrayRef(IdxList, NumIdx))); } LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, @@ -2008,7 +2006,7 @@ "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment"); } -void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) { +void LLVMSetAlignment(LLVMValueRef V, uint64_t Bytes) { Value *P = unwrap(V); if (GlobalObject *GV = dyn_cast(P)) GV->setAlignment(MaybeAlign(Bytes)); @@ -2035,7 +2033,7 @@ } unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries, - unsigned Index) { + size_t Index) { LLVMOpaqueValueMetadataEntry MVE = static_cast(Entries[Index]); return MVE.Kind; @@ -2043,7 +2041,7 @@ LLVMMetadataRef LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries, - unsigned Index) { + size_t Index) { LLVMOpaqueValueMetadataEntry MVE = static_cast(Entries[Index]); return MVE.Metadata; @@ -2414,7 +2412,7 @@ LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, - const char *K, unsigned KLen) { + const char *K, size_t KLen) { return wrap(unwrap(F)->getAttribute(Idx, StringRef(K, KLen))); } @@ -2424,7 +2422,7 @@ } void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, - const char *K, unsigned KLen) { + const char *K, size_t KLen) { unwrap(F)->removeAttribute(Idx, StringRef(K, KLen)); } @@ -2450,7 +2448,7 @@ *ParamRefs++ = wrap(&*I); } -LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index) { +LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, size_t index) { Function *Fn = unwrap(FnRef); return wrap(&Fn->arg_begin()[index]); } @@ -2490,7 +2488,7 @@ return wrap(&A->getParent()->arg_begin()[A->getArgNo() - 1]); } -void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) { +void LLVMSetParamAlignment(LLVMValueRef Arg, uint64_t align) { Argument *A = unwrap(Arg); A->addAttr(Attribute::getWithAlignment(A->getContext(), Align(align))); } @@ -2789,7 +2787,7 @@ } void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, - unsigned align) { + uint64_t align) { auto *Call = unwrap(Instr); Attribute AlignAttr = Attribute::getWithAlignment(Call->getContext(), Align(align)); @@ -2825,7 +2823,7 @@ LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, - const char *K, unsigned KLen) { + const char *K, size_t KLen) { return wrap(unwrap(C)->getAttribute(Idx, StringRef(K, KLen))); } @@ -2835,7 +2833,7 @@ } void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, - const char *K, unsigned KLen) { + const char *K, size_t KLen) { unwrap(C)->removeAttribute(Idx, StringRef(K, KLen)); } @@ -3109,7 +3107,7 @@ } LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef B, LLVMValueRef Fn, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name) { Value *V = unwrap(Fn); @@ -3122,7 +3120,7 @@ } LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name) { return wrap(unwrap(B)->CreateInvoke( @@ -3143,7 +3141,7 @@ } LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, const char *Name) { return wrap(unwrap(B)->CreateCatchPad(unwrap(ParentPad), makeArrayRef(unwrap(Args), NumArgs), @@ -3151,7 +3149,7 @@ } LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, const char *Name) { if (ParentPad == nullptr) { Type *Ty = Type::getTokenTy(unwrap(B)->getContext()); @@ -3444,14 +3442,14 @@ LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Val, LLVMValueRef Len, - unsigned Align) { + uint64_t Align) { return wrap(unwrap(B)->CreateMemSet(unwrap(Ptr), unwrap(Val), unwrap(Len), MaybeAlign(Align))); } LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, - LLVMValueRef Dst, unsigned DstAlign, - LLVMValueRef Src, unsigned SrcAlign, + LLVMValueRef Dst, uint64_t DstAlign, + LLVMValueRef Src, uint64_t SrcAlign, LLVMValueRef Size) { return wrap(unwrap(B)->CreateMemCpy(unwrap(Dst), MaybeAlign(DstAlign), unwrap(Src), MaybeAlign(SrcAlign), @@ -3459,8 +3457,8 @@ } LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B, - LLVMValueRef Dst, unsigned DstAlign, - LLVMValueRef Src, unsigned SrcAlign, + LLVMValueRef Dst, uint64_t DstAlign, + LLVMValueRef Src, uint64_t SrcAlign, LLVMValueRef Size) { return wrap(unwrap(B)->CreateMemMove(unwrap(Dst), MaybeAlign(DstAlign), unwrap(Src), MaybeAlign(SrcAlign), @@ -3585,7 +3583,7 @@ } LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, - LLVMValueRef *Indices, unsigned NumIndices, + LLVMValueRef *Indices, size_t NumIndices, const char *Name) { ArrayRef IdxList(unwrap(Indices), NumIndices); Value *Val = unwrap(Pointer); @@ -3596,13 +3594,13 @@ LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, - unsigned NumIndices, const char *Name) { + size_t NumIndices, const char *Name) { ArrayRef IdxList(unwrap(Indices), NumIndices); return wrap(unwrap(B)->CreateGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name)); } LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, - LLVMValueRef *Indices, unsigned NumIndices, + LLVMValueRef *Indices, size_t NumIndices, const char *Name) { ArrayRef IdxList(unwrap(Indices), NumIndices); Value *Val = unwrap(Pointer); @@ -3613,7 +3611,7 @@ LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, - unsigned NumIndices, const char *Name) { + size_t NumIndices, const char *Name) { ArrayRef IdxList(unwrap(Indices), NumIndices); return wrap( unwrap(B)->CreateInBoundsGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name)); @@ -3840,7 +3838,7 @@ } LLVMValueRef LLVMBuildCall(LLVMBuilderRef B, LLVMValueRef Fn, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, const char *Name) { Value *V = unwrap(Fn); FunctionType *FnT = @@ -3851,7 +3849,7 @@ } LLVMValueRef LLVMBuildCall2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, - LLVMValueRef *Args, unsigned NumArgs, + LLVMValueRef *Args, size_t NumArgs, const char *Name) { FunctionType *FTy = unwrap(Ty); return wrap(unwrap(B)->CreateCall(FTy, unwrap(Fn),