This is an archive of the discontinued LLVM Phabricator instance.

[MC] When using bundle aligment, align sections to bundle size
ClosedPublic

Authored by dschuff on Apr 20 2015, 3:44 PM.

Details

Summary

Bundle aligment requires that the functions always start at an aligned address.
Usually this is ensured by the compiler, but assembly code does not always
begin with a .align directive.

This change ensures that sections get the correct alignment if they contain
any instructions and bundling is enabled. (It also makes LLVM match the
behavior of GNU as).

Diff Detail

Repository
rL LLVM

Event Timeline

dschuff updated this revision to Diff 24069.Apr 20 2015, 3:44 PM
dschuff retitled this revision from to [MC] When using bundle aligment, align sections to bundle size.
dschuff updated this object.
dschuff edited the test plan for this revision. (Show Details)
dschuff added reviewers: eliben, jvoung.
dschuff added a subscriber: Unknown Object (MLST).
Why do you need to call it from both locations?

Needs a testcase.

lib/MC/MCELFStreamer.cpp
134 ↗(On Diff #24069)

Start function names with a lowercase letter.

see comment in the test plan section about testing. Should I just change llvm-objdump to print the alignment of each section so I can add a test?

wrt calling it from both places:
This needs to happen for every section that has instructions, so it has to be on switching away from each section, and on finish (unless the last section is guaranteed to be switched away from before FinishImpl runs?)
Alternatively, I could just iterate over all the sections in some finish function, but I didn't see a way to get them from here. Maybe in MCAssembler::Finish?

lib/MC/MCELFStreamer.cpp
134 ↗(On Diff #24069)

Done.

dschuff updated this revision to Diff 24072.Apr 20 2015, 4:04 PM
  • use lowercase function name
jvoung edited edge metadata.Apr 20 2015, 4:13 PM

How about use "llvm-readobj -sections" to test? That will print out the sections plus the "AddressAlignment".

dschuff updated this revision to Diff 24075.Apr 20 2015, 4:32 PM
dschuff edited edge metadata.
  • Add test

How about use "llvm-readobj -sections" to test? That will print out the sections plus the "AddressAlignment".

ah, didn't even know about that. Done.

dschuff edited the test plan for this revision. (Show Details)Apr 20 2015, 4:40 PM
rafael accepted this revision.Apr 20 2015, 5:00 PM
rafael added a reviewer: rafael.

LGTM with a comment on each call on why it is there.

test/MC/X86/AlignedBundling/section-alignment.s
9 ↗(On Diff #24075)

Add a
CHECK-NOT: Name

to make sure it is matching the correct section.

This revision is now accepted and ready to land.Apr 20 2015, 5:00 PM
dschuff updated this revision to Diff 24083.Apr 20 2015, 5:11 PM
dschuff edited edge metadata.
  • add comments and tighten test
test/MC/X86/AlignedBundling/section-alignment.s
9 ↗(On Diff #24075)

Done.

LGTM with test update

test/MC/X86/AlignedBundling/section-alignment.s
16 ↗(On Diff #24083)

CHECK-NOT in here too.

20 ↗(On Diff #24083)

and here

This revision was automatically updated to reflect the committed changes.