search for: clonefunction

Displaying 20 results from an estimated 84 matches for "clonefunction".

2011 Oct 14
1
[LLVMdev] CloneFunction
Hi, I want to duplicate a function and transfer it from one module to another. I found "CloneFunction()" but it needs an "vMap". I found that "vMap" is used to map the original values to the new values. So, hypothetically, if the original function uses a global variable from the previous module and I want that use in the new function to be mapped to a global variable in the...
2016 Jul 15
2
clone function
On 14 July 2016 at 20:07, Mehdi Amini <mehdi.amini at apple.com> wrote: > > On Jul 14, 2016, at 7:58 AM, Pierre Gagelin via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > Hi, > > I am trying to use the CloneFunction from llvm/Transforms/Utils/Cloning.h > and I don't understand how the ValueToValueMapTy argument should be > initialized. For instance, let say I want to clone this function (to add an > argument): > > define void @function(i32 %i) #0 { > entry: > %i.addr = alloca i32, al...
2016 Jul 14
2
clone function
Hi, I am trying to use the CloneFunction from llvm/Transforms/Utils/Cloning.h and I don't understand how the ValueToValueMapTy argument should be initialized. For instance, let say I want to clone this function (to add an argument): define void @function(i32 %i) #0 { entry: %i.addr = alloca i32, align 4 store i32 %i, i32* %i.addr...
2016 Feb 12
3
CloneFunction during LTO leads to seg fault?
...a Forum, hosted by The Linux Foundation > -----Original Message----- > From: Tobias Edler von Koch [mailto:tobias at codeaurora.org] > Sent: Friday, February 12, 2016 9:51 AM > To: Mehdi Amini; Scott A. Carr > Cc: llvm-dev at lists.llvm.org; Sergei Larin > Subject: Re: [llvm-dev] CloneFunction during LTO leads to seg fault? > > On 02/11/2016 10:05 AM, Mehdi Amini via llvm-dev wrote: > >> Is this a bug? Is there an assumption that a function won't be cloned after > inlining? Is there an assumption that the debug info metadata nodes are well > formed when they g...
2016 Feb 11
2
CloneFunction during LTO leads to seg fault?
y > On Feb 11, 2016, at 8:00 AM, Scott A. Carr <carr27 at purdue.edu> wrote: > > Hello again, > > I've narrowed down my issue to a small test case. The core of the issue is that CloneFunction (with ModuleLevelChanges=true) on a function that has had other functions inlined into it generates orphan debug info metadata nodes. Then when this module is emitted, DwarfDebug crashes. > > The C program is here [1]. Note that the inliner should inline add into main. > > If compil...
2016 Feb 09
2
CloneFunction during LTO leads to seg fault?
Hello, I'm writing an LTO pass and I'd like to be able to duplicate a function (with debugging info). I'm trying to accomplish this with CloneFunction but it's leading to a seg fault in ld. I've whittled down my problem so that it occurs in this small pass [1]. If I run this pass with opt, I get the expected result (i.e. a valid program that calls main twice). If I run the pass during LTO, ld seg faults. Here is a pastebin of when...
2016 Feb 09
2
CloneFunction during LTO leads to seg fault?
...wrote: >> On Feb 9, 2016, at 10:24 AM, Scott A. Carr via llvm-dev <llvm-dev at lists.llvm.org> wrote: >> >> Hello, >> >> I'm writing an LTO pass and I'd like to be able to duplicate a function (with debugging info). I'm trying to accomplish this with CloneFunction but it's leading to a seg fault in ld. >> >> I've whittled down my problem so that it occurs in this small pass [1]. >> >> If I run this pass with opt, I get the expected result (i.e. a valid program that calls main twice). If I run the pass during LTO, ld seg fault...
2008 Mar 03
1
[LLVMdev] Cloning a function
Hi, we have two modules, one that we basically use as a library in which we store a lot of simple function calls, the other is small program generated at run-time. Whenever a function call for to one of the builtin functions is being called we use CloneFunction to clone the instruction from the library module and insert it in the generated module. The problem is for example when we have something like: declare float @powf(float, float) define void @pow(<4 x float>* %res, /*other args*/...) { entry: ... %call = tail call float @powf( float %tmp1,...
2014 Dec 18
1
[LLVMdev] Metadata/Value split has landed
...2014-Dec-18, at 01:43, Keno Fischer <kfischer at college.harvard.edu> wrote: > > Hi Duncan, > > I'm in the following situation for which this change caused an assertion failure: > > Three modules, let's say A B C > Two function, F in A, G in B > > Now I CloneFunction F into B (call the new function F') and inline F' into G. > Now, for the problematic part, where I try to extract G (and all referenced values) into C: > > upon encountering any debug node in the inlined code, it tries to clone the DISubprogram for F', so it creates a tempora...
2012 Apr 29
0
[LLVMdev] Bug in Cloning.h?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, unless I overlook something, the second version of CloneFunction() (from http://llvm.org/doxygen/Cloning_8h_source.html): 00114 Function *CloneFunction(const Function *F, 00115 ValueToValueMapTy &VMap, 00116 bool ModuleLevelChanges, 00117 ClonedCodeInfo *CodeInfo = 0); 00118 00119 /// C...
2017 Jun 20
2
CloneFunctionInto produces invalid debug info
...Subprogram (that would prohibit cloning the DICompileUnit is side-stepped). But then I remembered the discussion we had in http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20170306/435395.html and now I think that this might actually be legal IR. With this in mind, the correct behavior for CloneFunction is to not remap any debug metadata (and just attach the original nodes) if it is cloning into the same Module *and* there is not DISubprogram attached to the function. -- adrian > On Jun 20, 2017, at 7:52 AM, Sergei Larin <slarin at codeaurora.org> wrote: > > Adrian, > > T...
2008 Jul 09
0
[LLVMdev] Cloning Functions
...efore but I can't find it by searching. > > What's the right way to clone a Function? I need to save off the text at a > certain point and spit it out later, after other optimizations have run. But > I need to spit out the original text, not the optimized version. You can use CloneFunction (in llvm/Transforms/Utils/Cloning.h) to duplicate a function within a module. That said, I'm not completely sure what you're trying to do, so I don't know if that's what you're looking for. -Eli
2008 Jul 09
2
[LLVMdev] Cloning Functions
I seem to recall havbing asked this before but I can't find it by searching. What's the right way to clone a Function? I need to save off the text at a certain point and spit it out later, after other optimizations have run. But I need to spit out the original text, not the optimized version. What would be the most effective way to do this?
2013 Jun 10
0
[LLVMdev] CFG of a function
...uction, BB's, arguments, and everything you cloned will be deleted from memory, and it'll just seem like nothing was cloned. Ok, now in order to identify all the values between the two copies of the functions you need to use that ValueToValueMap that you created and used as an argument for cloneFunction. This VMap can be seen as a hash of values, and everything in the cloned function is mapped to something in the original function inside this map. So, if you need to identify an equivalent BB between them, for example, you could use VMap[BBfromOrigFunc] to access the pointer to the equivalent BB in...
2008 Jul 09
2
[LLVMdev] Cloning Functions
...ing. > > > > What's the right way to clone a Function? I need to save off the text at > > a certain point and spit it out later, after other optimizations have > > run. But I need to spit out the original text, not the optimized > > version. > > You can use CloneFunction (in llvm/Transforms/Utils/Cloning.h) to > duplicate a function within a module. > > That said, I'm not completely sure what you're trying to do, so I > don't know if that's what you're looking for. Ok, I've looked at the cloning stuff and it's on the right t...
2017 May 03
3
Should it be legal for two functions to have the same !dbg attachment?
...his it seemed obvious to me we should disallow this by preventing two functions from sharing the same !dbg attachment. After implementing my new verifier check (and updating a couple of hand-crafted testcases that violated it) I noticed that the new check causes the cloning unit test to fail: When CloneFunction clones a function into the same module, it will not create a deep copy of the function's debug info. Before I start fixing this (which is a bit of work, because we will need to re-parent all of the function's DILocations into the cloned DISubprogram) I wanted to get everyone's opinion o...
2014 Dec 02
2
[LLVMdev] Cloned Functions Are Not the Same
I am trying to use CloneFunction to clone every IR function in a program, give the cloned versions a prefix and call the clones from the original functions (redirect the calls). Surprisingly, I see that after the LTO optimizations, the number of machine basic blocks in the two functions differ in some cases. Is this reasonable a...
2016 Mar 01
2
Insert CallInst within a function passing same parameters of the calling function.
...ome: int foo(int a, int b) { bar(a,b); … ... } I am using the following code: bool ThreadSanitizer::runOnFunction(Function &F) { ValueToValueMapTy VMap; Function *new_function = CloneFunction(&F, VMap, false); new_function->setName(functionName + “_newfunction"); F.getParent()->getFunctionList().push_back(new_function);...
2009 Nov 05
0
[LLVMdev] Debug Information for LLVM 2.6 and TOT
...col number - DIScope - lexical scope - DILocation - inlined at location When an instruction is inlined, the first three fields will stay unchanged. But the inlined instruction will have non null "inlined at location" indicating where this instruction was inlined. - Devang Index: Utils/CloneFunction.cpp =================================================================== --- Utils/CloneFunction.cpp (revision 86036) +++ Utils/CloneFunction.cpp (working copy) @@ -20,6 +20,7 @@ #include "llvm/IntrinsicInst.h" #include "llvm/GlobalVariable.h" #include "llvm/Function.h&qu...
2009 Nov 18
2
[LLVMdev] Strange error using CallInst constructor
...t goes anyway. I'm trying to invoke the following constructor: CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, const Twine &NameStr, BasicBlock *InsertAtEnd); My code is: using namespace llvm; void replaceByClone(Function *f, CallInst *I){ Function *clone = CloneFunction(f); BasicBlock::iterator ii(I); ReplaceInstWithInst(I->getParent()->getInstList(),ii,CallInst(clone,clone->arg_begin(),clone->arg_end())); } Compiling generates the following error: error: no matching function for call to ‘llvm::CallInst::CallInst(llvm::Function*&, llvm::ilist_it...