[llvm-commits] r133708 strikes me again? - the case clang stalls

John McCall rjmccall at apple.com
Mon Aug 8 23:50:24 PDT 2011


On Aug 8, 2011, at 11:03 PM, Cameron Zwarich wrote:
> Do you know why this only happens with MSVC++? We have had cases of infinite loops in the past caused by MSVC++ miscomputing code.

It looks completely bogus that this works under either Clang or GCC.  replaceSuccessorsPhiUsesWith is doing a dyn_cast on the end() of a BasicBlock.  Due to craziness in ilist_traits<Instruction>, this is loading from the memory immediately before ilist_traits<Instruction>::Sentinel, i.e. from random global memory.  Since loads from global memory are likely to succeed, and even more likely to not randomly return Instruction::PHI, I can easily imagine this being a latent bug.

There's no way that MSVC++ could be figuring that this is happening and aggressively optimizing, but I guess it could somehow be locating something that looks like a PHINode there (Instruction::PHI == 48 == '0'), or it could be screwing up the template metaprograms somehow.

Anyway, the fix is to either (1) put an empty() check in replaceSuccessorsPhiUsesWith or (2) say that you can never do replaceAllUsesWith on partially-formed IR.  (2) would be pretty cruel to front-ends.

John.



More information about the llvm-commits mailing list