This is an archive of the discontinued LLVM Phabricator instance.

[mlir] fix dereferencing of optional sym_name attribute
ClosedPublic

Authored by ashay-github on Jan 17 2023, 8:11 AM.

Details

Summary

sym_name is an optional attribute of ModuleOp, so it is unsafe to
fetch the underlying value without checking whether it is non-empty.
Such unsafe dereferencing causes the lower-host-to-llvm-calls_fail.mlir
test to segfault. Although this bug existed for four months, it wasn't
triggered, since previous tests executed a code path that used a default
value instead of one fetched from the module attribute.

This patch makes the code use a default value if the optional attribute
does not have a value.

Diff Detail

Event Timeline

ashay-github created this revision.Jan 17 2023, 8:11 AM
Herald added a project: Restricted Project. · View Herald Transcript
ashay-github requested review of this revision.Jan 17 2023, 8:11 AM
ashay-github edited the summary of this revision. (Show Details)Jan 17 2023, 8:16 AM

Can you add a test for this please?

Added unit tests to check that lowering using either the specified or the
default attribute value.

This revision is now accepted and ready to land.Jan 17 2023, 10:51 AM