Skip to content

Commit de56a89

Browse files
committed
[AMDGPU] return Fail instead of SolfFail from addOperand()
addOperand() method of AMDGPU disassembler returns SoftFail on error. All instances which may lead to that place are an impossible encdoing, not something which is possible to encode, but semantically incorrect as described for SoftFail. Then tablegen generates a check of the following form: if (Decode...(..) == MCDisassembler::Fail) { return MCDisassembler::Fail; } Since we can only return Success and SoftFail that is dead code as detected by the static code analyzer. Solution: return Fail as it should be. See https://bugs.llvm.org/show_bug.cgi?id=43886 Differential Revision: https://reviews.llvm.org/D69819
1 parent 87e0cb4 commit de56a89

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ addOperand(MCInst &Inst, const MCOperand& Opnd) {
7373
Inst.addOperand(Opnd);
7474
return Opnd.isValid() ?
7575
MCDisassembler::Success :
76-
MCDisassembler::SoftFail;
76+
MCDisassembler::Fail;
7777
}
7878

7979
static int insertNamedMCOperand(MCInst &MI, const MCOperand &Op,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RUN: llvm-mc -arch=amdgcn -mcpu=gfx900 -disassemble -show-encoding < %s 2>&1 | FileCheck -check-prefix=GCN %s
2+
3+
# GCN: warning: invalid instruction encoding
4+
0xdf,0x00,0x00,0x02

0 commit comments

Comments
 (0)