[LLVMdev] Problem in CodeExtractor::severSplitPHINodes()
Devang Patel
dpatel at apple.com
Thu Nov 20 17:22:38 PST 2008
Hi Jack,
On Nov 20, 2008, at 2:56 PM, Jack Tzu-Han Hung wrote:
> Hi Devang,
>
> Thanks for your reply.
>
> But if you look at the comment of BasicBlock::splitBasicBlock(), it
> says that "...an unconditional branch is added to the new BB, and
> the rest of the instructions in the BB are moved to the newBB,
> including the old terminator."
>
> So, the terminator of the newBB is exactly the same as the
> terminator of the oldBB. IF the oldBB has multiple successors, then
> newBB will have multiple successors.
>
> Actually there is an example for this (in "wc", the word count
> program):
>
> for (gotsp = 1; len = read(fd, buf, MAXBSIZE);){
> if (len == -1) {
> perror(file);
> exit(1);
> }
> // do other stuff
> }
>
> Compiled with llvm-gcc -O1, the loop header has three successors:
> one to inside the loop, one to outside the loop, and the third to a
> block that contains exit(1).
>
> ExtractLoop() has problem with this this example.
Yes, it is a bug in loop extractor. See
BasicBlockUtils.cpp:SplitBlock(). It does the right thing.
Do you want to prepare a a patch to fix loop extractor ?
-
Devang
More information about the llvm-dev
mailing list