[clang] [CIR] Function type return type improvements (PR #128787)
David Olsen via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 26 15:07:17 PST 2025
================
@@ -424,6 +424,10 @@ LogicalResult cir::FuncOp::verifyType() {
if (!isa<cir::FuncType>(type))
return emitOpError("requires '" + getFunctionTypeAttrName().str() +
"' attribute of function type");
+ if (auto rt = type.getReturnTypes();
----------------
dkolsen-pgi wrote:
> `getFunctionType` already gives us a `cir::FuncType`, so an `isa` will always be true, correct?
Correct. I just noticed that myself, as I was looking at this function more closely.
In the incubator, this function has three checks. The first is a tautology, because it is checking if a `cir::FuncType` `isa` `cir::FuncType`. The second, which I had not upstreamed yet, is wrong. It checks that an ellipsis is not the only parameter, but functions with only an ellipsis are allowed in C++. The third check, the one added in this PR, that there isn't an explicit `void` return type, is redundant, because that is already checked in `FuncType::verify`.
It doesn't look like `FuncOp::verifyType` is called from anywhere (even in the incubator), and it doesn't do anything useful. So rather than adding a check for `rt.size() < 2` to the function, I will look into getting rid of it entirely.
https://github.com/llvm/llvm-project/pull/128787
More information about the cfe-commits
mailing list