[llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp

Joel Stanley jstanley at cs.uiuc.edu
Wed Feb 12 14:46:01 PST 2003


Changes in directory llvm/lib/CWriter:

Writer.cpp updated: 1.76 -> 1.77

---
Log message:

Fixed alloca declaration problem on sun.


---
Diffs of the changes:

Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.76 llvm/lib/CWriter/Writer.cpp:1.77
--- llvm/lib/CWriter/Writer.cpp:1.76	Wed Nov 20 12:32:03 2002
+++ llvm/lib/CWriter/Writer.cpp	Wed Feb 12 14:45:00 2003
@@ -504,6 +504,17 @@
   return Changed;
 }
 
+static void generateAllocaDecl(ostream& Out) 
+{
+  // On SunOS, we need to insert the alloca macro & proto for the builtin.
+  Out << "#ifdef sun\n"
+      << "extern void *__builtin_alloca(unsigned long);\n"
+      << "#define alloca(x) __builtin_alloca(x)\n"
+      << "#else\n"
+      << "#include <alloca.h>\n"
+      << "#endif\n\n";
+}
+
 void CWriter::printModule(Module *M) {
   // Calculate which global values have names that will collide when we throw
   // away type information.
@@ -528,18 +539,18 @@
   //Out << "#include <stdlib.h>\n";
 
   // get declaration for alloca
-  Out << "/* Provide Declarations */\n"
-      << "#include <alloca.h>\n\n"
-
-    // Provide a definition for null if one does not already exist,
-    // and for `bool' if not compiling with a C++ compiler.
-      << "#ifndef NULL\n#define NULL 0\n#endif\n\n"
+  Out << "/* Provide Declarations */\n";
+  generateAllocaDecl(Out);
+  
+  // Provide a definition for null if one does not already exist,
+  // and for `bool' if not compiling with a C++ compiler.
+  Out << "#ifndef NULL\n#define NULL 0\n#endif\n\n"
       << "#ifndef __cplusplus\ntypedef unsigned char bool;\n#endif\n"
-
+    
       << "\n\n/* Support for floating point constants */\n"
       << "typedef unsigned long long ConstantDoubleTy;\n"
       << "typedef unsigned int        ConstantFloatTy;\n"
-
+    
       << "\n\n/* Global Declarations */\n";
 
   // First output all the declarations for the program, because C requires





More information about the llvm-commits mailing list