[llvm] [llvm][NFC] Assert VAArg type (PR #67148)
Nathan Sidwell via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 22 07:30:24 PDT 2023
https://github.com/urnathan created https://github.com/llvm/llvm-project/pull/67148
Due to the way we have a backend arranged, we fell over a varadic struct bug, and noticed the generic machinery presumes all by-val structs are by hidden pointer. The documentation even warns:
'Note that the code generator does not yet fully support va\_arg on many targets. Also, it does not currently support va\_arg with aggregate types on any target.'
While this assert would not have triggered in our case, it was surprising to not see a check. So here's one. Of course it doesn't trigger :)
>From f28424e11c58b564acebadb694d8a804435be437 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan at acm.org>
Date: Fri, 22 Sep 2023 10:22:57 -0400
Subject: [PATCH] [llvm][NFC] Assert VAArg type
Assert that VAArg is not given a structure or array type, for those
absolutely won't work (as documented in LangRef.rst).
---
llvm/include/llvm/IR/Instructions.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index a0c8406fe4ec1e5..cfe90ecdef3fd5a 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -1796,12 +1796,16 @@ class VAArgInst : public UnaryInstruction {
VAArgInst(Value *List, Type *Ty, const Twine &NameStr = "",
Instruction *InsertBefore = nullptr)
: UnaryInstruction(Ty, VAArg, List, InsertBefore) {
+ assert(!Ty->isStructTy() && !Ty->isArrayTy() &&
+ "by-val structures and arrays unsupported");
setName(NameStr);
}
VAArgInst(Value *List, Type *Ty, const Twine &NameStr,
BasicBlock *InsertAtEnd)
: UnaryInstruction(Ty, VAArg, List, InsertAtEnd) {
+ assert(!Ty->isStructTy() && !Ty->isArrayTy() &&
+ "by-val structures and arrays unsupported");
setName(NameStr);
}
More information about the llvm-commits
mailing list