[llvm-commits] CVS: llvm/tools/lli/ExecutionEngine.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed May 7 15:32:01 PDT 2003


Changes in directory llvm/tools/lli:

ExecutionEngine.cpp updated: 1.7 -> 1.8

---
Log message:

Fix bug: Jello/2003-05-07-ArgumentTest.llx
Also fixes yacr2/ks benchmarks


---
Diffs of the changes:

Index: llvm/tools/lli/ExecutionEngine.cpp
diff -u llvm/tools/lli/ExecutionEngine.cpp:1.7 llvm/tools/lli/ExecutionEngine.cpp:1.8
--- llvm/tools/lli/ExecutionEngine.cpp:1.7	Wed Apr 23 15:41:01 2003
+++ llvm/tools/lli/ExecutionEngine.cpp	Wed May  7 15:31:37 2003
@@ -193,26 +193,42 @@
 
 
 void *ExecutionEngine::CreateArgv(const std::vector<std::string> &InputArgv) {
-  // Pointers are 64 bits...
-  // FIXME: Assumes 64 bit target
-  PointerTy *Result = new PointerTy[InputArgv.size()+1];
-  DEBUG(std::cerr << "ARGV = " << (void*)Result << "\n");
+  if (getTargetData().getPointerSize() == 8) {   // 64 bit target?
+    PointerTy *Result = new PointerTy[InputArgv.size()+1];
+    DEBUG(std::cerr << "ARGV = " << (void*)Result << "\n");
+    
+    for (unsigned i = 0; i < InputArgv.size(); ++i) {
+      unsigned Size = InputArgv[i].size()+1;
+      char *Dest = new char[Size];
+      DEBUG(std::cerr << "ARGV[" << i << "] = " << (void*)Dest << "\n");
+      
+      copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
+      Dest[Size-1] = 0;
+      
+      // Endian safe: Result[i] = (PointerTy)Dest;
+      StoreValueToMemory(PTOGV(Dest), (GenericValue*)(Result+i), Type::LongTy);
+    }
+    Result[InputArgv.size()] = 0;
+    return Result;
 
-  for (unsigned i = 0; i < InputArgv.size(); ++i) {
-    unsigned Size = InputArgv[i].size()+1;
-    char *Dest = new char[Size];
-    DEBUG(std::cerr << "ARGV[" << i << "] = " << (void*)Dest << "\n");
+  } else {                                      // 32 bit target?
+    int *Result = new int[InputArgv.size()+1];
+    DEBUG(std::cerr << "ARGV = " << (void*)Result << "\n");
 
-    copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
-    Dest[Size-1] = 0;
-
-    // Endian safe: Result[i] = (PointerTy)Dest;
-    StoreValueToMemory(PTOGV(Dest), (GenericValue*)(Result+i),
-                       Type::LongTy);  // 64 bit assumption
+    for (unsigned i = 0; i < InputArgv.size(); ++i) {
+      unsigned Size = InputArgv[i].size()+1;
+      char *Dest = new char[Size];
+      DEBUG(std::cerr << "ARGV[" << i << "] = " << (void*)Dest << "\n");
+      
+      copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
+      Dest[Size-1] = 0;
+      
+      // Endian safe: Result[i] = (PointerTy)Dest;
+      StoreValueToMemory(PTOGV(Dest), (GenericValue*)(Result+i), Type::IntTy);
+    }
+    Result[InputArgv.size()] = 0;  // null terminate it
+    return Result;
   }
-
-  Result[InputArgv.size()] = 0;
-  return Result;
 }
 
 /// EmitGlobals - Emit all of the global variables to memory, storing their





More information about the llvm-commits mailing list