function_ref<AAResults &(Function &)> &AARGetter, ImportedFunctionsInliningStatistics &ImportedFunctionsStats) { Function *Callee = CB.getCalledFunction(); Function *Caller = CB.getCaller(); AAResults &AAR = AAR
AnalysisManagerT&AM,ExtraArgTs...ExtraArgs)=0;virtualvoidprintPipeline(raw_ostream&OS,function_ref<StringRef(StringRef)>MapClassName2PassName)=0;virtual StringRefname()const=0;/// Polymorphic method to to let a pass optionally
voidsetFuncArgs(Function*Func,SmallVector<std::string>FuncArgs){unsignedIdx=0;Function::arg_iteratorbegin,end;for(begin=Func->arg_begin(),end=Func->arg_end();begin!=end;++begin,++Idx){begin->setName(FuncArgs[Idx]);}}intmain(){InitializeModule();my_Module->getOrInsertGlobal("num",my_...
getName(), StringRef(), Unit, LineNo, CreateFunctionType(TheFunction->arg_size(), Unit), false /* internal linkage */, true /* definition */, ScopeLine, DINode::FlagPrototyped, false); TheFunction->setSubprogram(SP); 现在我们有了一个DISubProgram,它包含对函数的所有元数据的引用。 源...
Function *llvmFun = module->getFunction(StringRef(function->functionName)); functionPassManager->run(*llvmFun); } Function *llvmMainFun = module->getFunction(StringRef("main")); functionPassManager->run(*llvmMainFun); 具体而言,看一下 Bolt 编译器之前和之后的 LLVM IR 输出。可以在 repo 中...
FunctionPass*createHelloPass() {returnnewHello(); } LLVM Pass的作用 显然它的一个用处就是插桩: 在Pass遍历LLVM IR的同时,自然就可以往里面插入新的代码。 机器无关的代码优化:IR在被翻译成机器码前会做一些机器无关的优化。 但是不同的优化方法之间需要解耦,所以自然要各自遍历一遍IR,实现成了一个个LLVM ...
FunctionType::get 的第一个参数是返回类型;第二个参数是一个 LLVM::ArrayRef 结构,并且最后的 false 指明了后面未跟可变数量的参数。ArrayRef 结构与矢量相似,只是它不包含任何基础数据,并且主要用于包装诸如阵列和矢量等数据块。由于这个改变,输出显示...
class FileManager : public llvm::RefCountedBase<FileManager> { FileSystemOptions FileSystemOpts; /// \brief The virtual directories that we have allocated. For each /// virtual file (e.g. foo/bar/baz.cpp), we add all of its parent /// directories (foo/ and foo/bar/) here. SmallVec...
(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-16.0.0/bin/clang+++0x620eeb5)#7 0x000055ed1a98a059 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, clang::QualType, clang::FunctionDecl*&, clang::sema::...
DeclRefExpr 引用类型声明 ReturnStmt 返回语句 使用clang的API可针对AST进行相应的分析及处理。 中间语言IR IR,即 Intermediate language ,有两种表示样式: 文本格式 便于阅读的文本格式,类似于汇编格式,后缀为.ll 也就是上面所说的clang test1.c -S -emit-llvm -o test ...