This fixes an unhandled signed integer overflow in AddWithCarry() by using the llvm::checkedAdd() function. Thats to @vsk for the suggestion!
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Any chance we can export AddWithCarry via EmulateInstructionARM64.h, then add a unit test in TestArm64InstEmulation.cpp?
I should add: otherwise, this looks good!
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp | ||
---|---|---|
92 | The docs [1] say 'integer signed_sum = SInt(x) + SInt(y) + UInt(carry_in)', but I bet checkedAdd doesn't support that, and anyway carry_in is 1-bit so it doesn't matter. |
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp | ||
---|---|---|
25 | Why? also should be cstdlib in C++. |
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp | ||
---|---|---|
25 | It's just something shuffled around, probably a side effect of clang-format. |
This is great Adrian. I feel like there are several other instances of additions that should use llvm::checkAdd here instead of +. Is this the only UB triggered in the testsuite?
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp | ||
---|---|---|
92 | Am I misreading this or are we also setting the C(arry) flag inverted according to the documentation? |
This is great Adrian. I feel like there are several other instances of additions that should use llvm::checkAdd here instead of +. Is this the only UB triggered in the testsuite?
It's the only UB caught by the green dragon / ci.swift.org bots.
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp | ||
---|---|---|
92 | Oh wow.. nice catch. |
Why? also should be cstdlib in C++.