This is an archive of the discontinued LLVM Phabricator instance.

[fir] Add !fir.char type conversion
ClosedPublic

Authored by rovka on Nov 10 2021, 4:15 AM.

Details

Summary

This patch is part of the upstreaming effort from fir-dev.

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>

Diff Detail

Event Timeline

rovka created this revision.Nov 10 2021, 4:15 AM
rovka requested review of this revision.Nov 10 2021, 4:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2021, 4:15 AM
clementval accepted this revision.Nov 10 2021, 4:18 AM

LGTM. Thanks

This revision is now accepted and ready to land.Nov 10 2021, 4:18 AM
clementval added inline comments.Nov 10 2021, 4:19 AM
flang/test/Fir/types-to-llvm.fir
66

Nit: add a blank line after the comment like other tests.

This revision was automatically updated to reflect the committed changes.
awarzynski added inline comments.Nov 10 2021, 4:29 AM
flang/lib/Optimizer/CodeGen/TypeConverter.h
159

[nit] Shouldn't this be:

  • !fir.char<n, 12> --> !llvm.array<12 x ix*>
  • !fir.char<n, ?> --> ix*

instead?

rovka added inline comments.Nov 10 2021, 4:40 AM
flang/lib/Optimizer/CodeGen/TypeConverter.h
159

Actually, now that you mention it, I'm noticing we're doing !fir.char<n, ?> -> ix, not ix*. Are we supposed to return LLVMPointerType::get(iTy) instead?

awarzynski added inline comments.Nov 10 2021, 4:57 AM
flang/lib/Optimizer/CodeGen/TypeConverter.h
159

Are we supposed to return LLVMPointerType::get(iTy) instead?

I don't know the answer to this question, but making the comment consistent with the implementation (and the tests) will make any potential debugging easier :-)

rovka added a comment.Nov 10 2021, 5:11 AM

Fixed with commit 81c99c5404c1

So, to answer my own question, stuff in fir-dev seems to know when it needs to add a pointer, and I think a "plain" !fir.char is never expected as a function parameter. I'm not sure if there's a less misleading way to write a test for this.