[NFC][DirectX backend] Fix crash when emit_obj for DirectX backend.
authorXiang Li <python3kgae@outlook.com>
Sun, 31 Jul 2022 21:15:28 +0000 (14:15 -0700)
committerXiang Li <python3kgae@outlook.com>
Tue, 2 Aug 2022 19:09:07 +0000 (12:09 -0700)
commit20f7f9b709dfb1dafd6827c9708928ecac547d87
treed21e225be94b737c302d676e9d1d96e53a0e21df
parenta1a30dc933b928a7a8277d5b5f7bd25670e68884
[NFC][DirectX backend] Fix crash when emit_obj for DirectX backend.

When emit-obj from clang directly, DirectX backend will hit assert caused by not initialize passes for AsmPrinter.
The fix will initialize the passes by calling createPassConfig.
Also ignore global variable which not has section in DXILAsmPrinter::emitGlobalVariable to avoid hit llvm_unreachable in DXILTargetObjectFile::SelectSectionForGlobal.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D130856
llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp
llvm/lib/Target/DirectX/DirectXTargetMachine.cpp