This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Make it possible to directly supply constant values to LLVM GEPOp
ClosedPublic

Authored by ftynse on Jan 6 2022, 10:25 AM.

Details

Summary

In LLVM IR, the GEP indices that correspond to structures are required to be
i32 constants. MLIR models constants as just values defined by special
operations, and there is no verification that it is the case for structure
indices in GEP. Furthermore, some common transformations such as control flow
simplification may lead to the operands becoming non-constant. Make it possible
to directly supply constant values to LLVM GEPOp to guarantee they remain
constant until the translation to LLVM IR. This is not yet a requirement and
the verifier is not modified, this will be introduced separately.

Diff Detail

Event Timeline

ftynse created this revision.Jan 6 2022, 10:25 AM
ftynse requested review of this revision.Jan 6 2022, 10:25 AM
wsmoses added inline comments.Jan 6 2022, 10:37 AM
mlir/test/Target/LLVMIR/llvmir.mlir
982

Can you add a test where the constant's aren't always at the end. E.g. struct { [10 x i64], [10 x f32] } can have a gep of constant 0, nonconstant %i

ftynse updated this revision to Diff 397991.Jan 6 2022, 2:29 PM
ftynse marked an inline comment as done.

Add a test requested in review.

wsmoses accepted this revision.Jan 6 2022, 4:30 PM
This revision is now accepted and ready to land.Jan 6 2022, 4:30 PM
This revision was landed with ongoing or failed builds.Jan 7 2022, 12:56 AM
This revision was automatically updated to reflect the committed changes.