[PATCH] D130856: [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.
Xiang Li via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 1 16:57:52 PDT 2022
python3kgae updated this revision to Diff 449157.
python3kgae added a comment.
Keep createDXILEmbedderPass in addPassesToEmitFile.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130856/new/
https://reviews.llvm.org/D130856
Files:
llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp
llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
Index: llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
===================================================================
--- llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
+++ llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
@@ -67,6 +67,11 @@
}
FunctionPass *createTargetRegisterAllocator(bool) override { return nullptr; }
+ void addCodeGenPrepare() override {
+ addPass(createDXILOpLoweringLegacyPass());
+ addPass(createDXILPrepareModulePass());
+ addPass(createDXILTranslateMetadataPass());
+ }
};
DirectXTargetMachine::DirectXTargetMachine(const Target &T, const Triple &TT,
@@ -91,9 +96,9 @@
PassManagerBase &PM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut,
CodeGenFileType FileType, bool DisableVerify,
MachineModuleInfoWrapperPass *MMIWP) {
- PM.add(createDXILOpLoweringLegacyPass());
- PM.add(createDXILPrepareModulePass());
- PM.add(createDXILTranslateMetadataPass());
+ TargetPassConfig *PassConfig = createPassConfig(PM);
+ PassConfig->addCodeGenPrepare();
+
if (TargetPassConfig::willCompleteCodeGenPipeline()) {
PM.add(createDXILEmbedderPass());
}
Index: llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp
+++ llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp
@@ -46,6 +46,8 @@
// Skip the LLVM metadata
if (GV->getSection() == "llvm.metadata")
return;
+ if (!GV->hasSection())
+ return;
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
MCSection *TheSection = getObjFileLowering().SectionForGlobal(GV, GVKind, TM);
OutStreamer->switchSection(TheSection);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130856.449157.patch
Type: text/x-patch
Size: 1693 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220801/6a1a9392/attachment.bin>
More information about the llvm-commits
mailing list