Fix problem where lli would not print out a 64 bit value when the client code
authorChris Lattner <sabre@nondot.org>
Fri, 2 Aug 2002 23:08:32 +0000 (23:08 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 2 Aug 2002 23:08:32 +0000 (23:08 +0000)
uses the modifier "%ld".  Now lli passes off "%lld" to the underlying runtime
library in this case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3230 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp

index 6d1354c42b10517689e97354428a641f113eb13a..1a425c2bb62fec27483f352f142886ba44187367 100644 (file)
@@ -351,9 +351,17 @@ GenericValue lle_X_sprintf(FunctionType *M, const vector<GenericValue> &Args) {
       case 'd': case 'i':
       case 'u': case 'o':
       case 'x': case 'X':
-        if (HowLong == 2)
+        if (HowLong >= 1) {
+          if (HowLong == 1) {
+            // Make sure we use %lld with a 64 bit argument because we might be
+            // compiling LLI on a 32 bit compiler.
+            unsigned Size = strlen(FmtBuf);
+            FmtBuf[Size] = FmtBuf[Size-1];
+            FmtBuf[Size+1] = 0;
+            FmtBuf[Size-1] = 'l';
+          }
           sprintf(Buffer, FmtBuf, Args[ArgNo++].ULongVal);
-        else
+        else
           sprintf(Buffer, FmtBuf, Args[ArgNo++].IntVal); break;
       case 'e': case 'E': case 'g': case 'G': case 'f':
         sprintf(Buffer, FmtBuf, Args[ArgNo++].DoubleVal); break;