Displaying 20 results from an estimated 34 matches for "valuetovaluemapty".
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, align 4
ret void
}
to another function which should, after the CloneFunction, be like...
2016 Jul 15
2
clone function
...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, align 4
> store i32 %i, i32* %i.addr, align 4
> ret void
> }
>
> to another fu...
2018 Sep 06
2
Replacing a function from one module into another one
...t;llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
#include <iostream>
#include <string.h>
const std::string originalFileName = "tracer.ll";
const std::string referenceFileName = "tracer_ref.ll";
void populateVMap(llvm::ValueToValueMapTy &VMap, llvm::Function *fOld,
llvm::Function *fNew) {
llvm::Function::arg_iterator DestI = fOld->arg_begin();
for (llvm::Function::const_arg_iterator J = fNew->arg_begin(); J !=
fNew->arg_end();
++J) {
DestI->setName(J->getName());
VMap[&*J] = &*DestI++;...
2018 Sep 06
2
Replacing a function from one module into another one
Hi Philip,
Thanks for the reference, I was able to follow it and copy the code that I
saw necessary, but I still have some issues (references are still not
updated). I created the function:
void populateVMap(llvm::ValueToValueMapTy &VMap, llvm::Function *fOld,
llvm::Function *fNew) {
llvm::Function::arg_iterator DestI = fOld->arg_begin();
for (llvm::Function::const_arg_iterator J = fNew->arg_begin(); J !=
fNew->arg_end();
++J) {
DestI->setName(J->getName());
VMap[&*J] = &*DestI++;...
2016 Mar 01
2
Insert CallInst within a function passing same parameters of the calling function.
.....
...
}
I want to insert int the LLVM IR a call instructions to a function “bar” that requires the same parameters of foo.
So my function foo will become:
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");...
2012 Jun 21
3
[LLVMdev] Cloning block for newbie
...n is a definition (so I could remove
or rename the value)?
Is there a VMap book for newbies?
Is there some documentations I forgot to look at?
Thank you.
virtual BasicBlock* createAlteredBasicBlock(BasicBlock * basicBlock, const
Twine & Name = "", Function * F = 0){
ValueToValueMapTy VMap;
BasicBlock * alteredBB = llvm::CloneBasicBlock (basicBlock,
VMap, Name, F);
return alteredBB;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120621/169acc2e/attachment.html&g...
2018 Sep 04
2
Replacing a function from one module into another one
Hi Philip,
Thank you very much for your answer, the vector declaration example worked.
I'm pretty sure the ValueToValueMapTy is the last thing I need because I
even saw there is another function that could help me llvm*:*:RemapFunction
<http://llvm.org/doxygen/namespacellvm.html#addf0183e92893bdbcde00fc9091dda93>;
but my problem is that I don't know how to populate the ValueToValueMapTy
(VMap) and I couldn'...
2013 May 29
2
[LLVMdev] CloneFunctionInto() Error
...5b3 main + 7251
13 libc.so.6 0x00007f039618076d __libc_start_main + 237
14 opt 0x0000000000521f91
Stack dump:
0. Program arguments: opt -load ../../../Release+Asserts/lib/Blocks.so
-blocks
Aborted (core dumped)
***The code is
> std::vector<Type*> ArgTypes;
> ValueToValueMapTy VMap;
>FunctionType *FTy =
FunctionType::get(F.getFunctionType()->getReturnType(),
ArgTypes, F.getFunctionType()->isVarArg());
>Function *NewF = Function::Create(FTy, F.getLinkage(), F.getName());
> SmallVector<ReturnInst*, 8> Returns;
>Clone...
2017 Jun 15
4
CloneFunctionInto produces invalid debug info
...precisely a constructor of a
struct/class) and adds a parameter.
First, we create a new function with a new function type, which includes
the newly added parameter:
Function *NF = Function::Create(NewFTy, F.getLinkage(), F.getName() +
"Cloned", F.getParent());
and after setting up the ValueToValueMapTy, we use the CloneFunctionInto
method to clone the function body
CloneFunctionInto(NF, &F, Map, true, Returns, "Cloned");
The code seems to work as intended, but when we try to emit debug symbols
(clang -g flag) the pass fails with following message:
"All DICompileUnits must b...
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 /// CloneFunction - Version of the function that doesn't need the VMap.
00120 ///
00121 inline Function *CloneFunction(const Function *F, ClonedCodeInfo *Co...
2017 Jun 08
4
DICompileUnit duplication in LLVM 4.0.0?
...Old,
FunctionType *NewTy) const {
Function *New = Function::Create(NewTy, Old.getLinkage(), "", &M);
New->setAttributes(Old.getAttributes());
New->setCallingConv(Old.getCallingConv());
// Map old arguments to the new arguments.
ValueToValueMapTy VMap;
for (auto OldFI = Old.arg_begin(), OldFE = Old.arg_end(),
NewFI = New->arg_begin();
OldFI != OldFE; ++OldFI, ++NewFI) {
Argument &OldA = *OldFI;
Argument &NewA = *NewFI;
NewA.setName(OldA.getName());
VMap[&OldA] = &NewA;
}
SmallVect...
2019 Oct 30
2
How to make ScalarEvolution recompute SCEV values?
...make ScalarEvolution re-calculate the SCEV values for the unknown SCEVs, or, is there a way to re-run ScalarEvolution and LoopInfo analysis pass during my pass?
This is my current CloneLoop function:
Loop *cloneLoop(Function *F, Loop *L, LoopInfo *LI, const Twine &NameSuffix,
ValueToValueMapTy &VMap) {
// original preheader of the loop
const auto PreHeader = L->getLoopPreheader();
// keep track of the original predecessors
std::set<BasicBlock *> AllPredecessors;
for (auto PredIt = pred_begin(PreHeader), E = pred_end(PreHeader);
PredIt !...
2013 May 29
0
[LLVMdev] CloneFunctionInto() Error
...rt_main + 237
> 14 opt 0x0000000000521f91
> Stack dump:
> 0. Program arguments: opt -load ../../../Release+Asserts/lib/Blocks.so
> -blocks
> Aborted (core dumped)
>
>
>
> ***The code is
>
>
> > std::vector<Type*> ArgTypes;
>
> > ValueToValueMapTy VMap;
>
> >FunctionType *FTy =
> FunctionType::get(F.getFunctionType()->getReturnType(),
> ArgTypes, F.getFunctionType()->isVarArg());
>
> >Function *NewF = Function::Create(FTy, F.getLinkage(), F.getName());
>
> > SmallVector<Ret...
2013 Nov 05
1
[LLVMdev] Thread-safe cloning
...d lock around the entire copy
procedure?
In case you are interested, here is the algorithm I'm using to copy a
Module to a same (or different) LLVMContext:
if (&context == &other.myContext)
{
// If the context is shared, we can use cloning
ValueToValueMapTy map;
myModule = CloneModule(other.myModule, map);
}
else
{
// Otherwise, round trip the module to a stream and then back
// into the new context. This approach allows for duplication
// and optimization to proceed in...
2017 Jun 08
2
DICompileUnit duplication in LLVM 4.0.0?
...nType *NewTy) const {
>> Function *New = Function::Create(NewTy, Old.getLinkage(), "", &M);
>> New->setAttributes(Old.getAttributes());
>> New->setCallingConv(Old.getCallingConv());
>>
>> // Map old arguments to the new arguments.
>> ValueToValueMapTy VMap;
>> for (auto OldFI = Old.arg_begin(), OldFE = Old.arg_end(),
>> NewFI = New->arg_begin();
>> OldFI != OldFE; ++OldFI, ++NewFI) {
>> Argument &OldA = *OldFI;
>> Argument &NewA = *NewFI;
>> NewA.setName(OldA.getName...
2011 Jul 06
2
[LLVMdev] First steps with LLVM and partial evaluation
...;llvm/DerivedTypes.h"
#include "llvm/LLVMContext.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Transforms/Utils/Cloning.h"
using namespace std;
using namespace llvm;
static Function *cloneFunctionInfo(const Function *F,
ValueToValueMapTy& ValueMap)
{
vector<const Type*> ArgTypes;
// The user might be deleting arguments to the function by specifying them in
// the ValueMap. If so, we need to not add the arguments to the arg ty vector
//
for (Function::const_arg_iterator I = F->arg_begin(), E = F->...
2017 Jun 15
2
CloneFunctionInto produces invalid debug info
...) and adds a parameter.
>
> First, we create a new function with a new function type, which includes
> the newly added parameter:
>
> Function *NF = Function::Create(NewFTy, F.getLinkage(), F.getName() +
> "Cloned", F.getParent());
>
>
> and after setting up the ValueToValueMapTy, we use the CloneFunctionInto
> method to clone the function body
>
> CloneFunctionInto(NF, &F, Map, true, Returns, "Cloned");
>
>
> The code seems to work as intended, but when we try to emit debug symbols
> (clang -g flag) the pass fails with following message:...
2012 Jun 21
0
[LLVMdev] Cloning block for newbie
...gt; >
>> >
>> > Thank you.
>> >
>> >
>> >
>> > virtual BasicBlock* createAlteredBasicBlock(BasicBlock * basicBlock,
>> > const
>> > Twine & Name = "", Function * F = 0){
>> >
>> > ValueToValueMapTy VMap;
>> > BasicBlock * alteredBB = llvm::CloneBasicBlock (basicBlock,
>> > VMap, Name, F);
>> >
>> > return alteredBB;
>> > }
>> >
>> >
>> > _______________________________________________
>> >...
2017 Jun 15
3
CloneFunctionInto produces invalid debug info
...>> First, we create a new function with a new function type, which includes the newly added parameter:
>>>
>>>> Function *NF = Function::Create(NewFTy, F.getLinkage(), F.getName() + "Cloned", F.getParent());
>>>
>>> and after setting up the ValueToValueMapTy, we use the CloneFunctionInto method to clone the function body
>>>
>>>> CloneFunctionInto(NF, &F, Map, true, Returns, "Cloned");
>>>
>>> The code seems to work as intended, but when we try to emit debug symbols (clang -g flag) the pass fails...
2017 Jun 20
2
CloneFunctionInto produces invalid debug info
...d parameter:
>>>>>>>
>>>>>>>> Function *NF = Function::Create(NewFTy, F.getLinkage(),
>>>>>>>> F.getName() + "Cloned", F.getParent());
>>>>>>>
>>>>>>> and after setting up the ValueToValueMapTy, we use the
>>>>>>> CloneFunctionInto method to clone the function body
>>>>>>>
>>>>>>>> CloneFunctionInto(NF, &F, Map, true, Returns, "Cloned");
>>>>>>>
>>>>>>> The code see...