Ejemplo n.º 1
0
LLVMValueRef LLVMDIBuilderCreateFunction(
  LLVMDIBuilderRef D,
  LLVMValueRef Scope,
  const char *Name,
  const char *LinkageName,
  LLVMValueRef File,
  unsigned Line,
  LLVMValueRef CompositeType,
  bool IsLocalToUnit,
  bool IsDefinition,
  unsigned ScopeLine,
  unsigned Flags,
  bool IsOptimized,
  LLVMValueRef Func)
{
  DIBuilder *db = unwrap(D);
  DISubprogram SP = db->createFunction(
    unwrapDI<DIDescriptor>(Scope),
    Name,
    LinkageName,
    unwrapDI<DIFile>(File),
    Line,
    unwrapDI<DICompositeType>(CompositeType),
    IsLocalToUnit,
    IsDefinition,
    ScopeLine,
    Flags,
    IsOptimized,
    unwrap<Function>(Func));
  return wrap(SP);
}
Ejemplo n.º 2
0
LLVMMetadataRef LLVMDIBuilderCreateFunction(
    LLVMDIBuilderRef Dref, LLVMMetadataRef Scope, const char *Name,
    const char *LinkageName, LLVMMetadataRef File, unsigned Line,
    LLVMMetadataRef CompositeType, int IsLocalToUnit, int IsDefinition,
    unsigned ScopeLine, unsigned Flags, int IsOptimized) {
  DIBuilder *D = unwrap(Dref);
  return wrap(D->createFunction(
      unwrap<DIScope>(Scope), Name, LinkageName,
      File ? unwrap<DIFile>(File) : nullptr, Line,
      unwrap<DISubroutineType>(CompositeType), IsLocalToUnit, IsDefinition,
      ScopeLine, static_cast<DINode::DIFlags>(Flags), IsOptimized));
}
Ejemplo n.º 3
0
void*
mono_llvm_di_create_function (void *di_builder, void *cu, const char *name, const char *mangled_name, const char *dir, const char *file, int line)
{
	DIBuilder *builder = (DIBuilder*)di_builder;
	DIFile *di_file;
	DISubroutineType *type;

	// FIXME: Share DIFile
	di_file = builder->createFile (file, dir);
	type = builder->createSubroutineType (builder->getOrCreateTypeArray (ArrayRef<Metadata*> ()));
	return builder->createFunction (di_file, name, mangled_name, di_file, line, type, true, true, 0);
}
Ejemplo n.º 4
0
 virtual Value * materializeValueFor(Value * V) {
     if(Function * fn = dyn_cast<Function>(V)) {
         assert(fn->getParent() == src);
         Function * newfn = dest->getFunction(fn->getName());
         if(!newfn) {
             newfn = Function::Create(fn->getFunctionType(),fn->getLinkage(), fn->getName(),dest);
             newfn->copyAttributesFrom(fn);
         }
         if(!fn->isDeclaration() && newfn->isDeclaration() && copyGlobal(fn,data)) {
             for(Function::arg_iterator II = newfn->arg_begin(), I = fn->arg_begin(), E = fn->arg_end(); I != E; ++I, ++II) {
                 II->setName(I->getName());
                 VMap[I] = II;
             }
             VMap[fn] = newfn;
             SmallVector<ReturnInst*,8> Returns;
             CloneFunctionInto(newfn, fn, VMap, true, Returns, "", NULL, NULL, this);
         }
         return newfn;
     } else if(GlobalVariable * GV = dyn_cast<GlobalVariable>(V)) {
         GlobalVariable * newGV = dest->getGlobalVariable(GV->getName(),true);
         if(!newGV) {
             newGV = new GlobalVariable(*dest,GV->getType()->getElementType(),GV->isConstant(),GV->getLinkage(),NULL,GV->getName(),NULL,GlobalVariable::NotThreadLocal,GV->getType()->getAddressSpace());
             newGV->copyAttributesFrom(GV);
             if(!GV->isDeclaration()) {
                 if(!copyGlobal(GV,data)) {
                     newGV->setExternallyInitialized(true);
                 } else if(GV->hasInitializer()) {
                     Value * C = MapValue(GV->getInitializer(),VMap,RF_None,NULL,this);
                     newGV->setInitializer(cast<Constant>(C));
                 }
             }
         }
         return newGV;
     } else if(MDNode * MD = dyn_cast<MDNode>(V)) {
         DISubprogram SP(MD);
         if(DI != NULL && SP.isSubprogram()) {
             
             if(Function * OF = SP.getFunction()) {
                 Function * F = cast<Function>(MapValue(OF,VMap,RF_None,NULL,this));
                 DISubprogram NSP = DI->createFunction(SP.getContext(), SP.getName(), SP.getLinkageName(),
                                                   DI->createFile(SP.getFilename(),SP.getDirectory()),
                                                   SP.getLineNumber(), SP.getType(),
                                                   SP.isLocalToUnit(), SP.isDefinition(),
                                                   SP.getScopeLineNumber(),SP.getFlags(),SP.isOptimized(),
                                                   F);
                 return NSP;
             }
             /* fallthrough */
         }
         /* fallthrough */
     }
     return NULL;
 }
