Hi,
I have:
...
@.str1 = private unnamed_addr constant [21 x i8] c"Now f is a function\0A\00", align 1
; Function Attrs: ssp uwtable
define i32 @_Z1fv() #2 {
entry:
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x i8]* @.str1, i32 0, i32 0))
ret i32 0
}
Then I get after trying to erase the function from the module:
511 GV->eraseFromParent();
(gdb) p GV->dump()
; Function Attrs: ssp uwtable
define i32 @_Z1fv() #2 {
entry:
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x i8]* @.str1, i32 0, i32 0))
ret i32 0
}
(gdb) n
513 }
(gdb) br llvm::AssemblyWriter::printModule(llvm::Module const*)
(gdb) p m_CurTransaction->getModule()->dump()
llvm::AssemblyWriter::printGlobal (this=0x7fff5fbfe850, GV=0x107274058) at /Users/vvassilev/workspace/root/interpreter/llvm/src/lib/IR/AsmWriter.cpp:1444
1444 if (GV->isMaterializable())
(gdb) p GV->use_empty()
$78 = false
(gdb) p GV->use_back()
$79 = (class llvm::User *) 0x107279b88
(gdb) p GV->use_back()->dump()
i8* getelementptr inbounds ([21 x i8]* @.str1, i32 0, i32 0)
$80 = void
(gdb) p (('llvm::Instruction'*)GV->use_back())
$81 = ('llvm::Instruction' *) 0x107279b88
(gdb) p (('llvm::Instruction'*)GV->use_back())->getParent()
$82 = (const 'llvm::BasicBlock' *) 0x6c675f7878630046
My conclusion was that the use chains weren't updated. Is there any recommended way of deleting a llvm::Function such that the use chain of the globals that it uses to be updated correspondingly?
Many thanks,
Vassil
Hi,
I have:
...
@.str1 = private unnamed_addr constant [21 x i8] c"Now f is a
function\0A\00", align 1
; Function Attrs: ssp uwtable
define i32 @_Z1fv() #2 {
entry:
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x
i8]* @.str1, i32 0, i32 0))
ret i32 0
}
Then I get after trying to erase the function from the module:
511 GV->eraseFromParent();
(gdb) p GV->dump()
; Function Attrs: ssp uwtable
define i32 @_Z1fv() #2 {
entry:
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x
i8]* @.str1, i32 0, i32 0))
ret i32 0
}
(gdb) n
513 }
(gdb) br llvm::AssemblyWriter::printModule(llvm::Module const*)
(gdb) p m_CurTransaction->getModule()->dump()
llvm::AssemblyWriter::printGlobal (this=0x7fff5fbfe850, GV=0x107274058) at
/Users/vvassilev/workspace/root/interpreter/llvm/src/lib/IR/AsmWriter.cpp:1444
1444 if (GV->isMaterializable())
(gdb) p GV->use_empty()
$78 = false
(gdb) p GV->use_back()
$79 = (class llvm::User *) 0x107279b88
(gdb) p GV->use_back()->dump()
i8* getelementptr inbounds ([21 x i8]* @.str1, i32 0, i32 0)
$80 = void
(gdb) p (('llvm::Instruction'*)GV->use_back())
$81 = ('llvm::Instruction' *) 0x107279b88
(gdb) p (('llvm::Instruction'*)GV->use_back())->getParent()
$82 = (const 'llvm::BasicBlock' *) 0x6c675f7878630046
My conclusion was that the use chains weren't updated. Is there any
recommended way of deleting a llvm::Function such that the use chain of the
globals that it uses to be updated correspondingly?
You probably want replaceAllUsesWith.
Hi,
I have:
...
@.str1 = private unnamed_addr constant [21 x i8] c"Now f is a
function\0A\00", align 1
; Function Attrs: ssp uwtable
define i32 @_Z1fv() #2 {
entry:
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x
i8]* @.str1, i32 0, i32 0))
ret i32 0
}
Then I get after trying to erase the function from the module:
511 GV->eraseFromParent();
(gdb) p GV->dump()
; Function Attrs: ssp uwtable
define i32 @_Z1fv() #2 {
entry:
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x
i8]* @.str1, i32 0, i32 0))
ret i32 0
}
(gdb) n
513 }
(gdb) br llvm::AssemblyWriter::printModule(llvm::Module const*)
(gdb) p m_CurTransaction->getModule()->dump()
llvm::AssemblyWriter::printGlobal (this=0x7fff5fbfe850, GV=0x107274058) at
/Users/vvassilev/workspace/root/interpreter/llvm/src/lib/IR/AsmWriter.cpp:1444
1444 if (GV->isMaterializable())
(gdb) p GV->use_empty()
$78 = false
(gdb) p GV->use_back()
$79 = (class llvm::User *) 0x107279b88
(gdb) p GV->use_back()->dump()
i8* getelementptr inbounds ([21 x i8]* @.str1, i32 0, i32 0)
$80 = void
(gdb) p (('llvm::Instruction'*)GV->use_back())
$81 = ('llvm::Instruction' *) 0x107279b88
(gdb) p (('llvm::Instruction'*)GV->use_back())->getParent()
$82 = (const 'llvm::BasicBlock' *) 0x6c675f7878630046
My conclusion was that the use chains weren't updated. Is there any
recommended way of deleting a llvm::Function such that the use chain of the
globals that it uses to be updated correspondingly?
You probably want replaceAllUsesWith.
I am sorry I don't understand. Are you suggesting calling replaceAllUses of the .str1? What I really want to do is to 'erase' the function. By erasing I'd expect the uses of .str1 to 0 (because in the example I have it is used only by f()) and I see they are not.
Vassil
You probably want replaceAllUsesWith.
I am sorry I don't understand. Are you suggesting calling replaceAllUses of
the .str1? What I really want to do is to 'erase' the function. By erasing
I'd expect the uses of .str1 to 0 (because in the example I have it is used
only by f()) and I see they are not.
To remove something, the normal idiom is
Foo->replaceAllUsesWith(UndefValue::get(FooTy));
Foo->eraseFromParent();
Is that what you are trying to do?
Cheers,
Rafael
You probably want replaceAllUsesWith.
I am sorry I don't understand. Are you suggesting calling replaceAllUses of
the .str1? What I really want to do is to 'erase' the function. By erasing
I'd expect the uses of .str1 to 0 (because in the example I have it is used
only by f()) and I see they are not.
To remove something, the normal idiom is
Foo->replaceAllUsesWith(UndefValue::get(FooTy));
Foo->eraseFromParent();
Is that what you are trying to do?
I want llvm to 'forget' already compiled and run function. Both from the ExecutionEngine/JIT and the llvm::Module. The problem using replaceAllUsesWith is that the JIT inserts a invisible use so that it can prevent from out-of-sync situations. I already tried using ExecutionContext::updateGlobalMapping and it doesn't help.
Vassil