[llvm] d094f3c - [llvm-exegesis] SnippetFile: do create source manager in MCContext

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 4 05:59:03 PDT 2021


Author: Roman Lebedev
Date: 2021-04-04T15:58:39+03:00
New Revision: d094f3c3c5c447e2241f6d8b7e7379fc01865aeb

URL: https://github.com/llvm/llvm-project/commit/d094f3c3c5c447e2241f6d8b7e7379fc01865aeb
DIFF: https://github.com/llvm/llvm-project/commit/d094f3c3c5c447e2241f6d8b7e7379fc01865aeb.diff

LOG: [llvm-exegesis] SnippetFile: do create source manager in MCContext

This way, once there's an error in the snippet file (like in the test),
llvm-exegesis won't crash with an assertion failure,
but print a nice diagnostic about the problem.

Added: 
    llvm/test/tools/llvm-exegesis/X86/uops-misspelled-div.s

Modified: 
    llvm/tools/llvm-exegesis/lib/SnippetFile.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-exegesis/X86/uops-misspelled-div.s b/llvm/test/tools/llvm-exegesis/X86/uops-misspelled-div.s
new file mode 100644
index 0000000000000..05e8f4de91166
--- /dev/null
+++ b/llvm/test/tools/llvm-exegesis/X86/uops-misspelled-div.s
@@ -0,0 +1,8 @@
+# RUN: not llvm-exegesis -mode=uops -snippets-file=%s 2>&1 | FileCheck %s
+
+# LLVM-EXEGESIS-DEFREG CL 1
+# LLVM-EXEGESIS-DEFREG AX 1
+div8r cl
+
+CHECK: error: invalid instruction mnemonic 'div8r'
+CHECK: llvm-exegesis error: cannot parse asm file

diff  --git a/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp b/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
index c71050c61fa7c..1b8b3e7560ea1 100644
--- a/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
@@ -133,6 +133,7 @@ Expected<std::vector<BenchmarkCode>> readSnippets(const LLVMState &State,
   MCObjectFileInfo ObjectFileInfo;
   const TargetMachine &TM = State.getTargetMachine();
   MCContext Context(TM.getMCAsmInfo(), TM.getMCRegisterInfo(), &ObjectFileInfo);
+  Context.initInlineSourceManager();
   ObjectFileInfo.InitMCObjectFileInfo(TM.getTargetTriple(), /*PIC*/ false,
                                       Context);
   BenchmarkCodeStreamer Streamer(&Context, TM.getMCRegisterInfo(), &Result);


        


More information about the llvm-commits mailing list