This is an archive of the discontinued LLVM Phabricator instance.

[llvm] support graceful failure of DataLayout parsing
ClosedPublic

Authored by ftynse on Aug 10 2020, 7:04 AM.

Details

Summary

Existing implementation always aborts on syntax errors in a DataLayout
description. While this is meaningful for consuming textual IR modules, it is
inconvenient for users that may need fine-grained control over the layout from,
e.g., command-line options. Propagate errors through the parsing functions and
only abort in the top-level parsing function instead.

Diff Detail

Event Timeline

ftynse created this revision.Aug 10 2020, 7:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2020, 7:04 AM
ftynse updated this revision to Diff 284804.Aug 11 2020, 10:00 AM

Use the naming scheme consistent with (most of) the file. Some funcitons use
the same naming scheme for their attributes as the functions they relate to in
order to minimize renaming changes in this patch.

mehdi_amini accepted this revision.Aug 15 2020, 5:18 PM
mehdi_amini added inline comments.
llvm/include/llvm/IR/DataLayout.h
189

Is this a good idea to keep a duplication of every API that can fail? Couldn't we just offer the "safe" one returning an error?

This revision is now accepted and ready to land.Aug 15 2020, 5:18 PM
ftynse updated this revision to Diff 285962.Aug 17 2020, 4:35 AM

Remove duplication between trySet* and set*, only keep the set* API that now
returns Error on failure instead of asserting. I haven't realized these were
private methods so there were no users in the wild that could be depending on
the current API or behavior.

This revision was landed with ongoing or failed builds.Aug 17 2020, 6:10 AM
This revision was automatically updated to reflect the committed changes.