[mlir] don't drop undef initializers in translation to LLVM IR
authorAlex Zinenko <zinenko@google.com>
Thu, 8 Jul 2021 14:07:09 +0000 (16:07 +0200)
committerAlex Zinenko <zinenko@google.com>
Fri, 9 Jul 2021 15:52:43 +0000 (17:52 +0200)
commitd4df3825bd32277074b3859f5dea9593139147fb
tree5088d68ce29c950a5e54918f97fac60418e17f7b
parent42cc7f3c524a0ede6b903486c588003fe12d9293
[mlir] don't drop undef initializers in translation to LLVM IR

LLVM IR allows globals with external linkage to have initializers, including
undef. The translation was incorrectly using undef as a indicator that the
initializer should be ignored in translation, leading to the impossibility to
create an external global with an explicit undef initializer. Fix this and use
nullptr as a marker instead.

Reviewed By: wsmoses

Differential Revision: https://reviews.llvm.org/D105631
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Target/LLVMIR/llvmir.mlir