private static Function DeclareDoCopyFunc(NativeModule module, DIFile diFile, IDebugType <ITypeRef, DIType> voidType) { var doCopySig = module.Context.CreateFunctionType(module.DIBuilder, voidType); var doCopyFunc = module.CreateFunction(scope: diFile , name: "DoCopy" , linkageName: null , file: diFile , line: 23 , signature: doCopySig , isLocalToUnit: false , isDefinition: true , scopeLine: 24 , debugFlags: DebugInfoFlags.None , isOptimized: false ).AddAttributes(FunctionAttributeIndex.Function, AttributeKind.NoInline, AttributeKind.NoUnwind) .AddAttributes(FunctionAttributeIndex.Function, TargetDependentAttributes); return(doCopyFunc); }
private static Function DeclareCopyFunc(NativeModule module , DIFile diFile , IDebugType <ITypeRef, DIType> voidType , DIDerivedType constFoo , DebugPointerType fooPtr ) { // Since the first parameter is passed by value // using the pointer + alloca + memcopy pattern, the actual // source, and therefore debug, signature is NOT a pointer. // However, that usage would create a signature with two // pointers as the arguments, which doesn't match the source // To get the correct debug info signature this inserts an // explicit DebugType<> that overrides the default behavior // to pair the LLVM pointer type with the original source type. var copySig = module.Context.CreateFunctionType(module.DIBuilder , voidType , DebugType.Create(fooPtr, constFoo) , fooPtr ); var copyFunc = module.CreateFunction(scope: diFile , name: "copy" , linkageName: null , file: diFile , line: 11 , signature: copySig , isLocalToUnit: true , isDefinition: true , scopeLine: 14 , debugFlags: DebugInfoFlags.Prototyped , isOptimized: false ).Linkage(Linkage.Internal) // static function .AddAttributes(FunctionAttributeIndex.Function, AttributeKind.NoUnwind, AttributeKind.NoInline) .AddAttributes(FunctionAttributeIndex.Function, TargetDependentAttributes); TargetDetails.AddABIAttributesForByValueStructure(copyFunc, 0); return(copyFunc); }