[lld] Allow args::getInterger to parse args larger than 2^31-1

Differential Revision: https://reviews.llvm.org/D62933

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@362770 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Common/Args.cpp b/Common/Args.cpp
index b57b940..0691189 100644
--- a/Common/Args.cpp
+++ b/Common/Args.cpp
@@ -26,12 +26,13 @@
   return CodeGenOpt::Default;
 }
 
-int lld::args::getInteger(opt::InputArgList &Args, unsigned Key, int Default) {
+int64_t lld::args::getInteger(opt::InputArgList &Args, unsigned Key,
+                              int64_t Default) {
   auto *A = Args.getLastArg(Key);
   if (!A)
     return Default;
 
-  int V;
+  int64_t V;
   if (to_integer(A->getValue(), V, 10))
     return V;
 
diff --git a/include/lld/Common/Args.h b/include/lld/Common/Args.h
index d943646..cf8002d 100644
--- a/include/lld/Common/Args.h
+++ b/include/lld/Common/Args.h
@@ -25,7 +25,8 @@
 
 llvm::CodeGenOpt::Level getCGOptLevel(int OptLevelLTO);
 
-int getInteger(llvm::opt::InputArgList &Args, unsigned Key, int Default);
+int64_t getInteger(llvm::opt::InputArgList &Args, unsigned Key,
+                   int64_t Default);
 
 std::vector<StringRef> getStrings(llvm::opt::InputArgList &Args, int Id);
 
diff --git a/test/wasm/large-memory.test b/test/wasm/large-memory.test
new file mode 100644
index 0000000..8d403b5
--- /dev/null
+++ b/test/wasm/large-memory.test
@@ -0,0 +1,5 @@
+RUN: llc -filetype=obj %p/Inputs/start.ll -o %t.o
+
+; Verify we can parse large integers such as when we ask for 2G of total
+; memory.
+RUN: wasm-ld %t.o -o %t.wasm --max-memory=2147483648