[PATCH] D33574: PPC: Verify that branch fixups fit within the range.

Kyle Butt via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 30 10:22:55 PDT 2017


iteratee added inline comments.


================
Comment at: lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp:40
+      llvm_unreachable("Cond branch target overflow.");
+    else if (static_cast<int64_t>(Value) < 0 && Value < 0xffffffffffff8000)
+      llvm_unreachable("Cond branch target underflow.");
----------------
inouehrs wrote:
> You need suffix UL or ULL for a 64-bit literal?
> Also I feel signed comparison is easier to read than unsigned comparison with a very large literal.
Thanks for the suggestion. Negating one of the operands make the comparison symmetric and much clearer.


================
Comment at: lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp:44
   case PPC::fixup_ppc_brcond14abs:
+    assert(Value >= 0 && Value <= 0xffff &&
+           "Cond branch absolute target overflow.");
----------------
inouehrs wrote:
> You need a cast here; 'Value >= 0' is always true.
Or I just don't need it. ;-)


https://reviews.llvm.org/D33574





More information about the llvm-commits mailing list