[PATCH] D71468: [llvm-exegesis] Set up AsmTargetStreamer in readSnippets
Guillaume Chatelet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 07:20:50 PST 2019
gchatelet created this revision.
gchatelet added reviewers: courbet, mstojanovic.
Herald added subscribers: llvm-commits, mikhail.ramalho, tschuett.
Herald added a project: LLVM.
This is a follow up on D71137 <https://reviews.llvm.org/D71137> properly setting up the AsmTargetStreamer prior to AsmParser::Run call.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D71468
Files:
llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
llvm/unittests/tools/llvm-exegesis/X86/SnippetFileTest.cpp
Index: llvm/unittests/tools/llvm-exegesis/X86/SnippetFileTest.cpp
===================================================================
--- llvm/unittests/tools/llvm-exegesis/X86/SnippetFileTest.cpp
+++ llvm/unittests/tools/llvm-exegesis/X86/SnippetFileTest.cpp
@@ -115,6 +115,13 @@
consumeError(std::move(Error));
}
+TEST_F(X86SnippetFileTest, NoAsmStreamer) {
+ auto Snippets = TestCommon(R"(
+ .cv_fpo_proc foo 4
+ )");
+ EXPECT_FALSE((bool)Snippets.takeError());
+}
+
} // namespace
} // namespace exegesis
} // namespace llvm
Index: llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
===================================================================
--- llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
+++ llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
@@ -135,6 +135,20 @@
ObjectFileInfo.InitMCObjectFileInfo(TM.getTargetTriple(), /*PIC*/ false,
Context);
BenchmarkCodeStreamer Streamer(&Context, TM.getMCRegisterInfo(), &Result);
+
+ std::string Error;
+ raw_string_ostream ErrorStream(Error);
+ formatted_raw_ostream InstPrinterOStream(ErrorStream);
+ MCInstPrinter *const InstPrinter = TM.getTarget().createMCInstPrinter(
+ TM.getTargetTriple(), TM.getMCAsmInfo()->getAssemblerDialect(),
+ *TM.getMCAsmInfo(), *TM.getMCInstrInfo(), *TM.getMCRegisterInfo());
+ // The following call will take care of calling Streamer.setTargetStreamer.
+ TM.getTarget().createAsmTargetStreamer(Streamer, InstPrinterOStream,
+ InstPrinter,
+ TM.Options.MCOptions.AsmVerbose);
+ if (!Streamer.getTargetStreamer())
+ return make_error<Failure>("cannot create target asm streamer");
+
const std::unique_ptr<MCAsmParser> AsmParser(
createMCAsmParser(SM, Context, Streamer, *TM.getMCAsmInfo()));
if (!AsmParser)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71468.233800.patch
Type: text/x-patch
Size: 1860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191213/a68cc790/attachment.bin>
More information about the llvm-commits
mailing list