[LLVMdev] Basic block with two return instructions

Garrison Venn gvenn.cfe.dev at gmail.com
Fri Feb 5 09:25:05 PST 2010


Did your test include running llvm::verifyFunction(...) on the function in question?
I guess I should test this, but I would have thought this would catch the issue.

Garrison

On Feb 5, 2010, at 12:13, Russell Wallace wrote:

> Fair enough. In that case, is there an elegant way to test whether a
> basic block already has a terminator instruction?
> 
> (I can think of several ways to do it in the front-end, but all of
> them are fairly inelegant. The problem I'm trying to solve is things
> like 'a return instruction needs to be added to the end of a function,
> if and only if the programmer didn't already end the function with an
> explicit return statement', 'if the programmer did write an explicit
> return statement everything after it must be ignored' etc.)
> 
> On Fri, Feb 5, 2010 at 4:58 PM, Kenneth Uildriks <kennethuil at gmail.com> wrote:
>> On Fri, Feb 5, 2010 at 10:56 AM, Russell Wallace
>> <russell.wallace at gmail.com> wrote:
>>> When I generate a simple function with a single basic block with two
>>> return instructions, I had expected that if it did anything at all, it
>>> would use the first one, but it actually seems to ignore the first one
>>> and take the value of the second one.
>>> 
>>> I'm guessing what's going on here is something like "a basic block
>>> must end in exactly one terminator instruction, having two of them is
>>> undefined behavior and the code generator is entitled to do anything
>>> including make demons fly out of your nose"; is this correct?
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>> 
>> 
>> That's pretty much been my experience.  Usually, something crashes
>> when I try it though.
>> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list