Caused by optimizeExtInstr function uses uninitialized SubIdx.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I think SubIdx is supposed to be set by TII->isCoalescableExtInstr(). If it's not doing that, then the error's probably in that call and not in this function.
I think SubIdx is supposed to be set by TII->isCoalescableExtInstr(). If it's not doing that, then the error's probably in that call and not in this function.
Then most target instr infos need to patch.
A test case that shows the problem would also be good.
valgrind shows me this bug. I don't think any testcase is able to reproduce an expected value in this circumstance.
Which platform did you run valgrind on? The x86 platform should set SubIdx on all paths through it...
Which platform did you run valgrind on? The x86 platform should set SubIdx on all paths through it...
ARM. armv8-linux-android.
Strange. SubIdx is initialized on all paths that return true in that function. So I'm not sure why valgrind complained...
My one worry with the change in this patch is that 0 is ostensibly a valid index, right? So how do we distinguish it from an invalid one if isCoalescableExtInstr returns true without properly initializing SubIdx?
bool AArch64InstrInfo::isCoalescableExtInstr(const MachineInstr &MI, Register &SrcReg, Register &DstReg, unsigned &SubIdx) const { switch (MI.getOpcode()) { default: return false; case AArch64::SBFMXri: // aka sxtw case AArch64::UBFMXri: // aka uxtw // Check for the 32 -> 64 bit extension case, these instructions can do // much more. if (MI.getOperand(2).getImm() != 0 || MI.getOperand(3).getImm() != 31) return false; // This is a signed or unsigned 32 -> 64 bit extension. SrcReg = MI.getOperand(1).getReg(); DstReg = MI.getOperand(0).getReg(); SubIdx = AArch64::sub_32; return true; } }
Back to author. We should fix the relevant isCoalescableExtInstr in the targets instead of just default initializing the field. That said all implementations of that callback on open-source trunk look fine to me too.
clang-format not found in user's PATH; not linting file.