llvm.org GIT mirror llvm / 3d478ae
Return early from getUnconditionalBranchTargetOpValue if the branch target is an MCExpr, in order to avoid writing an encoded zero value in the immediate field. When getUnconditionalBranchTargetOpValue is called with an MCExpr target, we don't know what the final immediate field value should be. We shouldn't explicitly set the immediate field to an encoded zero value as zero is encoded with a non-zero bit pattern. This leads to bits being set that pollute the final immediate value. The nature of the encoding is such that the polluted bits only affect very large immediate values, explaining why this hasn't caused problems earlier. Fixes <rdar://problem/15155975>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193535 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 6 years ago
2 changed file(s) with 3 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
640640 const MCOperand MO = MI.getOperand(OpIdx);
641641
642642 if(MO.isExpr())
643 Val = ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_t2_uncondbranch, Fixups);
643 return ::getBranchTargetOpValue(MI, OpIdx, ARM::fixup_t2_uncondbranch, Fixups);
644644 else
645645 Val = MO.getImm() >> 1;
646646
225225 beq.w _bar
226226 bmi.w #-183396
227227
228 @ CHECK: b.w _bar @ encoding: [A,0xf0'A',A,0xb8'A']
228 @ CHECK: b.w _bar @ encoding: [A,0xf0'A',A,0x90'A']
229229 @ fixup A - offset: 0, value: _bar, kind: fixup_t2_uncondbranch
230230 @ CHECK: beq.w _bar @ encoding: [A,0xf0'A',A,0x80'A']
231231 @ fixup A - offset: 0, value: _bar, kind: fixup_t2_condbranch
232232 @ CHECK: it eq @ encoding: [0x08,0xbf]
233 @ CHECK: beq.w _bar @ encoding: [A,0xf0'A',A,0xb8'A']
233 @ CHECK: beq.w _bar @ encoding: [A,0xf0'A',A,0x90'A']
234234 @ fixup A - offset: 0, value: _bar, kind: fixup_t2_uncondbranch
235235 @ CHECK: bmi.w #-183396 @ encoding: [0x13,0xf5,0xce,0xa9]
236236