[LLVMdev] LLVM use chains

Vassil Vassilev vvasilev at cern.ch
Wed Oct 23 19:41:39 PDT 2013


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




More information about the llvm-dev mailing list