This is an archive of the discontinued LLVM Phabricator instance.

[mlir] disallow side-effecting ops in llvm.mlir.global
ClosedPublic

Authored by ftynse on Feb 27 2022, 9:57 AM.

Details

Summary

The llvm.mlir.global operation accepts a region as initializer. This region
corresponds to an LLVM IR constant expression and therefore should not accept
operations with side effects. Add a corresponding verifier.

Diff Detail

Event Timeline

ftynse created this revision.Feb 27 2022, 9:57 AM
ftynse requested review of this revision.Feb 27 2022, 9:57 AM
wsmoses accepted this revision.Feb 27 2022, 12:07 PM
This revision is now accepted and ready to land.Feb 27 2022, 12:07 PM

corresponds to an LLVM IR complex expression

Did you mean a "constant expression"?

bondhugula accepted this revision.Feb 27 2022, 6:49 PM
bondhugula added a subscriber: bondhugula.

LGTM. Two minor comments besides the typo in the commit summary Mehdi caught.

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
1805

expressions -> initializers?

1805

Print op as well?

-> "op with side-effect found in global initializer:\n" << op

ftynse edited the summary of this revision. (Show Details)Mar 1 2022, 5:10 AM
ftynse marked an inline comment as done.Mar 1 2022, 5:13 AM
ftynse added inline comments.
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
1805

Current op is automatically printed as a note, in addition to the caret pointer.

This revision was landed with ongoing or failed builds.Mar 1 2022, 5:16 AM
This revision was automatically updated to reflect the committed changes.