[llvm] [SandboxIR] Added isVolatile args to existing LoadInst::create function (PR #100850)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 27 21:17:13 PDT 2024
================
@@ -764,11 +764,21 @@ define void @foo(ptr %arg0, ptr %arg1) {
// Check create(InsertBefore)
sandboxir::LoadInst *NewLd =
sandboxir::LoadInst::create(Ld->getType(), Arg1, Align(8),
- /*InsertBefore=*/Ret, Ctx, "NewLd");
+ /*InsertBefore=*/Ret, Ctx,
+ /*IsVolatile=*/false, "NewLd");
----------------
vporpo wrote:
This is OK for this PR, but having to specify the `IsVolatile` argument whenever you create non-volatile LoadInsts looks a bit too verbose. The problem is that most of the times you will be creating an instruction with a name, so you can't take advantage of the default value f the `IsVolatile=false` argument. And swapping `IsVolatile` with `Name` isn't what most users will expect.
If you have time, try creating a follow-up PR with two additional create() functions that don't have the `IsVolatile` argument and remove the default `=false` value for these ones. So the functions would be:
```
1. create(Type *Ty, Value *Ptr, MaybeAlign Align, Instruction *InsertBefore, Context &Ctx, bool IsVolatile, const Twine &Name = "")
2. create(Type *Ty, Value *Ptr, MaybeAlign Align, Instruction *InsertBefore, Context &Ctx, const Twine &Name = "")
3. create(Type *Ty, Value *Ptr, MaybeAlign Align, BasicBlock *InsertAtEnd, Context &Ctx, bool IsVolatile, const Twine &Name = "")
4. create(Type *Ty, Value *Ptr, MaybeAlign Align, BasicBlock *InsertAtEnd, Context &Ctx, const Twine &Name = "")
```
Then in the body of 2 you would just call 1 with `/*IsVolatile=*/false`, and similarly in the body of 4 you would call 3.
https://github.com/llvm/llvm-project/pull/100850
More information about the llvm-commits
mailing list