summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetInstrInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/TargetInstrInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetInstrInfo.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp
index f221fa1ea5e..467f8730867 100644
--- a/llvm/lib/CodeGen/TargetInstrInfo.cpp
+++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp
@@ -79,21 +79,25 @@ unsigned TargetInstrInfo::getInlineAsmLength(const char *Str,
const MCAsmInfo &MAI) const {
// Count the number of instructions in the asm.
bool atInsnStart = true;
- unsigned Length = 0;
+ unsigned InstCount = 0;
for (; *Str; ++Str) {
if (*Str == '\n' || strncmp(Str, MAI.getSeparatorString(),
- strlen(MAI.getSeparatorString())) == 0)
+ strlen(MAI.getSeparatorString())) == 0) {
atInsnStart = true;
- if (atInsnStart && !std::isspace(static_cast<unsigned char>(*Str))) {
- Length += MAI.getMaxInstLength();
+ } else if (strncmp(Str, MAI.getCommentString(),
+ strlen(MAI.getCommentString())) == 0) {
+ // Stop counting as an instruction after a comment until the next
+ // separator.
atInsnStart = false;
}
- if (atInsnStart && strncmp(Str, MAI.getCommentString(),
- strlen(MAI.getCommentString())) == 0)
+
+ if (atInsnStart && !std::isspace(static_cast<unsigned char>(*Str))) {
+ ++InstCount;
atInsnStart = false;
+ }
}
- return Length;
+ return InstCount * MAI.getMaxInstLength();
}
/// ReplaceTailWithBranchTo - Delete the instruction OldInst and everything
OpenPOWER on IntegriCloud