[llvm] 95176b8 - AArch64: Register null MCTargetStreamer
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 31 20:08:17 PDT 2022
Author: Matt Arsenault
Date: 2022-10-31T18:31:46-07:00
New Revision: 95176b890052206991a4b33756d165b142d4664e
URL: https://github.com/llvm/llvm-project/commit/95176b890052206991a4b33756d165b142d4664e
DIFF: https://github.com/llvm/llvm-project/commit/95176b890052206991a4b33756d165b142d4664e.diff
LOG: AArch64: Register null MCTargetStreamer
Fixes crashes with clang -emit-codegen-only
Added:
llvm/test/CodeGen/AArch64/null-mctargetstreamer.ll
Modified:
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 3c50020dd1da2..b6d76c8d3a9fb 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -248,9 +248,9 @@ void AArch64AsmPrinter::emitStartOfAsmFile(Module &M) {
return;
// Emit a .note.gnu.property section with the flags.
- if (auto *TS = static_cast<AArch64TargetStreamer *>(
- OutStreamer->getTargetStreamer()))
- TS->emitNoteSection(Flags);
+ auto *TS =
+ static_cast<AArch64TargetStreamer *>(OutStreamer->getTargetStreamer());
+ TS->emitNoteSection(Flags);
}
void AArch64AsmPrinter::emitFunctionHeaderComment() {
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
index 3fe3b2a698550..451f0b26ed091 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
@@ -495,6 +495,10 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64TargetMC() {
// Register the asm streamer.
TargetRegistry::RegisterAsmTargetStreamer(*T,
createAArch64AsmTargetStreamer);
+ // Register the null streamer.
+ TargetRegistry::RegisterNullTargetStreamer(*T,
+ createAArch64NullTargetStreamer);
+
// Register the MCInstPrinter.
TargetRegistry::RegisterMCInstPrinter(*T, createAArch64MCInstPrinter);
}
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
index 1a8071ac1b338..e2860cef89817 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
@@ -119,3 +119,7 @@ llvm::createAArch64ObjectTargetStreamer(MCStreamer &S,
return new AArch64TargetWinCOFFStreamer(S);
return nullptr;
}
+
+MCTargetStreamer *llvm::createAArch64NullTargetStreamer(MCStreamer &S) {
+ return new AArch64TargetStreamer(S);
+}
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
index d6dc4a529cf45..acb03f349e863 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
@@ -154,6 +154,8 @@ class AArch64TargetWinCOFFStreamer : public llvm::AArch64TargetStreamer {
MCTargetStreamer *
createAArch64ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI);
+MCTargetStreamer *createAArch64NullTargetStreamer(MCStreamer &S);
+
} // end namespace llvm
#endif
diff --git a/llvm/test/CodeGen/AArch64/null-mctargetstreamer.ll b/llvm/test/CodeGen/AArch64/null-mctargetstreamer.ll
new file mode 100644
index 0000000000000..010e5d021193e
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/null-mctargetstreamer.ll
@@ -0,0 +1,5 @@
+; RUN: llc -mtriple=aarch64-unknown-unknown -filetype=null %s
+
+define dso_local aarch64_vector_pcs void @foo() {
+ ret void
+}
More information about the llvm-commits
mailing list