Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Ticket #50 (new defect)

Opened 6 months ago

Last modified 4 months ago

branching into an inline asm block is broken

Reported by: lindquist Assigned to:
Priority: major Milestone: Beta
Version: Keywords: asm
Cc:

Description (Last modified by lindquist)

The D spec states that any labels in a function are accesible from inline asm, and also that any labels inside inline asm are valid target for goto.

LLVM does not support this. Below is the IRC log of my inquery on this matter in the LLVM IRC channel:

<lindquist> is there any way to force a basic block to emitted when generating code, even though it has no predecessors
<_sabre_> give it a predecessor?
<_sabre_> otherwise no
<_sabre_> why do you want that?
<lindquist> well I'm hacking around a bit.
<lindquist> the thing is D allows jumping out of an asm block, so I'm experimenting with it to see what actually works (even though that may be pure luck)
<aKor> lindquist: you can have pretty nasty issues then
<aKor> it's better to have some 'collector' block
<aKor> which will dispatch codeflow
<lindquist> I'm not sure I follow
<aKor> well
<aKor> give each bb, which can be reached from asm unique number
<aKor> and return this number out of asm block
<aKor> (in some local var)
<aKor> then, use this number as input to big switch
<aKor> (in the 'collector' block)
<aKor> which will do actual jumping
<aKor> you might also want another variable, which will tell you, whether exit form asm block was 'normal', or via such jump
<aKor> *from
<aKor> does this make sence?
<lindquist> yes
<aKor> this is pretty proven method for such insane branches :)
<lindquist> the only thing I've seen it used for in D is overflow checking etc, branching to somewhere that throws an exception
<lindquist> this could certainly be made to work with that scheme
<_sabre_> I would model that as having the asm return a value
<_sabre_> and then use an llvm branch to pick the destination
<aKor> _sabre_: yeah: <aKor> you might also want another variable, which will tell you, whether exit form asm block was 'normal', or via such jump
<_sabre_> :)
<lindquist> thanx for the hints :)

This does seem like a feasible way to implement this.

Change History

06/08/08 19:13:19 changed by lindquist

  • description changed.

06/26/08 09:38:47 changed by ChristianK

  • summary changed from branching in/out of an inline asm block is broken to branching into an inline asm block is broken.

As of [324] branching to outside labels from inside inline asm is supported. Using a goto to jump inside inline asm is still to be implemented.

08/05/08 15:05:01 changed by lindquist

  • milestone set to Beta.
Copyright © 2008, LDC Development Team.