From fdd0815eacb45491ac0f4dccdccc46b498d6fbe1 Mon Sep 17 00:00:00 2001 From: Amy Huang Date: Thu, 31 Oct 2019 10:48:52 -0700 Subject: [PATCH] Fix initialization-order-fiasco error in "Add a heap alloc site marker field to the ExtraInfo in MachineInstrs" --- llvm/unittests/CodeGen/MachineInstrTest.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/llvm/unittests/CodeGen/MachineInstrTest.cpp b/llvm/unittests/CodeGen/MachineInstrTest.cpp index 9e45554..90c8a40 100644 --- a/llvm/unittests/CodeGen/MachineInstrTest.cpp +++ b/llvm/unittests/CodeGen/MachineInstrTest.cpp @@ -139,11 +139,9 @@ private: BogusSubtarget ST; }; -static MCAsmInfo AsmInfo = MCAsmInfo(); - -std::unique_ptr createMCContext() { +std::unique_ptr createMCContext(MCAsmInfo *AsmInfo) { return std::make_unique( - &AsmInfo, nullptr, nullptr, nullptr, nullptr, false); + AsmInfo, nullptr, nullptr, nullptr, nullptr, false); } std::unique_ptr createTargetMachine() { @@ -378,7 +376,8 @@ TEST(MachineInstrExtraInfo, AddExtraInfo) { 0, nullptr, nullptr, nullptr, 0, nullptr}; auto MI = MF->CreateMachineInstr(MCID, DebugLoc()); - auto MC = createMCContext(); + auto MAI = MCAsmInfo(); + auto MC = createMCContext(&MAI); auto MMO = MF->getMachineMemOperand(MachinePointerInfo(), MachineMemOperand::MOLoad, 8, 8); SmallVector MMOs; @@ -424,7 +423,8 @@ TEST(MachineInstrExtraInfo, ChangeExtraInfo) { 0, nullptr, nullptr, nullptr, 0, nullptr}; auto MI = MF->CreateMachineInstr(MCID, DebugLoc()); - auto MC = createMCContext(); + auto MAI = MCAsmInfo(); + auto MC = createMCContext(&MAI); auto MMO = MF->getMachineMemOperand(MachinePointerInfo(), MachineMemOperand::MOLoad, 8, 8); SmallVector MMOs; @@ -460,7 +460,8 @@ TEST(MachineInstrExtraInfo, RemoveExtraInfo) { 0, nullptr, nullptr, nullptr, 0, nullptr}; auto MI = MF->CreateMachineInstr(MCID, DebugLoc()); - auto MC = createMCContext(); + auto MAI = MCAsmInfo(); + auto MC = createMCContext(&MAI); auto MMO = MF->getMachineMemOperand(MachinePointerInfo(), MachineMemOperand::MOLoad, 8, 8); SmallVector MMOs; -- 2.7.4