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

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 29 02:05:32 PDT 2017


inouehrs 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.");
----------------
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.


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


================
Comment at: lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp:54
   case PPC::fixup_ppc_br24abs:
+    assert(Value >= 0 && Value <= 0x3ffffff &&
+           "Branch absolute target overflow.");
----------------
Ditto. 'Value >= 0' is always true.


Repository:
  rL LLVM

https://reviews.llvm.org/D33574





More information about the llvm-commits mailing list