[PATCH] Fix bug in llvm::DemoteRegToStack

Nick Lewycky nicholas at mxc.ca
Mon Jan 12 22:26:37 PST 2015


Akira Hatanaka wrote:
>> +  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"?

Yes. "StoreInst *SI = net StoreInst(Val, Ptr);" will create it without 
inserting it anywhere, then you can insert it later via. 
SI->insertBefore(Inst) or insertAfter(Inst).

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