[Lldb-commits] [PATCH] D80955: Fix UB in EmulateInstructionARM64.cpp

Vedant Kumar via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 2 18:07:53 PDT 2020


vsk added inline comments.


================
Comment at: lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp:99
+  if (!overflow)
+    overflow |= !llvm::checkedAdd(*signed_sum, SInt(carry_in));
   uint64_t result = unsigned_sum;
----------------
aprantl wrote:
> vsk wrote:
> > 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.
> > 
> > [1] https://developer.arm.com/docs/ddi0596/e/shared-pseudocode-functions/shared-functionsinteger-pseudocode#impl-shared.AddWithCarry.3
> Am I misreading this or are we also setting the C(arry) flag inverted according to the documentation?
Oh wow.. nice catch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80955/new/

https://reviews.llvm.org/D80955





More information about the lldb-commits mailing list