This is an archive of the discontinued LLVM Phabricator instance.

[IRParser] Pass a const Module& reference to the DataLayout callback
AbandonedPublic

Authored by arichardson on Jan 5 2023, 7:25 AM.

Details

Summary

This allows the "override DataLayout" callback to read both the
DataLayout and TargetTriple that was defined in the IR module when
inferring the default (for example we might not want to override the
existing value if it's non-empty).
We could also add an additional argument instead, but I feel that
passing a const reference to the Module is simpler and more extensible.

Diff Detail

Event Timeline

arichardson created this revision.Jan 5 2023, 7:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2023, 7:25 AM

@mehdi_amini In D78403 you were against passing a Module* callback, is a read-only const Module& okay or should I pass DataLayout + triple instead? I prefer the former, but if there are strong objections I'm happy to change it to the latter. Passing a read-only module should make it easier to extend in the future if needed.

arichardson published this revision for review.Jan 6 2023, 5:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 6 2023, 5:11 AM

In general I'm in favor of narrow API: that is pass what you need and not more. That makes it for cleaner API contracts which are easier to understand and/or maintain.

arichardson abandoned this revision.Jan 13 2023, 3:42 AM

Looks like this is obsolete now that D140985 landed, will rebase the remaining patch stack.