[PATCH] Fix bug in llvm::DemoteRegToStack

Akira Hatanaka ahatanak at gmail.com
Thu Jan 8 13:04:28 PST 2015


> +  StoreInst *Store = new StoreInst(&I, Slot, InsertPt);

>  +

>  +  // Change all of the users of the instruction, except the Store we've 

> just

>  +  // inserted, to read from the stack slot.

>  +  SmallVector<User*, 4> UsersOfI(I.users());

>  +

>  +  for (User *U : UsersOfI) {

>  +    if (PHINode *PN = dyn_cast<PHINode>(U)) {

> 

> Can you avoid the extra copy? What if you create the store now, but 

>  don't insert it yet? (I think InsertPt can't be one of the users, correct?)


I'm probably not understanding your suggestion, but is it possible to create the Store instruction without adding it the UseList of "I"? Also, I think InsertPt can be one of the users if the def (instruction "I") is immediately followed by a user of "I".

If that doesn't work, I was thinking maybe I can just split it into two parts. The first part just splits the critical edge and fixes the CFG, if that's necessary. After that, load instructions are inserted before all the users. The last step computes the insertion point and inserts the store instruction there.


http://reviews.llvm.org/D6729

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list