[llvm] [SandboxIR] More boilerplate: Function, Argument, Constant, Instruction, OpaqueInst (PR #97343)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 17:06:21 PDT 2024
================
@@ -40,3 +40,22 @@ define void @foo(i32 %v1) {
sandboxir::Context Ctx(C);
[[maybe_unused]] sandboxir::User U(sandboxir::Value::ClassID::User, Ret, Ctx);
}
+
+TEST_F(SandboxIRTest, FunctionArgumentConstantAndOpaqueInstInstantiation) {
+ parseIR(C, R"IR(
+define void @foo(i32 %v1) {
+ %add = add i32 %v1, 42
+ ret void
+}
+)IR");
+ llvm::Function *LLVMF = &*M->getFunction("foo");
+ llvm::BasicBlock *LLVMBB = &*LLVMF->begin();
+ llvm::Instruction *LLVMAdd = &*LLVMBB->begin();
+ auto *LLVMC = cast<llvm::Constant>(LLVMAdd->getOperand(1));
+ sandboxir::Context Ctx(C);
+ auto *LLVMArg0 = LLVMF->getArg(0);
+ [[maybe_unused]] sandboxir::Function F(LLVMF, Ctx);
----------------
aeubanks wrote:
can you add some checks like `isa<Instruction/User>()`?
https://github.com/llvm/llvm-project/pull/97343
More information about the llvm-commits
mailing list