From accddacb708e1925ac14417f21ce586f87b7bd4e Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 1 Jul 2016 23:26:50 +0000 Subject: TII: Fix inlineasm size counting comments as insts The main problem was counting comments on their own line as instructions. llvm-svn: 274405 --- llvm/lib/CodeGen/TargetInstrInfo.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'llvm/lib/CodeGen') 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(*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(*Str))) { + ++InstCount; atInsnStart = false; + } } - return Length; + return InstCount * MAI.getMaxInstLength(); } /// ReplaceTailWithBranchTo - Delete the instruction OldInst and everything -- cgit v1.2.3