[llvm-commits] [llvm] r79697 - in /llvm/trunk: test/MC/MachO/sections.s tools/llvm-mc/AsmParser.cpp
Daniel Dunbar
daniel at zuster.org
Fri Aug 21 16:30:16 PDT 2009
Author: ddunbar
Date: Fri Aug 21 18:30:15 2009
New Revision: 79697
URL: http://llvm.org/viewvc/llvm-project?rev=79697&view=rev
Log:
llvm-mc: Improve handling of implicit alignment for magic section directives
(e.g., .objc_message_refs).
- Just emit a .align when we see the directive; this isn't exactly what 'as'
does but in practice it should be ok, at least for now. See FIXME.
Modified:
llvm/trunk/test/MC/MachO/sections.s
llvm/trunk/tools/llvm-mc/AsmParser.cpp
Modified: llvm/trunk/test/MC/MachO/sections.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/sections.s?rev=79697&r1=79696&r2=79697&view=diff
==============================================================================
--- llvm/trunk/test/MC/MachO/sections.s (original)
+++ llvm/trunk/test/MC/MachO/sections.s Fri Aug 21 18:30:15 2009
@@ -121,8 +121,7 @@
// CHECK: ('address', 0)
// CHECK: ('size', 0)
// CHECK: ('offset', 2464)
- // FIXME: We aren't setting alignment correctly yet.
-// CHECX: ('alignment', 2)
+// CHECK: ('alignment', 2)
// CHECK: ('reloc_offset', 0)
// CHECK: ('num_reloc', 0)
// CHECK: ('flags', 0x3)
@@ -135,8 +134,7 @@
// CHECK: ('address', 0)
// CHECK: ('size', 0)
// CHECK: ('offset', 2464)
- // FIXME: We aren't setting alignment correctly yet.
-// CHECX: ('alignment', 3)
+// CHECK: ('alignment', 3)
// CHECK: ('reloc_offset', 0)
// CHECK: ('num_reloc', 0)
// CHECK: ('flags', 0x4)
@@ -149,8 +147,7 @@
// CHECK: ('address', 0)
// CHECK: ('size', 0)
// CHECK: ('offset', 2464)
- // FIXME: We aren't setting alignment correctly yet.
-// CHECX: ('alignment', 4)
+// CHECK: ('alignment', 4)
// CHECK: ('reloc_offset', 0)
// CHECK: ('num_reloc', 0)
// CHECK: ('flags', 0xe)
@@ -241,8 +238,7 @@
// CHECK: ('address', 0)
// CHECK: ('size', 0)
// CHECK: ('offset', 2464)
- // FIXME: We aren't setting alignment correctly yet.
-// CHECX: ('alignment', 2)
+// CHECK: ('alignment', 2)
// CHECK: ('reloc_offset', 0)
// CHECK: ('num_reloc', 0)
// CHECK: ('flags', 0x6)
@@ -255,8 +251,7 @@
// CHECK: ('address', 0)
// CHECK: ('size', 0)
// CHECK: ('offset', 2464)
- // FIXME: We aren't setting alignment correctly yet.
-// CHECX: ('alignment', 2)
+// CHECK: ('alignment', 2)
// CHECK: ('reloc_offset', 0)
// CHECK: ('num_reloc', 0)
// CHECK: ('flags', 0x7)
@@ -282,8 +277,7 @@
// CHECK: ('address', 0)
// CHECK: ('size', 0)
// CHECK: ('offset', 2464)
- // FIXME: We aren't setting alignment correctly yet.
-// CHECX: ('alignment', 2)
+// CHECK: ('alignment', 2)
// CHECK: ('reloc_offset', 0)
// CHECK: ('num_reloc', 0)
// CHECK: ('flags', 0x9)
@@ -296,8 +290,7 @@
// CHECK: ('address', 0)
// CHECK: ('size', 0)
// CHECK: ('offset', 2464)
- // FIXME: We aren't setting alignment correctly yet.
-// CHECX: ('alignment', 2)
+// CHECK: ('alignment', 2)
// CHECK: ('reloc_offset', 0)
// CHECK: ('num_reloc', 0)
// CHECK: ('flags', 0xa)
@@ -427,8 +420,7 @@
// CHECK: ('address', 0)
// CHECK: ('size', 0)
// CHECK: ('offset', 2464)
- // FIXME: We aren't setting alignment correctly yet.
-// CHECX: ('alignment', 2)
+// CHECK: ('alignment', 2)
// CHECK: ('reloc_offset', 0)
// CHECK: ('num_reloc', 0)
// CHECK: ('flags', 0x10000005)
@@ -441,8 +433,7 @@
// CHECK: ('address', 0)
// CHECK: ('size', 0)
// CHECK: ('offset', 2464)
- // FIXME: We aren't setting alignment correctly yet.
-// CHECX: ('alignment', 2)
+// CHECK: ('alignment', 2)
// CHECK: ('reloc_offset', 0)
// CHECK: ('num_reloc', 0)
// CHECK: ('flags', 0x10000005)
Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=79697&r1=79696&r2=79697&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Fri Aug 21 18:30:15 2009
@@ -794,13 +794,24 @@
// FIXME: Arch specific.
// FIXME: Cache this!
- // FIXME: Handle the implicit alignment!!
MCSection *S = 0; // Ctx.GetSection(Section);
if (S == 0)
S = MCSectionMachO::Create(Segment, Section, TAA, StubSize,
SectionKind(), Ctx);
Out.SwitchSection(S);
+
+ // Set the implicit alignment, if any.
+ //
+ // FIXME: This isn't really what 'as' does; I think it just uses the implicit
+ // alignment on the section (e.g., if one manually inserts bytes into the
+ // section, then just issueing the section switch directive will not realign
+ // the section. However, this is arguably more reasonable behavior, and there
+ // is no good reason for someone to intentionally emit incorrectly sized
+ // values into the implicitly aligned sections.
+ if (Align)
+ Out.EmitValueToAlignment(Align, 0, 1, 0);
+
return false;
}
More information about the llvm-commits
mailing list