[llvm] r359068 - [CommandLine] Provide parser<unsigned long> instantiation to allow cl::opt<uint64_t> on LP64 platforms
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 23 19:40:20 PDT 2019
Author: maskray
Date: Tue Apr 23 19:40:20 2019
New Revision: 359068
URL: http://llvm.org/viewvc/llvm-project?rev=359068&view=rev
Log:
[CommandLine] Provide parser<unsigned long> instantiation to allow cl::opt<uint64_t> on LP64 platforms
Summary:
And migrate opt<unsigned long long> to opt<uint64_t>
Fixes PR19665
Differential Revision: https://reviews.llvm.org/D60933
Modified:
llvm/trunk/include/llvm/Support/CommandLine.h
llvm/trunk/lib/Support/CommandLine.cpp
llvm/trunk/lib/Support/RandomNumberGenerator.cpp
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp
llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/trunk/tools/llvm-lto/llvm-lto.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp
llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
Modified: llvm/trunk/include/llvm/Support/CommandLine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CommandLine.h (original)
+++ llvm/trunk/include/llvm/Support/CommandLine.h Tue Apr 23 19:40:20 2019
@@ -973,6 +973,29 @@ public:
extern template class basic_parser<unsigned>;
//--------------------------------------------------
+// parser<unsigned long>
+//
+template <>
+class parser<unsigned long> final : public basic_parser<unsigned long> {
+public:
+ parser(Option &O) : basic_parser(O) {}
+
+ // parse - Return true on error.
+ bool parse(Option &O, StringRef ArgName, StringRef Arg, unsigned long &Val);
+
+ // getValueName - Overload in subclass to provide a better default value.
+ StringRef getValueName() const override { return "ulong"; }
+
+ void printOptionDiff(const Option &O, unsigned long V, OptVal Default,
+ size_t GlobalWidth) const;
+
+ // An out-of-line virtual method to provide a 'home' for this class.
+ void anchor() override;
+};
+
+extern template class basic_parser<unsigned long>;
+
+//--------------------------------------------------
// parser<unsigned long long>
//
template <>
@@ -986,7 +1009,7 @@ public:
unsigned long long &Val);
// getValueName - Overload in subclass to provide a better default value.
- StringRef getValueName() const override { return "uint"; }
+ StringRef getValueName() const override { return "ulong"; }
void printOptionDiff(const Option &O, unsigned long long V, OptVal Default,
size_t GlobalWidth) const;
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Tue Apr 23 19:40:20 2019
@@ -54,6 +54,7 @@ template class basic_parser<bool>;
template class basic_parser<boolOrDefault>;
template class basic_parser<int>;
template class basic_parser<unsigned>;
+template class basic_parser<unsigned long>;
template class basic_parser<unsigned long long>;
template class basic_parser<double>;
template class basic_parser<float>;
@@ -78,6 +79,7 @@ void parser<bool>::anchor() {}
void parser<boolOrDefault>::anchor() {}
void parser<int>::anchor() {}
void parser<unsigned>::anchor() {}
+void parser<unsigned long>::anchor() {}
void parser<unsigned long long>::anchor() {}
void parser<double>::anchor() {}
void parser<float>::anchor() {}
@@ -1663,6 +1665,16 @@ bool parser<unsigned>::parse(Option &O,
return false;
}
+// parser<unsigned long> implementation
+//
+bool parser<unsigned long>::parse(Option &O, StringRef ArgName, StringRef Arg,
+ unsigned long &Value) {
+
+ if (Arg.getAsInteger(0, Value))
+ return O.error("'" + Arg + "' value invalid for ulong argument!");
+ return false;
+}
+
// parser<unsigned long long> implementation
//
bool parser<unsigned long long>::parse(Option &O, StringRef ArgName,
@@ -1670,7 +1682,7 @@ bool parser<unsigned long long>::parse(O
unsigned long long &Value) {
if (Arg.getAsInteger(0, Value))
- return O.error("'" + Arg + "' value invalid for uint argument!");
+ return O.error("'" + Arg + "' value invalid for ullong argument!");
return false;
}
@@ -1851,6 +1863,7 @@ PRINT_OPT_DIFF(bool)
PRINT_OPT_DIFF(boolOrDefault)
PRINT_OPT_DIFF(int)
PRINT_OPT_DIFF(unsigned)
+PRINT_OPT_DIFF(unsigned long)
PRINT_OPT_DIFF(unsigned long long)
PRINT_OPT_DIFF(double)
PRINT_OPT_DIFF(float)
Modified: llvm/trunk/lib/Support/RandomNumberGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/RandomNumberGenerator.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/lib/Support/RandomNumberGenerator.cpp (original)
+++ llvm/trunk/lib/Support/RandomNumberGenerator.cpp Tue Apr 23 19:40:20 2019
@@ -26,13 +26,9 @@ using namespace llvm;
#define DEBUG_TYPE "rng"
-// Tracking BUG: 19665
-// http://llvm.org/bugs/show_bug.cgi?id=19665
-//
-// Do not change to cl::opt<uint64_t> since this silently breaks argument parsing.
-static cl::opt<unsigned long long>
- Seed("rng-seed", cl::value_desc("seed"), cl::Hidden,
- cl::desc("Seed for the random number generator"), cl::init(0));
+static cl::opt<uint64_t> Seed("rng-seed", cl::value_desc("seed"), cl::Hidden,
+ cl::desc("Seed for the random number generator"),
+ cl::init(0));
RandomNumberGenerator::RandomNumberGenerator(StringRef Salt) {
LLVM_DEBUG(if (Seed == 0) dbgs()
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Tue Apr 23 19:40:20 2019
@@ -321,10 +321,10 @@ static cl::opt<int> ClMappingScale("asan
cl::desc("scale of asan shadow mapping"),
cl::Hidden, cl::init(0));
-static cl::opt<unsigned long long> ClMappingOffset(
- "asan-mapping-offset",
- cl::desc("offset of asan shadow mapping [EXPERIMENTAL]"), cl::Hidden,
- cl::init(0));
+static cl::opt<uint64_t>
+ ClMappingOffset("asan-mapping-offset",
+ cl::desc("offset of asan shadow mapping [EXPERIMENTAL]"),
+ cl::Hidden, cl::init(0));
// Optimization flags. Not user visible, used mostly for testing
// and benchmarking the tool.
Modified: llvm/trunk/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp Tue Apr 23 19:40:20 2019
@@ -124,10 +124,10 @@ static cl::opt<bool> ClEnableKhwasan(
// is accessed. The shadow mapping looks like:
// Shadow = (Mem >> scale) + offset
-static cl::opt<unsigned long long> ClMappingOffset(
- "hwasan-mapping-offset",
- cl::desc("HWASan shadow mapping offset [EXPERIMENTAL]"), cl::Hidden,
- cl::init(0));
+static cl::opt<uint64_t>
+ ClMappingOffset("hwasan-mapping-offset",
+ cl::desc("HWASan shadow mapping offset [EXPERIMENTAL]"),
+ cl::Hidden, cl::init(0));
static cl::opt<bool>
ClWithIfunc("hwasan-with-ifunc",
Modified: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Tue Apr 23 19:40:20 2019
@@ -304,21 +304,21 @@ static cl::opt<bool> ClWithComdat("msan-
// These options allow to specify custom memory map parameters
// See MemoryMapParams for details.
-static cl::opt<unsigned long long> ClAndMask("msan-and-mask",
- cl::desc("Define custom MSan AndMask"),
- cl::Hidden, cl::init(0));
+static cl::opt<uint64_t> ClAndMask("msan-and-mask",
+ cl::desc("Define custom MSan AndMask"),
+ cl::Hidden, cl::init(0));
-static cl::opt<unsigned long long> ClXorMask("msan-xor-mask",
- cl::desc("Define custom MSan XorMask"),
- cl::Hidden, cl::init(0));
+static cl::opt<uint64_t> ClXorMask("msan-xor-mask",
+ cl::desc("Define custom MSan XorMask"),
+ cl::Hidden, cl::init(0));
-static cl::opt<unsigned long long> ClShadowBase("msan-shadow-base",
- cl::desc("Define custom MSan ShadowBase"),
- cl::Hidden, cl::init(0));
+static cl::opt<uint64_t> ClShadowBase("msan-shadow-base",
+ cl::desc("Define custom MSan ShadowBase"),
+ cl::Hidden, cl::init(0));
-static cl::opt<unsigned long long> ClOriginBase("msan-origin-base",
- cl::desc("Define custom MSan OriginBase"),
- cl::Hidden, cl::init(0));
+static cl::opt<uint64_t> ClOriginBase("msan-origin-base",
+ cl::desc("Define custom MSan OriginBase"),
+ cl::Hidden, cl::init(0));
static const char *const kMsanModuleCtorName = "msan.module_ctor";
static const char *const kMsanInitName = "__msan_init";
Modified: llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp (original)
+++ llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.cpp Tue Apr 23 19:40:20 2019
@@ -38,17 +38,17 @@ using Instr = llvm::cfi_verify::FileAnal
namespace llvm {
namespace cfi_verify {
-unsigned long long SearchLengthForUndef;
-unsigned long long SearchLengthForConditionalBranch;
+uint64_t SearchLengthForUndef;
+uint64_t SearchLengthForConditionalBranch;
-static cl::opt<unsigned long long, true> SearchLengthForUndefArg(
+static cl::opt<uint64_t, true> SearchLengthForUndefArg(
"search-length-undef",
cl::desc("Specify the maximum amount of instructions "
"to inspect when searching for an undefined "
"instruction from a conditional branch."),
cl::location(SearchLengthForUndef), cl::init(2));
-static cl::opt<unsigned long long, true> SearchLengthForConditionalBranchArg(
+static cl::opt<uint64_t, true> SearchLengthForConditionalBranchArg(
"search-length-cb",
cl::desc("Specify the maximum amount of instructions "
"to inspect when searching for a conditional "
Modified: llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h (original)
+++ llvm/trunk/tools/llvm-cfi-verify/lib/GraphBuilder.h Tue Apr 23 19:40:20 2019
@@ -46,8 +46,8 @@ using Instr = llvm::cfi_verify::FileAnal
namespace llvm {
namespace cfi_verify {
-extern unsigned long long SearchLengthForUndef;
-extern unsigned long long SearchLengthForConditionalBranch;
+extern uint64_t SearchLengthForUndef;
+extern uint64_t SearchLengthForConditionalBranch;
struct ConditionalBranchNode {
uint64_t Address;
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Tue Apr 23 19:40:20 2019
@@ -154,7 +154,8 @@ static list<std::string> Name(
"the -regex option <pattern> is interpreted as a regular expression."),
value_desc("pattern"), cat(DwarfDumpCategory));
static alias NameAlias("n", desc("Alias for -name"), aliasopt(Name));
-static opt<unsigned long long> Lookup("lookup",
+static opt<uint64_t>
+ Lookup("lookup",
desc("Lookup <address> in the debug information and print out any "
"available file, function, block and line table details."),
value_desc("address"), cat(DwarfDumpCategory));
Modified: llvm/trunk/tools/llvm-lto/llvm-lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-lto/llvm-lto.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-lto/llvm-lto.cpp (original)
+++ llvm/trunk/tools/llvm-lto/llvm-lto.cpp Tue Apr 23 19:40:20 2019
@@ -157,8 +157,8 @@ static cl::opt<int>
ThinLTOCachePruningInterval("thinlto-cache-pruning-interval",
cl::init(1200), cl::desc("Set ThinLTO cache pruning interval."));
-static cl::opt<unsigned long long>
- ThinLTOCacheMaxSizeBytes("thinlto-cache-max-size-bytes",
+static cl::opt<uint64_t> ThinLTOCacheMaxSizeBytes(
+ "thinlto-cache-max-size-bytes",
cl::desc("Set ThinLTO cache pruning directory maximum size in bytes."));
static cl::opt<int>
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Tue Apr 23 19:40:20 2019
@@ -87,7 +87,7 @@ extern cl::opt<bool> Rebase;
extern cl::opt<bool> UniversalHeaders;
extern cl::opt<bool> WeakBind;
-static cl::opt<unsigned long long> AdjustVMA(
+static cl::opt<uint64_t> AdjustVMA(
"adjust-vma",
cl::desc("Increase the displayed address by the specified offset"),
cl::value_desc("offset"), cl::init(0));
@@ -271,12 +271,13 @@ static cl::alias PrintSourceShort("S", c
cl::NotHidden, cl::Grouping,
cl::aliasopt(PrintSource));
-static cl::opt<unsigned long long>
+static cl::opt<uint64_t>
StartAddress("start-address", cl::desc("Disassemble beginning at address"),
cl::value_desc("address"), cl::init(0));
-static cl::opt<unsigned long long>
- StopAddress("stop-address", cl::desc("Stop disassembly at address"),
- cl::value_desc("address"), cl::init(UINT64_MAX));
+static cl::opt<uint64_t> StopAddress("stop-address",
+ cl::desc("Stop disassembly at address"),
+ cl::value_desc("address"),
+ cl::init(UINT64_MAX));
cl::opt<bool> SymbolTable("syms", cl::desc("Display the symbol table"));
static cl::alias SymbolTableShort("t", cl::desc("Alias for --syms"),
Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original)
+++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Tue Apr 23 19:40:20 2019
@@ -91,35 +91,28 @@ CheckFiles("check",
cl::desc("File containing RuntimeDyld verifier checks."),
cl::ZeroOrMore);
-// Tracking BUG: 19665
-// http://llvm.org/bugs/show_bug.cgi?id=19665
-//
-// Do not change these options to cl::opt<uint64_t> since this silently breaks
-// argument parsing.
-static cl::opt<unsigned long long>
-PreallocMemory("preallocate",
- cl::desc("Allocate memory upfront rather than on-demand"),
- cl::init(0));
+static cl::opt<uint64_t>
+ PreallocMemory("preallocate",
+ cl::desc("Allocate memory upfront rather than on-demand"),
+ cl::init(0));
-static cl::opt<unsigned long long>
-TargetAddrStart("target-addr-start",
- cl::desc("For -verify only: start of phony target address "
- "range."),
- cl::init(4096), // Start at "page 1" - no allocating at "null".
- cl::Hidden);
+static cl::opt<uint64_t> TargetAddrStart(
+ "target-addr-start",
+ cl::desc("For -verify only: start of phony target address "
+ "range."),
+ cl::init(4096), // Start at "page 1" - no allocating at "null".
+ cl::Hidden);
-static cl::opt<unsigned long long>
-TargetAddrEnd("target-addr-end",
- cl::desc("For -verify only: end of phony target address range."),
- cl::init(~0ULL),
- cl::Hidden);
+static cl::opt<uint64_t> TargetAddrEnd(
+ "target-addr-end",
+ cl::desc("For -verify only: end of phony target address range."),
+ cl::init(~0ULL), cl::Hidden);
-static cl::opt<unsigned long long>
-TargetSectionSep("target-section-sep",
- cl::desc("For -verify only: Separation between sections in "
- "phony target address space."),
- cl::init(0),
- cl::Hidden);
+static cl::opt<uint64_t> TargetSectionSep(
+ "target-section-sep",
+ cl::desc("For -verify only: Separation between sections in "
+ "phony target address space."),
+ cl::init(0), cl::Hidden);
static cl::list<std::string>
SpecificSectionMappings("map-section",
Modified: llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp?rev=359068&r1=359067&r2=359068&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp Tue Apr 23 19:40:20 2019
@@ -134,7 +134,7 @@ static cl::opt<bool> ClVerbose("verbose"
cl::desc("Print verbose line info"));
// -adjust-vma
-static cl::opt<unsigned long long>
+static cl::opt<uint64_t>
ClAdjustVMA("adjust-vma", cl::init(0), cl::value_desc("offset"),
cl::desc("Add specified offset to object file addresses"));
More information about the llvm-commits
mailing list