Skip to content

Commit 5870156

Browse files
authored
Rollup merge of #97840 - durin42:llvm-15-apint, r=nikic
RustWrapper: adapt to APInt API changes in LLVM 15 In https://reviews.llvm.org/D125556 upstream changed sext() and zext() to allow some no-op cases, which previously required use of the *OrSelf() methods, which I assume is what was going on here. The *OrSelf() methods got removed in https://reviews.llvm.org/D125559 after two weeks of deprecation because they came with some bonus (probably-undesired) behavior. Since the behavior of sext() and zext() changed slightly, I kept the old *OrSelf() calls in LLVM 14 and earlier, and only use the new version in LLVM 15. r? `@nikic`
2 parents 796c466 + 1c26dd0 commit 5870156

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -1542,11 +1542,19 @@ extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *hig
15421542
auto C = unwrap<llvm::ConstantInt>(CV);
15431543
if (C->getBitWidth() > 128) { return false; }
15441544
APInt AP;
1545+
#if LLVM_VERSION_GE(15, 0)
1546+
if (sext) {
1547+
AP = C->getValue().sext(128);
1548+
} else {
1549+
AP = C->getValue().zext(128);
1550+
}
1551+
#else
15451552
if (sext) {
15461553
AP = C->getValue().sextOrSelf(128);
15471554
} else {
15481555
AP = C->getValue().zextOrSelf(128);
15491556
}
1557+
#endif
15501558
*low = AP.getLoBits(64).getZExtValue();
15511559
*high = AP.getHiBits(64).getZExtValue();
15521560
return true;

0 commit comments

Comments
 (0)