[llvm-commits] [PATCH] [MC] .pushsection / .popsection support

Joerg Sonnenberger joerg at britannica.bec.de
Thu Feb 10 13:14:33 PST 2011


On Wed, Feb 09, 2011 at 03:38:56PM -0800, Nick Lewycky wrote:
> On 9 February 2011 13:40, Joerg Sonnenberger <joerg at britannica.bec.de>wrote:
> 
> > Because .popstack changes both the current and last section. More
> > importantly, it can set the previous section to NULL, so it can't just
> > be emulated with two calls to SwitchSection.
> >
> 
> Right, I realize that it can't, but the MCStreamer API is supposed to mirror
> the set of directives actually supported. SwitchSection maps to ".section"
> but SwitchSection2 doesn't as there's no directive which set the current and
> previous section to any strings you want. The MCStreamer implementations can
> just modify CurSection and PrevSection directly, they don't need an API for
> it.

I think the handling of push/pop/section can and should be isolated from
the "backend" view of changing the active section. Attached patch is a
newer version which makes push/pop/switch non-virtual. The actual
implementation overrides ChangeSection, which gets called whenever there
is an actual section change. The only case left is the logging streamer,
which would now only log this specific event. I'm not sure if that is a
regression or not.

> Splitting the current SwitchSection would be cleaner and fix some issues
> > as I mentioned.
> >
> 
> Sure, feel free to refactor but please make them protected methods.
> Currently CurSection and PrevSection are protected. I'd suggest replacing
> those with the stacks and then get{Current,Previous}Section return the top
> of the stack.

I've kept them separate as the stack manipulation is a separate path.

> > Also, did you check that a .s which consists entirely of ".previous" gives
> > a
> > > nice error? GAS says:
> > > x.s:1: Warning: .previous without corresponding .section; ignored
> >
> > I haven't touched .previous and don't plan to do it for this patch.
> > It is an unrelated issue.
> >
> 
> Good point!

I've fixed it with the handling of .ident, which is using the new
push/pop primitives to ensure that it doesn't clobber PrevSection.

Joerg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: section-stack.diff
Type: text/x-diff
Size: 15186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110210/5d86e78c/attachment.diff>


More information about the llvm-commits mailing list