Skip to content

Commit 5cf138c

Browse files
committed
[llvm][JITLink][LoongArch] Fix bit extraction on 32 bit platforms
This shifted `1UL` to make the mask. On 32 bit Linux UL is 32 bit, so if Hi+1 was >= 32 then you'd get the wrong result here. The other version of this uses 1ULL, but using the uint64_t typename here saves someone going to check what ULL means on different platforms. This fixes test failures seen on Linaro's 32 bit bots: https://lab.llvm.org/buildbot/#/builders/39/builds/3700 https://lab.llvm.org/buildbot/#/builders/122/builds/781 Though I cannot say exactly why this fixes them. Does not seem like the new code was triggering this problem, but somehow it must be.
1 parent f87a9db commit 5cf138c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/include/llvm/ExecutionEngine/JITLink/loongarch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ const char *getEdgeKindName(Edge::Kind K);
233233

234234
// Returns extract bits Val[Hi:Lo].
235235
inline uint32_t extractBits(uint64_t Val, unsigned Hi, unsigned Lo) {
236-
return Hi == 63 ? Val >> Lo : (Val & (((1UL << (Hi + 1)) - 1))) >> Lo;
236+
return Hi == 63 ? Val >> Lo : (Val & ((((uint64_t)1 << (Hi + 1)) - 1))) >> Lo;
237237
}
238238

239239
/// Apply fixup expression for edge to block content.

0 commit comments

Comments
 (0)