This is an archive of the discontinued LLVM Phabricator instance.

[mlir][llvm] Iterative constant import from LLVM IR.

Authored by gysit on Nov 7 2022, 8:45 AM.



Instead of importing constant expressions recursively, the revision
walks all dependencies of an LLVM constant iteratively. The actual
conversion then iterates over a list of constants and all intermediate
constant values are added to the value mapping. As a result, an LLVM IR
constant maps to exactly one MLIR operation per function. The revision
adapts the existing tests since the constant ordering changed for
aggregate types. Additionally, it adds extra tests that mix aggregate
constants and constant expressions.

Depends on D137416

Diff Detail

Event Timeline

gysit created this revision.Nov 7 2022, 8:45 AM
Herald added a project: Restricted Project. · View Herald Transcript
gysit requested review of this revision.Nov 7 2022, 8:45 AM
gysit updated this revision to Diff 476073.Nov 17 2022, 3:21 AM


ftynse accepted this revision.Nov 18 2022, 4:09 AM
ftynse added inline comments.

Nit: is there a way to reserve before pushing back in the loop?


Not for this commit, but we should probably handle this more gracefully.

This revision is now accepted and ready to land.Nov 18 2022, 4:09 AM
gysit updated this revision to Diff 476441.Nov 18 2022, 5:40 AM
gysit marked an inline comment as done.

Address comment.


I have put it on my TODO list! Indeed a return value based error handling would be nicer.

This revision was automatically updated to reflect the committed changes.