@@ -810,6 +810,7 @@ TEST_F(SandboxIRTest, StoreInst) {
810810 parseIR (C, R"IR(
811811define void @foo(i8 %val, ptr %ptr) {
812812 store i8 %val, ptr %ptr, align 64
813+ store volatile i8 %val, ptr %ptr, align 64
813814 ret void
814815}
815816)IR" );
@@ -821,9 +822,12 @@ define void @foo(i8 %val, ptr %ptr) {
821822 auto *BB = &*F->begin ();
822823 auto It = BB->begin ();
823824 auto *St = cast<sandboxir::StoreInst>(&*It++);
825+ auto *VSt = cast<sandboxir::StoreInst>(&*It++);
824826 auto *Ret = cast<sandboxir::ReturnInst>(&*It++);
825827
826828 // Check that the StoreInst has been created correctly.
829+ EXPECT_FALSE (St->isVolatile ());
830+ EXPECT_TRUE (VSt->isVolatile ());
827831 // Check getPointerOperand()
828832 EXPECT_EQ (St->getValueOperand (), Val);
829833 EXPECT_EQ (St->getPointerOperand (), Ptr);
@@ -833,10 +837,46 @@ define void @foo(i8 %val, ptr %ptr) {
833837 sandboxir::StoreInst *NewSt =
834838 sandboxir::StoreInst::create (Val, Ptr, Align (8 ),
835839 /* InsertBefore=*/ Ret, Ctx);
840+ EXPECT_FALSE (NewSt->isVolatile ());
836841 EXPECT_EQ (NewSt->getType (), St->getType ());
837842 EXPECT_EQ (NewSt->getValueOperand (), Val);
838843 EXPECT_EQ (NewSt->getPointerOperand (), Ptr);
839844 EXPECT_EQ (NewSt->getAlign (), 8 );
845+ EXPECT_EQ (NewSt->getNextNode (), Ret);
846+ // Check create(InsertBefore, IsVolatile=true)
847+ sandboxir::StoreInst *NewVSt =
848+ sandboxir::StoreInst::create (Val, Ptr, Align (8 ),
849+ /* InsertBefore=*/ Ret,
850+ /* IsVolatile=*/ true , Ctx);
851+ EXPECT_TRUE (NewVSt->isVolatile ());
852+ EXPECT_EQ (NewVSt->getType (), VSt->getType ());
853+ EXPECT_EQ (NewVSt->getValueOperand (), Val);
854+ EXPECT_EQ (NewVSt->getPointerOperand (), Ptr);
855+ EXPECT_EQ (NewVSt->getAlign (), 8 );
856+ EXPECT_EQ (NewVSt->getNextNode (), Ret);
857+ // Check create(InsertAtEnd)
858+ sandboxir::StoreInst *NewStEnd =
859+ sandboxir::StoreInst::create (Val, Ptr, Align (8 ),
860+ /* InsertAtEnd=*/ BB, Ctx);
861+ EXPECT_FALSE (NewStEnd->isVolatile ());
862+ EXPECT_EQ (NewStEnd->getType (), St->getType ());
863+ EXPECT_EQ (NewStEnd->getValueOperand (), Val);
864+ EXPECT_EQ (NewStEnd->getPointerOperand (), Ptr);
865+ EXPECT_EQ (NewStEnd->getAlign (), 8 );
866+ EXPECT_EQ (NewStEnd->getParent (), BB);
867+ EXPECT_EQ (NewStEnd->getNextNode (), nullptr );
868+ // Check create(InsertAtEnd, IsVolatile=true)
869+ sandboxir::StoreInst *NewVStEnd =
870+ sandboxir::StoreInst::create (Val, Ptr, Align (8 ),
871+ /* InsertAtEnd=*/ BB,
872+ /* IsVolatile=*/ true , Ctx);
873+ EXPECT_TRUE (NewVStEnd->isVolatile ());
874+ EXPECT_EQ (NewVStEnd->getType (), VSt->getType ());
875+ EXPECT_EQ (NewVStEnd->getValueOperand (), Val);
876+ EXPECT_EQ (NewVStEnd->getPointerOperand (), Ptr);
877+ EXPECT_EQ (NewVStEnd->getAlign (), 8 );
878+ EXPECT_EQ (NewVStEnd->getParent (), BB);
879+ EXPECT_EQ (NewVStEnd->getNextNode (), nullptr );
840880}
841881
842882TEST_F (SandboxIRTest, ReturnInst) {
0 commit comments