Ejemplo n.º 5
0
LLVMMetadataRef LLVMDIBuilderCreateFunction(
    LLVMDIBuilderRef Dref, LLVMMetadataRef Scope, const char *Name,
    const char *LinkageName, LLVMMetadataRef File, unsigned Line,
    LLVMMetadataRef CompositeType, int IsLocalToUnit, int IsDefinition,
    unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Func) {
  DIBuilder *D = unwrap(Dref);
  DISubprogram SP = D->createFunction(
      unwrap<MDScope>(Scope), Name, LinkageName,
      File ? unwrap<MDFile>(File) : nullptr, Line,
      unwrap<MDSubroutineType>(CompositeType), IsLocalToUnit, IsDefinition,
      ScopeLine, Flags, IsOptimized, unwrap<Function>(Func));
  return wrap(SP);
}
Ejemplo n.º 6
0
LLVMValueRef DIBuilderCreateFunction(LLVMDIBuilderRef dref,
                                     LLVMValueRef diScope, const char *name,
                                     const char *linkageName,
                                     LLVMValueRef diFile, unsigned line,
                                     LLVMValueRef diCompositeType,
                                     int isLocalToUnit, int isDefinition,
                                     unsigned scopeLine, unsigned flags,
                                     int isOptimized, LLVMValueRef function) {
  DIBuilder *d = unwrap(dref);
  DISubprogram sp = d->createFunction(
      unwrapDI<DIDescriptor>(diScope), StringRef(name), StringRef(linkageName),
      unwrapDI<DIFile>(diFile), line,
      unwrapDI<DICompositeType>(diCompositeType), isLocalToUnit, isDefinition,
      scopeLine, flags, isOptimized, unwrap<Function>(function));
  return wrap(sp);
}
Ejemplo n.º 7
0
void*
mono_llvm_di_create_function (void *di_builder, void *cu, LLVMValueRef func, const char *name, const char *mangled_name, const char *dir, const char *file, int line)
{
    DIBuilder *builder = (DIBuilder*)di_builder;
    DIFile *di_file;
    DISubroutineType *type;
    DISubprogram *di_func;

    // FIXME: Share DIFile
    di_file = builder->createFile (file, dir);
    type = builder->createSubroutineType (builder->getOrCreateTypeArray (ArrayRef<Metadata*> ()));
    di_func = builder->createFunction (di_file, name, mangled_name, di_file, line, type, true, true, 0);

    unwrap<Function>(func)->setMetadata ("dbg", di_func);

    return di_func;
}
Ejemplo n.º 8
0
int
DefineFunction(
    ClientData clientData,
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[])
{
    if (objc != 8) {
	Tcl_WrongNumArgs(interp, 1, objv,
		"DIBuilder scope name linkName file line subroutineType");
	return TCL_ERROR;
    }

    DIBuilder *builder;
    if (GetDIBuilderFromObj(interp, objv[1], builder) != TCL_OK)
	return TCL_ERROR;
    DIScope *scope;
    if (GetMetadataFromObj(interp, objv[2], "scope", scope) != TCL_OK)
	return TCL_ERROR;
    std::string name = Tcl_GetString(objv[3]);
    std::string linkName = Tcl_GetString(objv[4]);
    DIFile *file;
    if (GetMetadataFromObj(interp, objv[5], "file", file) != TCL_OK)
	return TCL_ERROR;
    int line;
    if (Tcl_GetIntFromObj(interp, objv[6], &line) != TCL_OK)
	return TCL_ERROR;
    DISubroutineType *type;
    if (GetMetadataFromObj(interp, objv[7], "subroutine type", type) != TCL_OK)
	return TCL_ERROR;
    unsigned flags = 0;
    bool isOpt = true, isLocal = true, isDef = true;

    auto val = builder->createFunction(scope, name, linkName, file, line,
	    type, isLocal, isDef, line, flags, isOpt);

    Tcl_SetObjResult(interp, NewMetadataObj(val, "Function"));
    return TCL_OK;
}