Skip to content

Commit 797b7aa

Browse files
committed
Attempt to make the bit-twiddling readable resulted in the binary value being
overwritten. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121337 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 09aa3f0 commit 797b7aa

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/Target/ARM/ARMAsmBackend.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,11 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
152152
// Note that the halfwords are stored high first, low second; so we need
153153
// to transpose the fixup value here to map properly.
154154
unsigned isNeg = (int64_t(Value) < 0) ? 1 : 0;
155-
uint32_t Binary = 0x3fffff & ((Value - 4) >> 1);
156-
Binary = (Binary & 0x7ff) << 16; // Low imm11 value.
157-
Binary |= (Binary & 0x1ffc00) >> 11; // High imm10 value.
158-
Binary |= isNeg << 10; // Sign bit.
155+
uint32_t Binary = 0;
156+
Value = 0x3fffff & ((Value - 4) >> 1);
157+
Binary = (Value & 0x7ff) << 16; // Low imm11 value.
158+
Binary |= (Value & 0x1ffc00) >> 11; // High imm10 value.
159+
Binary |= isNeg << 10; // Sign bit.
159160
return Binary;
160161
}
161162
case ARM::fixup_arm_thumb_blx: {
@@ -169,10 +170,11 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
169170
// Note that the halfwords are stored high first, low second; so we need
170171
// to transpose the fixup value here to map properly.
171172
unsigned isNeg = (int64_t(Value) < 0) ? 1 : 0;
172-
uint32_t Binary = 0xfffff & ((Value - 2) >> 2);
173-
Binary = (Binary & 0x3ff) << 17; // Low imm10L value.
174-
Binary |= (Binary & 0xffc00) >> 10; // High imm10H value.
175-
Binary |= isNeg << 10; // Sign bit.
173+
uint32_t Binary = 0;
174+
Value = 0xfffff & ((Value - 2) >> 2);
175+
Binary = (Value & 0x3ff) << 17; // Low imm10L value.
176+
Binary |= (Value & 0xffc00) >> 10; // High imm10H value.
177+
Binary |= isNeg << 10; // Sign bit.
176178
return Binary;
177179
}
178180
case ARM::fixup_arm_thumb_cp:

0 commit comments

Comments
 (0)