[llvm] [SandboxIR][NFC] Fixes for LoadInst::create functions (PR #100955)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 08:28:00 PDT 2024
================
@@ -774,13 +773,27 @@ define void @foo(ptr %arg0, ptr %arg1) {
EXPECT_EQ(NewLd->getName(), "NewLd");
sandboxir::LoadInst *NewVLd =
- sandboxir::LoadInst::create(Vld->getType(), Arg1, Align(8),
- /*InsertBefore=*/Ret, Ctx,
- /*IsVolatile=*/true, "NewVLd");
+ sandboxir::LoadInst::create(VLd->getType(), Arg1, Align(8),
+ /*InsertBefore=*/Ret,
+ /*IsVolatile=*/true, Ctx, "NewVLd");
// Checking if create() was volatile
EXPECT_TRUE(NewVLd->isVolatile());
EXPECT_EQ(NewVLd->getName(), "NewVLd");
+
+ // Check create(InsertAtEnd)
+ sandboxir::LoadInst *NewLdEnd =
+ sandboxir::LoadInst::create(Ld->getType(), Arg1, Align(8),
+ /*InsertAtEnd=*/BB, Ctx, "NewLdEnd");
+ EXPECT_FALSE(NewLdEnd->isVolatile());
+ EXPECT_EQ(NewLdEnd->getName(), "NewLdEnd");
----------------
vporpo wrote:
We should probably check the same things across all create() functions, because although the implementation is currently the same, there is no guarantee that this will still be the case in the future.
```
EXPECT_EQ(NewLdEnd->getType(), Ld->getType());
EXPECT_EQ(NewLdEnd->getPointerOperand(), Arg1);
EXPECT_EQ(NewLdEnd->getAlign(), 8);
```
And even though we didn't check this above, we should check the instruction position with:
```
EXPECT_EQ(NewLdEnd->getParent(), BB);
EXPECT_EQ(NewLdEnd->getNextNode(), nullptr);
```
https://github.com/llvm/llvm-project/pull/100955
More information about the llvm-commits
mailing list