Skip to content

Commit 0637263

Browse files
[IPSCCP] Variable not visible at Og:
https://bugs.llvm.org/show_bug.cgi?id=51559 #50901 IPSCCP pass removes the global variable and does not create a constant expression for the initializer value. Fix assertion detected by the BuildKite pre-commit CI: llvm::APInt::getZExtValue() const: `getActiveBits() <= 64 && "Too many bits for uint64_t"' failed.
1 parent 42cd75c commit 0637263

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3588,8 +3588,12 @@ DIExpression *llvm::getExpressionForConstant(DIBuilder &DIB, const Constant &C,
35883588
auto *FP = dyn_cast<ConstantFP>(&C);
35893589
if (FP && Ty.isFloatingPointTy()) {
35903590
const APFloat &APF = FP->getValueAPF();
3591-
return DIB.createConstantValueExpression(
3592-
APF.bitcastToAPInt().getZExtValue());
3591+
APInt const &API = APF.bitcastToAPInt();
3592+
if (auto Temp = API.tryZExtValue())
3593+
return DIB.createConstantValueExpression(static_cast<uint64_t>(*Temp));
3594+
else if (auto Temp = API.trySExtValue())
3595+
return DIB.createConstantValueExpression(static_cast<uint64_t>(*Temp));
3596+
return DIB.createConstantValueExpression(*API.getRawData());
35933597
}
35943598

35953599
if (!Ty.isPointerTy())

0 commit comments

Comments
 (0)