[LLVMdev] hoisting problem.

kiyancla at uiuc.edu kiyancla at uiuc.edu
Sun May 2 11:09:01 PDT 2004

First, sorry in advance for pasting code like this :) 
I'm doing a simple optimization pass for a cs326 class 
project.  The pass in question is LICM, and I'm getting an 
assertion when I try to hoist an instruction.  
My hoist function is below.  I dont think I need that 
copying in there, that was just something people on the 
newsgroup suggested.  I get the same assertion regardless. 
So, the code: 
  bool LICM::hoist(Instruction *I, const Loop* L){ 
    DEBUG(std::cerr << "HOIST\n"); 
    //remove instruction, and stick it in the preheader, 
    //the last Instruction of that block (which is a branch) 
    Instruction* I2 = I->clone(); 
    //we want to insert before the  
    //branch at the end 
    iplist<Instruction> preheaderInsts = 
    iplist<Instruction>::iterator i = preheaderInsts.end(); 
    preheaderInsts.insert(i, I2); 
    DEBUG(std::cerr << "HOIST: DONE\n"); 
    return false; 
and the assertion: 
While deleting: int%Billy 
Use still stuck around after Def is destroyed:  ret int 
opt: Value.cpp:51: virtual llvm::Value::~Value(): Assertion 
`Uses.begin() == Uses.end() &&"Uses remain when a value is 
destroyed!"' failed. 
nadir at quiche:~/src/llvm/lib/Transforms/LICM$ fg 
emacs LICM.cpp 
Any help is appreciated, 
Nadir Kiyanclar 
kiyancla at uiuc.edu 

More information about the llvm-dev mailing list