summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
diff options
context:
space:
mode:
authorNicolas Geoffray <nicolas.geoffray@lip6.fr>2010-05-24 12:24:11 +0000
committerNicolas Geoffray <nicolas.geoffray@lip6.fr>2010-05-24 12:24:11 +0000
commitc5327226e48208e17e464a47edbda062d0d1f9f9 (patch)
tree9b335ec4e109622d19cdfa2491e7ef4544cf584c /llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
parente9cd6d069d7eb4c1b4bbe1e5503d2153267bf9d8 (diff)
downloadbcm5719-llvm-c5327226e48208e17e464a47edbda062d0d1f9f9.tar.gz
bcm5719-llvm-c5327226e48208e17e464a47edbda062d0d1f9f9.zip
Encode the Caml frametable by following what the comment says: the number of descriptors
is first emitted, and StackOffsets are emitted in 16 bits. llvm-svn: 104488
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
index a8c3c7b2176..f92127f2274 100644
--- a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
@@ -104,6 +104,21 @@ void OcamlGCMetadataPrinter::finishAssembly(AsmPrinter &AP) {
AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection());
EmitCamlGlobal(getModule(), AP, "frametable");
+ int NumDescriptors = 0;
+ for (iterator I = begin(), IE = end(); I != IE; ++I) {
+ GCFunctionInfo &FI = **I;
+ for (GCFunctionInfo::iterator J = FI.begin(), JE = FI.end(); J != JE; ++J) {
+ NumDescriptors++;
+ }
+ }
+
+ if (NumDescriptors >= 1<<16) {
+ // Very rude!
+ report_fatal_error(" Too much descriptor for ocaml GC");
+ }
+ AP.EmitInt16(NumDescriptors);
+ AP.EmitAlignment(IntPtrSize == 4 ? 2 : 3);
+
for (iterator I = begin(), IE = end(); I != IE; ++I) {
GCFunctionInfo &FI = **I;
@@ -135,11 +150,13 @@ void OcamlGCMetadataPrinter::finishAssembly(AsmPrinter &AP) {
for (GCFunctionInfo::live_iterator K = FI.live_begin(J),
KE = FI.live_end(J); K != KE; ++K) {
- assert(K->StackOffset < 1<<16 &&
- "GC root stack offset is outside of fixed stack frame and out "
- "of range for ocaml GC!");
-
- AP.EmitInt32(K->StackOffset);
+ if (K->StackOffset >= 1<<16) {
+ // Very rude!
+ report_fatal_error(
+ "GC root stack offset is outside of fixed stack frame and out "
+ "of range for ocaml GC!");
+ }
+ AP.EmitInt16(K->StackOffset);
}
AP.EmitAlignment(IntPtrSize == 4 ? 2 : 3);
OpenPOWER on IntegriCloud