diff --git a/llvm/include/llvm/MC/MCDwarf.h b/llvm/include/llvm/MC/MCDwarf.h index 5052c6756c32bd..18056c5fdf816a 100644 --- a/llvm/include/llvm/MC/MCDwarf.h +++ b/llvm/include/llvm/MC/MCDwarf.h @@ -483,7 +483,7 @@ class MCGenDwarfLabelEntry { class MCCFIInstruction { public: - enum OpType : uint8_t { + enum OpType { OpSameValue, OpRememberState, OpRestoreState, @@ -504,44 +504,35 @@ class MCCFIInstruction { }; private: + OpType Operation; MCSymbol *Label; + unsigned Register; union { - struct { - unsigned Register; - int Offset; - } RI; - struct { - unsigned Register; - int Offset; - unsigned AddressSpace; - } RIA; - struct { - unsigned Register; - unsigned Register2; - } RR; - } U; - OpType Operation; + int Offset; + unsigned Register2; + }; + unsigned AddressSpace = ~0u; SMLoc Loc; std::vector Values; std::string Comment; MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, SMLoc Loc, StringRef V = "", StringRef Comment = "") - : Label(L), Operation(Op), Loc(Loc), Values(V.begin(), V.end()), - Comment(Comment) { + : Operation(Op), Label(L), Register(R), Offset(O), Loc(Loc), + Values(V.begin(), V.end()), Comment(Comment) { assert(Op != OpRegister && Op != OpLLVMDefAspaceCfa); - U.RI = {R, O}; } + MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R1, unsigned R2, SMLoc Loc) - : Label(L), Operation(Op), Loc(Loc) { + : Operation(Op), Label(L), Register(R1), Register2(R2), Loc(Loc) { assert(Op == OpRegister); - U.RR = {R1, R2}; } + MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, unsigned AS, SMLoc Loc) - : Label(L), Operation(Op), Loc(Loc) { + : Operation(Op), Label(L), Register(R), Offset(O), AddressSpace(AS), + Loc(Loc) { assert(Op == OpLLVMDefAspaceCfa); - U.RIA = {R, O, AS}; } public: @@ -668,34 +659,30 @@ class MCCFIInstruction { MCSymbol *getLabel() const { return Label; } unsigned getRegister() const { - if (Operation == OpRegister) - return U.RR.Register; - if (Operation == OpLLVMDefAspaceCfa) - return U.RIA.Register; assert(Operation == OpDefCfa || Operation == OpOffset || Operation == OpRestore || Operation == OpUndefined || Operation == OpSameValue || Operation == OpDefCfaRegister || - Operation == OpRelOffset); - return U.RI.Register; + Operation == OpRelOffset || Operation == OpRegister || + Operation == OpLLVMDefAspaceCfa); + return Register; } unsigned getRegister2() const { assert(Operation == OpRegister); - return U.RR.Register2; + return Register2; } unsigned getAddressSpace() const { assert(Operation == OpLLVMDefAspaceCfa); - return U.RIA.AddressSpace; + return AddressSpace; } int getOffset() const { - if (Operation == OpLLVMDefAspaceCfa) - return U.RIA.Offset; assert(Operation == OpDefCfa || Operation == OpOffset || Operation == OpRelOffset || Operation == OpDefCfaOffset || - Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize); - return U.RI.Offset; + Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize || + Operation == OpLLVMDefAspaceCfa); + return Offset; } StringRef getValues() const {