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
On 23 October 2013 22:41, Vassil Vassilev <vvasilev at cern.ch> wrote:> 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.> Many thanks, > Vassil > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On 10/24/13 2:13 AM, Rafael EspĂndola wrote:> On 23 October 2013 22:41, Vassil Vassilev <vvasilev at cern.ch> wrote: >> 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> > >> Many thanks, >> Vassil >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev