From 53211aa9f130ce307c86698953e09746d70a6ef1 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 7 Jun 2019 06:05:26 +0000 Subject: [PATCH] [lld] Allow args::getInterger to parse args larger than 2^31-1 Differential Revision: https://reviews.llvm.org/D62933 llvm-svn: 362770 --- lld/Common/Args.cpp | 5 +++-- lld/include/lld/Common/Args.h | 3 ++- lld/test/wasm/large-memory.test | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 lld/test/wasm/large-memory.test diff --git a/lld/Common/Args.cpp b/lld/Common/Args.cpp index b57b940..0691189 100644 --- a/lld/Common/Args.cpp +++ b/lld/Common/Args.cpp @@ -26,12 +26,13 @@ CodeGenOpt::Level lld::args::getCGOptLevel(int OptLevelLTO) { 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/lld/include/lld/Common/Args.h b/lld/include/lld/Common/Args.h index d943646..cf8002d 100644 --- a/lld/include/lld/Common/Args.h +++ b/lld/include/lld/Common/Args.h @@ -25,7 +25,8 @@ namespace args { 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 getStrings(llvm::opt::InputArgList &Args, int Id); diff --git a/lld/test/wasm/large-memory.test b/lld/test/wasm/large-memory.test new file mode 100644 index 0000000..8d403b5 --- /dev/null +++ b/lld/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 -- 2.7.4