LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 32480 - llvm/lib/Target/Hexagon/HexagonEarlyIfConv.cpp: PVS-Studio: two similar code fragments
Summary: llvm/lib/Target/Hexagon/HexagonEarlyIfConv.cpp: PVS-Studio: two similar code ...
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Backend: Hexagon (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks: 30996
  Show dependency tree
 
Reported: 2017-03-30 23:39 PDT by Svyatoslav Razmyslov
Modified: 2017-03-31 13:48 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Svyatoslav Razmyslov 2017-03-30 23:39:38 PDT
We have found a bug using PVS-Studio tool. PVS-Studio is a static code analyzer for C, C++ and C#: https://www.viva64.com/en/pvs-studio/

Analyzer warning: V778 Two similar code fragments were found. Perhaps, this is a typo and 'FS' variable should be used instead of 'TS'. hexagonearlyifconv.cpp 549

bool HexagonEarlyIfConversion::isProfitable(....) const
{
  ....
  unsigned TS = 0, FS = 0, Spare = 0;
  if (FP.TrueB) {
    TS = std::distance(FP.TrueB->begin(),
      FP.TrueB->getFirstTerminator());
    if (TS < HEXAGON_PACKET_SIZE)
      Spare += HEXAGON_PACKET_SIZE-TS;     // <=
  }
  if (FP.FalseB) {
    FS = std::distance(FP.FalseB->begin(),
      FP.FalseB->getFirstTerminator());
    if (FS < HEXAGON_PACKET_SIZE)
      Spare += HEXAGON_PACKET_SIZE-TS;     // <= FS ???
  }
  unsigned TotalIn = TS+FS;
  ....
}
Comment 1 Simon Pilgrim 2017-03-31 06:07:22 PDT
Krzysztof please can you take a look?
Comment 2 Krzysztof Parzyszek 2017-03-31 13:48:46 PDT
Fixed in r299258.