Skip to content

Commit 4ffd523

Browse files
committed
Fixes simple issue found static analyzer
1 parent 965c3d7 commit 4ffd523

File tree

9 files changed

+20
-32
lines changed

9 files changed

+20
-32
lines changed

llvm/lib/CodeGen/GlobalISel/GISelValueTracking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ void GISelValueTracking::computeKnownFPClass(Register R,
13731373
(KnownLHS.isKnownNeverInfinity() || KnownRHS.isKnownNeverInfinity()))
13741374
Known.knownNot(fcNan);
13751375

1376-
if (Opcode == Instruction::FAdd) {
1376+
if (Opcode == TargetOpcode::G_FADD) {
13771377
if (KnownLHS.cannotBeOrderedLessThanZero() &&
13781378
KnownRHS.cannotBeOrderedLessThanZero())
13791379
Known.knownNot(KnownFPClass::OrderedLessThanZeroMask);
@@ -1488,7 +1488,7 @@ void GISelValueTracking::computeKnownFPClass(Register R,
14881488
KnownLHS, Depth + 1);
14891489
}
14901490

1491-
if (Opcode == Instruction::FDiv) {
1491+
if (Opcode == TargetOpcode::G_FDIV) {
14921492
// Only 0/0, Inf/Inf produce NaN.
14931493
if (KnownLHS.isKnownNeverNaN() && KnownRHS.isKnownNeverNaN() &&
14941494
(KnownLHS.isKnownNeverInfinity() ||

llvm/lib/CodeGen/MachineFunction.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,8 +1439,7 @@ void MachineJumpTableInfo::print(raw_ostream &OS) const {
14391439
OS << printJumpTableEntryReference(i) << ':';
14401440
for (const MachineBasicBlock *MBB : JumpTables[i].MBBs)
14411441
OS << ' ' << printMBBReference(*MBB);
1442-
if (i != e)
1443-
OS << '\n';
1442+
OS << '\n';
14441443
}
14451444

14461445
OS << '\n';

llvm/lib/CodeGen/MachineInstr.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,39 +2011,34 @@ void MachineInstr::print(raw_ostream &OS, ModuleSlotTracker &MST,
20112011
// operands.
20122012
if (MCSymbol *PreInstrSymbol = getPreInstrSymbol()) {
20132013
if (!FirstOp) {
2014-
FirstOp = false;
20152014
OS << ',';
20162015
}
20172016
OS << " pre-instr-symbol ";
20182017
MachineOperand::printSymbol(OS, *PreInstrSymbol);
20192018
}
20202019
if (MCSymbol *PostInstrSymbol = getPostInstrSymbol()) {
20212020
if (!FirstOp) {
2022-
FirstOp = false;
20232021
OS << ',';
20242022
}
20252023
OS << " post-instr-symbol ";
20262024
MachineOperand::printSymbol(OS, *PostInstrSymbol);
20272025
}
20282026
if (MDNode *HeapAllocMarker = getHeapAllocMarker()) {
20292027
if (!FirstOp) {
2030-
FirstOp = false;
20312028
OS << ',';
20322029
}
20332030
OS << " heap-alloc-marker ";
20342031
HeapAllocMarker->printAsOperand(OS, MST);
20352032
}
20362033
if (MDNode *PCSections = getPCSections()) {
20372034
if (!FirstOp) {
2038-
FirstOp = false;
20392035
OS << ',';
20402036
}
20412037
OS << " pcsections ";
20422038
PCSections->printAsOperand(OS, MST);
20432039
}
20442040
if (MDNode *MMRA = getMMRAMetadata()) {
20452041
if (!FirstOp) {
2046-
FirstOp = false;
20472042
OS << ',';
20482043
}
20492044
OS << " mmra ";

llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,9 @@ LVScope *LVDWARFReader::processOneDie(const DWARFDie &InputDIE, LVScope *Parent,
395395
if (abbrCode) {
396396
if (const DWARFAbbreviationDeclaration *AbbrevDecl =
397397
TheDIE.getAbbreviationDeclarationPtr())
398-
if (AbbrevDecl)
399-
for (const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec :
400-
AbbrevDecl->attributes())
401-
processOneAttribute(TheDIE, &CurrentEndOffset, AttrSpec);
398+
for (const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec :
399+
AbbrevDecl->attributes())
400+
processOneAttribute(TheDIE, &CurrentEndOffset, AttrSpec);
402401
}
403402
};
404403

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5732,7 +5732,7 @@ void AArch64InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
57325732
AArch64::FPR8RegClass.contains(SrcReg)) {
57335733
if (Subtarget.hasZeroCycleRegMoveFPR128() &&
57345734
!Subtarget.hasZeroCycleRegMoveFPR64() &&
5735-
!Subtarget.hasZeroCycleRegMoveFPR64() && Subtarget.isNeonAvailable()) {
5735+
!Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable()) {
57365736
MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
57375737
&AArch64::FPR128RegClass);
57385738
MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,

llvm/lib/Target/PowerPC/PPCInstrInfo.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ bool PPCInstrInfo::getFMAPatterns(MachineInstr &Root,
416416

417417
// If this is not Leaf FMA Instr, its 'add' operand should only have one use
418418
// as this fma will be changed later.
419-
return IsLeaf ? true : MRI->hasOneNonDBGUse(OpAdd.getReg());
419+
return MRI->hasOneNonDBGUse(OpAdd.getReg());
420420
};
421421

422422
int16_t AddOpIdx = -1;
@@ -5809,9 +5809,6 @@ bool PPCInstrInfo::getMemOperandWithOffsetWidth(
58095809
if (!LdSt.getOperand(1).isImm() ||
58105810
(!LdSt.getOperand(2).isReg() && !LdSt.getOperand(2).isFI()))
58115811
return false;
5812-
if (!LdSt.getOperand(1).isImm() ||
5813-
(!LdSt.getOperand(2).isReg() && !LdSt.getOperand(2).isFI()))
5814-
return false;
58155812

58165813
if (!LdSt.hasOneMemOperand())
58175814
return false;

llvm/lib/Target/VE/AsmParser/VEAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ class VEOperand : public MCParsedAsmOperand {
694694
if (!ConstExpr)
695695
return false;
696696
unsigned regIdx = ConstExpr->getValue();
697-
if (regIdx > 31 || MISCRegs[regIdx] == VE::NoRegister)
697+
if (regIdx >= std::size(MISCRegs) || MISCRegs[regIdx] == VE::NoRegister)
698698
return false;
699699
Op.Kind = k_Register;
700700
Op.Reg.Reg = MISCRegs[regIdx];

llvm/lib/TargetParser/Host.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,9 +2195,9 @@ StringMap<bool> sys::getHostCPUFeatures() {
21952195
bool HasLeaf24 =
21962196
MaxLevel >= 0x24 && !getX86CpuIDAndInfo(0x24, &EAX, &EBX, &ECX, &EDX);
21972197

2198-
int AVX10Ver = HasLeaf24 && (EBX & 0xff);
2199-
Features["avx10.1"] = HasAVX10 && AVX10Ver >= 1;
2200-
Features["avx10.2"] = HasAVX10 && AVX10Ver >= 2;
2198+
int AVX10Ver = EBX & 0xff;
2199+
Features["avx10.1"] = HasAVX10 && HasLeaf24 && AVX10Ver >= 1;
2200+
Features["avx10.2"] = HasAVX10 && HasLeaf24 && AVX10Ver >= 2;
22012201

22022202
return Features;
22032203
}

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,17 +1909,15 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(Instruction *TI,
19091909
});
19101910
if (!AllSame)
19111911
return false;
1912-
if (AllSame) {
1913-
LockstepReverseIterator<true> LRI(Succs);
1914-
while (LRI.isValid()) {
1915-
Instruction *I0 = (*LRI)[0];
1916-
if (any_of(*LRI, [I0](Instruction *I) {
1917-
return !areIdenticalUpToCommutativity(I0, I);
1918-
})) {
1919-
return false;
1920-
}
1921-
--LRI;
1912+
LockstepReverseIterator<true> LRI(Succs);
1913+
while (LRI.isValid()) {
1914+
Instruction *I0 = (*LRI)[0];
1915+
if (any_of(*LRI, [I0](Instruction *I) {
1916+
return !areIdenticalUpToCommutativity(I0, I);
1917+
})) {
1918+
return false;
19221919
}
1920+
--LRI;
19231921
}
19241922
// Now we know that all instructions in all successors can be hoisted. Let
19251923
// the loop below handle the hoisting.

0 commit comments

Comments
 (0)