diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-07-01 23:26:50 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-07-01 23:26:50 +0000 |
commit | accddacb708e1925ac14417f21ce586f87b7bd4e (patch) | |
tree | e02406637843d4a058893d364a47db1174f6619c /llvm/lib/CodeGen/TargetInstrInfo.cpp | |
parent | 58b6e3e3d099057e300caa864ae53d01e50f296e (diff) | |
download | bcm5719-llvm-accddacb708e1925ac14417f21ce586f87b7bd4e.tar.gz bcm5719-llvm-accddacb708e1925ac14417f21ce586f87b7bd4e.zip |
TII: Fix inlineasm size counting comments as insts
The main problem was counting comments on their own
line as instructions.
llvm-svn: 274405
Diffstat (limited to 'llvm/lib/CodeGen/TargetInstrInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetInstrInfo.cpp | 18 |
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 |