From d9bbe85943f6322e8fa1e85f72e53dd579c14a2f Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Mon, 27 Jul 2020 08:16:28 +0000 Subject: [Alignment][NFC] Update Bitcodewriter to use Align Differential Revision: https://reviews.llvm.org/D83533 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 9632b57..908e70b2 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -20,8 +20,9 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/ADT/Twine.h" -#include "llvm/Bitstream/BitstreamReader.h" #include "llvm/Bitcode/LLVMBitCodes.h" +#include "llvm/Bitstream/BitcodeCommon.h" +#include "llvm/Bitstream/BitstreamReader.h" #include "llvm/Config/llvm-config.h" #include "llvm/IR/Argument.h" #include "llvm/IR/Attributes.h" @@ -4813,17 +4814,13 @@ Error BitcodeReader::parseFunctionBody(Function *F) { case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align] if (Record.size() != 4) return error("Invalid record"); - uint64_t AlignRecord = Record[3]; - const uint64_t InAllocaMask = uint64_t(1) << 5; - const uint64_t ExplicitTypeMask = uint64_t(1) << 6; - const uint64_t SwiftErrorMask = uint64_t(1) << 7; - const uint64_t FlagMask = InAllocaMask | ExplicitTypeMask | - SwiftErrorMask; - bool InAlloca = AlignRecord & InAllocaMask; - bool SwiftError = AlignRecord & SwiftErrorMask; + using APV = AllocaPackedValues; + const uint64_t Rec = Record[3]; + const bool InAlloca = Bitfield::get(Rec); + const bool SwiftError = Bitfield::get(Rec); FullTy = getFullyStructuredTypeByID(Record[0]); Type *Ty = flattenPointerTypes(FullTy); - if ((AlignRecord & ExplicitTypeMask) == 0) { + if (!Bitfield::get(Rec)) { auto *PTy = dyn_cast_or_null(Ty); if (!PTy) return error("Old-style alloca with a non-pointer type"); @@ -4832,7 +4829,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) { Type *OpTy = getTypeByID(Record[1]); Value *Size = getFnValueByID(Record[2], OpTy); MaybeAlign Align; - if (Error Err = parseAlignmentValue(AlignRecord & ~FlagMask, Align)) { + if (Error Err = + parseAlignmentValue(Bitfield::get(Rec), Align)) { return Err; } if (!Ty || !Size) -- cgit v1.1