diff options
author | Matthias Braun <matze@braunis.de> | 2018-10-01 17:50:52 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2018-10-01 17:50:52 +0000 |
commit | 5c22a0c683e2f14f30315be0af26dca0ca711924 (patch) | |
tree | d27ee91acc1df3b6d9b39ad14297bf1b53cf63df /llvm | |
parent | 5521bb8993e01d4ce34ab8182c7a9c1bf2a3a067 (diff) |
MIRParser: Check that instructions only reference DILocation metadata
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.cpp | 2 | ||||
-rw-r--r-- | llvm/test/CodeGen/MIR/X86/invalid-debug-location.mir | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 5c6a41af97a..da758da873c 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -779,6 +779,8 @@ bool MIParser::parse(MachineInstr *&MI) { MDNode *Node = nullptr; if (parseMDNode(Node)) return true; + if (!isa<DILocation>(Node)) + return error("referenced metadata is not a DILocation"); DebugLocation = DebugLoc(Node); } diff --git a/llvm/test/CodeGen/MIR/X86/invalid-debug-location.mir b/llvm/test/CodeGen/MIR/X86/invalid-debug-location.mir new file mode 100644 index 00000000000..60f718ed679 --- /dev/null +++ b/llvm/test/CodeGen/MIR/X86/invalid-debug-location.mir @@ -0,0 +1,15 @@ +# RUN: not llc -o - %s -run-pass=none 2>&1 | FileCheck %s +--- | + target triple="x86_64--" + define void @func() { + unreachable + } + !0 = !{} +... +--- +name: func +body: | + bb.0: + ; CHECK: [[@LINE+1]]:27: referenced metadata is not a DILocation + NOOP debug-location !0 +... |