summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/InlineAsm.cpp
diff options
context:
space:
mode:
authorDaniil Fukalov <daniil.fukalov@amd.com>2017-10-25 12:51:32 +0000
committerDaniil Fukalov <daniil.fukalov@amd.com>2017-10-25 12:51:32 +0000
commit2bfbadcbc19eeb7e059d844bcd8fd844f1c0a0ed (patch)
treeec8ca97088d00a147be541a7dce8b5f2f04d288b /llvm/lib/IR/InlineAsm.cpp
parentc537795433018594a0b2967d88f04f282e15153e (diff)
downloadbcm5719-llvm-2bfbadcbc19eeb7e059d844bcd8fd844f1c0a0ed.tar.gz
bcm5719-llvm-2bfbadcbc19eeb7e059d844bcd8fd844f1c0a0ed.zip
[inlineasm] Fix crash when number of matched input constraint operands overflows signed char
In a case when number of output constraint operands that has matched input operands doesn't fit to signed char, TargetLowering::ParseConstraints() can try to access ConstraintOperands (that is std::vector) with negative index. Reviewers: rampitec, arsenm Differential Review: https://reviews.llvm.org/D39125 llvm-svn: 316574
Diffstat (limited to 'llvm/lib/IR/InlineAsm.cpp')
-rw-r--r--llvm/lib/IR/InlineAsm.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/IR/InlineAsm.cpp b/llvm/lib/IR/InlineAsm.cpp
index ad22efdf0ef..8667d7aab58 100644
--- a/llvm/lib/IR/InlineAsm.cpp
+++ b/llvm/lib/IR/InlineAsm.cpp
@@ -163,6 +163,7 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
return true;
// Note that operand #n has a matching input.
scInfo.MatchingInput = ConstraintsSoFar.size();
+ assert(scInfo.MatchingInput >= 0);
} else {
if (ConstraintsSoFar[N].hasMatchingInput() &&
(size_t)ConstraintsSoFar[N].MatchingInput !=
@@ -170,6 +171,7 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str,
return true;
// Note that operand #n has a matching input.
ConstraintsSoFar[N].MatchingInput = ConstraintsSoFar.size();
+ assert(ConstraintsSoFar[N].MatchingInput >= 0);
}
} else if (*I == '|') {
multipleAlternativeIndex++;
OpenPOWER on IntegriCloud