search for: getfunctionlist

Displaying 20 results from an estimated 34 matches for "getfunctionlist".

2018 Dec 09
2
Parse LLVM IR
...t/raw_ostream.h> using namespace llvm; int main() { LLVMContext context; SMDiagnostic error; Module *m = parseIRFile("t.ll", error, context).get(); if(!m) { return 0; } std::cout << error.getMessage().str() << std::endl; std::cout << sizeof(m->getFunctionList()) << std::endl; auto iter1 = m->getFunctionList().begin(); std::cout << " Function: " << (*iter1).getName().str() << std::endl; for (auto iter1 = m->getFunctionList().begin(); iter1 != m->getFunctionList().end(); iter1++) { Function...
2018 Feb 02
2
Debug info error on bitcode inline modification
...tcode/ReaderWriter.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; int main(int argc, char *argv[]) { SMDiagnostic error; LLVMContext context; Module *M = parseIRFile(argv[1], error, context).release(); for (Module::iterator F = M->getFunctionList().begin(); F != M->getFunctionList().end(); F++) { if (!F->isDeclaration()) { if (F->getName() == "caller") { Function* callee = M->getFunction("callee&...
2016 Mar 01
2
Insert CallInst within a function passing same parameters of the calling function.
...Function *new_function = CloneFunction(&F, VMap, false); new_function->setName(functionName + “_newfunction"); F.getParent()->getFunctionList().push_back(new_function); Function::ArgumentListType::iterator it = F.getArgumentList().begin(); Function::ArgumentListType::iterator end =...
2018 Feb 02
0
Debug info error on bitcode inline modification
...Support/raw_ostream.h" > > using namespace llvm; > > int main(int argc, char *argv[]) > { > SMDiagnostic error; > LLVMContext context; > Module *M = parseIRFile(argv[1], error, context).release(); > > for (Module::iterator F = M->getFunctionList().begin(); F != > M->getFunctionList().end(); F++) > { > if (!F->isDeclaration()) > { > if (F->getName() == "caller") > { > Function* calle...
2015 Feb 13
2
[LLVMdev] module functions
Hi. I would like to move first function of module to end. To do this, I remove function from module, then I insert it with getOrInsertFunction() method. It worked. But there is a problem: I can't see body of function (basic blocks). In other words, function basic blocks don't move. To solve, I store function basic blocks before remove it. and after function insertion, I want to insert
2009 Jun 25
0
[LLVMdev] Replacing instruction in LLVM IR by an intrinsics
On Thu, Jun 25, 2009 at 12:32 AM, ihusar<ihusar at fit.vutbr.cz> wrote: >                //now i need to create an instruction that represents a call to a intrinsic >                Function* FIntr = Intrinsic::getDeclaration(&M, Intrinsic::regread_i32); > >                // here it fails: void llvm::CallInst::init(llvm::Value*): >                //Assertion
2018 Mar 22
1
How to extract functions from Module A and put them into Module B, and generate a new IR file?
...nlineAsm(M.getModuleInlineAsm()); ModuleB-->setDataLayout(M.getDataLayout()); ModuleB-->setTargetTriple(M.getTargetTriple()); ModuleB-->setModuleInlineAsm(M.getModuleInlineAsm()); for (Function &F : M) { if (F.getName() == "My Criterion") ModuleA->getFunctionList().push_back(F); else ModuleB->getFunctionList().push_back(F); } WriteBitcodeToFile(ModuleA, osA); WriteBitcodeToFile(ModuleB, osB); } By doing this I can get two .bc files, but when I open it, for each function I can only get the declaration, but not the definition(func...
2018 Feb 05
1
Debug info error on bitcode inline modification
...;> using namespace llvm; >> >> int main(int argc, char *argv[]) >> { >> SMDiagnostic error; >> LLVMContext context; >> Module *M = parseIRFile(argv[1], error, context).release(); >> >> for (Module::iterator F = M->getFunctionList().begin(); F != >> M->getFunctionList().end(); F++) >> { >> if (!F->isDeclaration()) >> { >> if (F->getName() == "caller") >> { >>...
2015 May 19
2
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
...PO/GlobalDCE.cpp (revision 237590) +++ lib/Transforms/IPO/GlobalDCE.cpp (working copy) @@ -162,7 +162,10 @@ bool GlobalDCE::runOnModule(Module &M) { // themselves. for (unsigned i = 0, e = DeadFunctions.size(); i != e; ++i) { RemoveUnusedGlobalValue(*DeadFunctions[i]); - M.getFunctionList().erase(DeadFunctions[i]); + // Might have deleted the body of an available externally function that + // is still referenced. Leave the declaration. + if (DeadFunctions[i]->use_empty()) + M.getFunctionList().erase(DeadFunctions[i]); } NumFunctions += DeadFunction...
2008 Mar 03
1
[LLVMdev] Cloning a function
...declaration in the library module to the powf declaration in the generated module, as in: DenseMap<const Value*, Value *> val; val[m_builtins->getFunction("powf")] = currentModule()->getFunction("powf"); func = CloneFunction(originalFunc, val); currentModule()->getFunctionList().push_back(func); unfortunately after this we get an assert: vp-tris: /home/zack/projects/general/llvm/lib/Target/X86/X86CodeEmitter.cpp:412: unsigned int sizeOfImm(const llvm::TargetInstrDesc*): Assertion `0 && "Immediate size not set!"' failed. which I'm a little co...
2009 Jun 24
3
[LLVMdev] Replacing instruction in LLVM IR by an intrinsics
Hi everyone, I am trying to write a pass, that finds some instructions and replaces them with my intrinsics, but I am having problem understanding, how this should be done. Let's say I have this instruction: %tmp14 = load i32* getelementptr ([32 x i32]* @gpregs, i32 0, i64 28) and i need to read the load's operands and replace it by let's say: %tmp14 = call i32
2015 May 19
2
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
...ansforms/IPO/GlobalDCE.cpp (working copy) >> @@ -162,7 +162,10 @@ bool GlobalDCE::runOnModule(Module &M) { >> // themselves. >> for (unsigned i = 0, e = DeadFunctions.size(); i != e; ++i) { >> RemoveUnusedGlobalValue(*DeadFunctions[i]); >> - M.getFunctionList().erase(DeadFunctions[i]); >> + // Might have deleted the body of an available externally function >> that >> + // is still referenced. Leave the declaration. >> + if (DeadFunctions[i]->use_empty()) >> + M.getFunctionList().erase(DeadFunctions[...
2019 Aug 31
3
Usage of the jumptable attribute
...es it) to every function definition:     // includes ...     using namespace llvm;     namespace {       struct MyPass : public ModulePass {         static char ID;         MyPass() : ModulePass(ID) {}         bool runOnModule(Module &M) override {           for (Function &F : M.getFunctionList()) {             if (!F.isDeclaration()) { F.setUnnamedAddr(GlobalValue::UnnamedAddr::Global);               F.addFnAttr(Attribute::JumpTable);             }           }           return true;         }       };     }     char MyPass::ID = 0;     static RegisterPass<MyPass> X(&quot...
2008 Feb 13
3
[LLVMdev] LLVM2.2 x64 JIT trouble on VStudio build
...Now we going to create JIT ExistingModuleProvider *MP = new ExistingModuleProvider(M); ExecutionEngine *EE = ExecutionEngine::create(MP, false); sys::DynamicLibrary::AddSymbol("bar", (void*) bar); llvm::Module::FunctionListType& funcList = MP->getModule()->getFunctionList(); for (llvm::Module::FunctionListType::iterator i = funcList.begin() ; i != funcList.end() ; ++i) { EE->getPointerToFunction(i); } EE->recompileAndRelinkFunction(pFooF); std::vector<GenericValue> Args(1); Args[0].IntVal = APInt(32, 3);...
2011 Feb 22
2
[LLVMdev] Clone a function and change signature
...F = CloneFunction(CI->getCalledFunction()); DirectF->setName(CI->getCalledFunction()->getNameStr() + "_SPEC"); DirectF->setLinkage(GlobalValue::InternalLinkage); // add the extra argument new Argument(GEP->getPointerOperand()->getType(),"arg",DirectF); M.getFunctionList().push_back(DirectF); DirectF->dump(); SmallVector<Value*, 8> Args; for(unsigned j =1;j<CI->getNumOperands();j++) { Args.push_back(CI->getOperand(j)); } //Add the extra parameter Args.push_back(GEP->getPointerOperand()); CallInst *CallI = CallInst::Create(DirectF,Ar...
2010 May 02
2
[LLVMdev] Function insertion
Is there a way to insert a function at the start of a module rather than inserting it at the end, which happens by default? -- Adarsh Yoga Graduate Student, Computer Science Indiana University, Bloomington -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100502/30f9e9d4/attachment.html>
2012 Nov 03
1
[LLVMdev] import/export functions between Modules
I'm having trouble figuring out how to export/import IR functions at the C++ API level. I think I've got the linking part figured out, but I need to get the functions exporting from one module into another. I see how I can iterate over the functions in one, but I'm not clear on how to expose this name/reference into the other module. Is there a simple example/tutorial of this
2008 Feb 15
0
[LLVMdev] LLVM2.2 x64 JIT trouble on VStudio build
...T > ExistingModuleProvider *MP = new ExistingModuleProvider(M); > ExecutionEngine *EE = ExecutionEngine::create(MP, false); > > sys::DynamicLibrary::AddSymbol("bar", (void*) bar); > llvm::Module::FunctionListType& funcList = MP->getModule()- > >getFunctionList(); > > for (llvm::Module::FunctionListType::iterator i = > funcList.begin() ; i != funcList.end() ; ++i) > { > EE->getPointerToFunction(i); > } > > EE->recompileAndRelinkFunction(pFooF); > > std::vector<GenericValue> Args(1); &...
2017 Apr 05
2
Difference in EHType between ARM and AArch64
...ExceptionHandlingType()) {// // case ExceptionHandling::SjLj:// // case ExceptionHandling::DwarfCFI:// // case ExceptionHandling::ARM:// //*isCFIMoveForDebugging = true;*// //*if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI)*/*/ /**/ break;/*/ // for (auto &F: M.getFunctionList()) {// // // If the module contains any function with unwind data,// // // .eh_frame has to be emitted.// // // Ignore functions that won't get emitted.// // if (!F.isDeclarationForLinker() && F.needsUnwindTableEntry()) {// //*isCFIMoveForDebugging = false;*// //...
2016 Feb 09
2
CloneFunction during LTO leads to seg fault?
Hi Medhi, Thanks for you reply. Here is the full output of -print-after-all [1] and just the module itself after my pass[2]. I've looked over the IR, but I can't see anything obviously wrong. I'm not sure what you meant by: > You may want to try to add it at the end of the pipeline My pass is the last one added inside populateLTOPassManager. Should I add it to the