[PATCH] D72271: [Clang] Handle target-specific builtins returning aggregates.
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 7 09:37:08 PST 2020
rjmccall added a comment.
In D72271#1807790 <https://reviews.llvm.org/D72271#1807790>, @simon_tatham wrote:
> The current return value of `EmitTargetBuiltinExpr` will be the `llvm::Value *` corresponding to the last of a sequence of store instructions that writes the constructed aggregate into the return value slot. There's no need to actually use that `Value` for anything in this case, but we can still test that it's non-null, to find out whether `EmitTargetBuiltinExpr` has successfully recognized a builtin and generated some code, or whether we have to fall through to the `ErrorUnsupported`.
Ah, yes, good point.
================
Comment at: clang/lib/CodeGen/CGBuiltin.cpp:4350
+ llvm_unreachable("Bad evaluation kind in EmitBuiltinExpr");
+ }
----------------
I would just structure this as:
```
// If the result is an aggregate, force ReturnValue to be non-null so that
// the target-specific emission code can always just emit into it.
TypeEvaluationKind EvalKind = getEvaluationKind(E->getType());
if (EvalKind == TEK_Aggregate && ReturnValue.isNull()) { ... }
// Try to emit a target builtin.
if (Value *V = EmitTargetBuiltinExpr(BuiltinID, E, ReturnValue)) {
// Turn the result into the appropriate kind of RValue.
switch (EvalKind) { ... }
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72271/new/
https://reviews.llvm.org/D72271
More information about the cfe-commits
mailing list