[mlir] fix dereferencing of optional sym_name attribute
authorAshay Rane <ashay@users.noreply.github.com>
Tue, 17 Jan 2023 18:55:02 +0000 (10:55 -0800)
committerStella Stamenova <stilis@microsoft.com>
Tue, 17 Jan 2023 18:56:06 +0000 (10:56 -0800)
commitd23516e9ad477527a9db4d06b1fa9566680ac67c
treea989431b84692e64ec7b8df9f35a63865622f567
parenteec516a0954a5a91490ac4b6e86196e9813d9185
[mlir] fix dereferencing of optional sym_name attribute

`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.

Reviewed By: stella.stamenova

Differential Revision: https://reviews.llvm.org/D141941
mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
mlir/test/Conversion/SPIRVToLLVM/lower-host-to-llvm-calls.mlir