diff --git a/llvm/include/llvm/MC/MCLinkerOptimizationHint.h b/llvm/include/llvm/MC/MCLinkerOptimizationHint.h index 50fd527ffe2a..1f91b0de3647 100644 --- a/llvm/include/llvm/MC/MCLinkerOptimizationHint.h +++ b/llvm/include/llvm/MC/MCLinkerOptimizationHint.h @@ -45,7 +45,7 @@ static inline StringRef MCLOHDirectiveName() { return StringRef(".loh"); } -static inline bool isValidMCLOHType(MCLOHType Kind) { +static inline bool isValidMCLOHType(unsigned Kind) { return Kind >= MCLOH_AdrpAdrp && Kind <= MCLOH_AdrpLdrGot; } diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 057a50275724..c4f5449d8694 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -3985,10 +3985,9 @@ bool AArch64AsmParser::parseDirectiveLOH(StringRef IDVal, SMLoc Loc) { // We successfully get a numeric value for the identifier. // Check if it is valid. int64_t Id = getParser().getTok().getIntVal(); - Kind = (MCLOHType)Id; - // Check that Id does not overflow MCLOHType. - if (!isValidMCLOHType(Kind) || Id != Kind) + if (Id <= -1U && !isValidMCLOHType(Id)) return TokError("invalid numeric identifier in directive"); + Kind = (MCLOHType)Id; } else { StringRef Name = getTok().getIdentifier(); // We successfully parse an identifier.