[llvm-commits] Fold() function on TargetFolder class - removal of redundant constantexpr

Jin Gu Kang jaykang10 at imrc.kist.re.kr
Fri Feb 25 00:19:07 PST 2011


> Now, for various reasons, I didn't turn off *all* of llvm-gcc's use of 
> constant folding, but I turned off the huge majority of it. There are 
> some things like this snippet:
>      // If a previous proto existed with the wrong type, replace any 
> uses of it
>      // with the actual function and delete the proto.
>      if (FnEntry) {
>        FnEntry->replaceAllUsesWith(
>          TheFolder->CreateBitCast(Fn, FnEntry->getType())
>        );
>        changeLLVMConstant(FnEntry, Fn);
>        FnEntry->eraseFromParent();
>      }
> which works by replacing one constant with another. In theory, you could 
> find all uses of the constant and instead create a new bitcast 
> instruction that casts the constant then switch the users to use that 
> instruction, but it's not trivial to update this code like that. This 
> code creates a single replacement value. To do it with instructions you 
> would need to put one new instruction in each function the constant is 
> used. That's not impossible, I just don't think it's worth-while to 
> update every spot llvm-gcc does this sort of thing.

It was error-prone for me to modify all of llvm-gcc's spot which use
Folder's functions and I didn't know side-effect on original llvm-gcc 
according to this working.

Is it right to modify llvm-gcc to support NoFolder based on instruction?

Thanks.
Jin-Gu Kang



More information about the llvm-commits mailing list