HomePhabricator

[clang codegen] Clean up handling of vectors with trivial-auto-var-init.

Authored by efriedma on Mar 20 2020, 2:18 PM.

Description

[clang codegen] Clean up handling of vectors with trivial-auto-var-init.

The code was pretending to be doing something useful with vectors, but
really it was doing nothing: the element type of a vector is always a
scalar type, so constWithPadding would always just return the input constant.

Split off from D75661 so it can be reviewed separately.

While I'm here, also add testcase to show missing vector handling.

Differential Revision: https://reviews.llvm.org/D76528

Details

Event Timeline

ctetreau added inline comments.
/clang/lib/CodeGen/CGDecl.cpp
1049

Since the original function appeared to do something with vectors, it might be good to put a comment in here addressing the fact that it is not handled. Perhaps:

// Vector types always have scalar elements, therefore we can return the input vector with no further processing
1078

In my opinion, a lot of comments of this sort are just noise. Do you have reason to believe that the answer is yes? If so, you should state it here. If not, you should not add the comment.

Nitpicks aside, this looks reasonable to me. I'll defer to a domain expert for final approval.

efriedma marked an inline comment as done.Mar 25 2020, 10:51 AM
efriedma added inline comments.
/clang/lib/CodeGen/CGDecl.cpp
1078

I'm pretty sure the answer is yes; I'll fix the comment to address both your questions.