This is an archive of the discontinued LLVM Phabricator instance.

Bug 9761: EmitEndOfAsmFile is not the final emission point.
AbandonedPublic

Authored by arsenm on Apr 5 2013, 3:05 PM.

Details

Reviewers
grosbach
Summary

MCStreamer::Finish() implementations add more code after the EmitEndOfAsmFile, which shouldn't happen, so move this after the Finish

Diff Detail

Event Timeline

arsenm updated this revision to Unknown Object (????).Apr 8 2013, 9:47 PM
grosbach accepted this revision.Apr 22 2013, 2:29 PM

Totally reasonable. Please make sure to test very carefully on as many platforms as you have access to. I've been bitten lots of times by unintended consequences from cleanups like that. That is, finding all sorts of latent assumptions in the surrounding code.

This breaks 6 tests. 2 of them are Darwin x86 (2010-12-02-MC-Set.ll and personality.ll) because of the placement of .subsections_via_symbols

The comment emitting it in X86AsmPrinter says

// Funny Darwin hack: This flag tells the linker that no global symbols
// contain code that falls through to other global symbols (e.g. the obvious
// implementation of multiple entry points).

So does the placement of this not actually matter? Is it OK to just move the expected location in the tests?

The other 4 are ARM and Mips object tests, which I don't understand yet.

".subsections_via_symbols" should be the last thing in the file. It's mostly stylistic, but has been that way for a very long time, and I'd really prefer to keep it that way.

.subsections_via_symbols isn't the last thing as it is now. This patch puts it there, breaking the 2 tests.

The broken object tests seem to be broken not from the content, but just the order things happen to occur in.

e.g. CodeGen/Thumb2/constant-islands.ll
The ARMMachObjectWriter is dependent on ARMAsmPrinter::EmitEndOfAsmFile calling MCObjectStreamer::EmitLabel to set the MCDataFragment on the nonlazy pointers (LLVM ERROR: symbol 'L__ZTV7RagDoll$non_lazy_ptr' can not be undefined in a subtraction expression), and I'm not sure where to move things around to fix this.

ARM and Mips ELF have similar problems. They add some flags in EmitEndOfAsmFile that are actually emitted in the OutStreamer Finish.

Should these move into the MC<ELF|MachO>Streamer::FinishImpls? It seems like target specific stuff doesn't belong there. Should there be a new function? The distinction between EmitEndOfAsmFile and MCStreamer::Finish is kind of confusing. Both "claim" to be the end of emission. The Emit* functions setting state that's used later feels wrong.

Ah. OK. Those ARM failures aren't about subsections_via_symbols, really. This is other things that function does in addition to that.

This seems to be a reasonable explanation for why these functions are called in the order they are. Other than the name of the function being somewhat of a misnomer, what's the underlying motivation for the change? Perhaps there's a simpler solution.

My problem is that AMDIL assumes the last thing in the program is "end", which is emitted in EmitEndOfAsmFile. When using debug info, the OutStreamer.Finish() dumps the line tables after it, which doesn't parse.

I could probably fight with the thing that parses the debug output to get it to work, but I think it would make more sense if this function emitted the actual end.

arsenm abandoned this revision.Nov 13 2013, 6:40 PM

This is obsoleted by r194575 which just deletes the whole function.

arsenm reclaimed this revision.Nov 13 2013, 6:41 PM

Whoops, wrong one

arsenm abandoned this revision.Mar 9 2016, 9:14 PM

No longer care about this target