[PATCH] D114194: [SystemZ] Add range checks for PC-relative fixups
Jonas Paulsson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 7 10:14:52 PST 2021
jonpa added inline comments.
================
Comment at: llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp:43
+ auto handlePCRelFixupValue = [&](unsigned W) -> uint64_t {
+ assert(Value % 2 == 0 && "Non-even PC relative offset.");
+ if (!checkFixupInRange(minIntN(W) * 2, maxIntN(W) * 2))
----------------
uweigand wrote:
> Hmm, this scenario could be triggered by wrong assembler input (e.g. something simple like `j .+1`), so I don't think this should result in an assert (internal compiler error).
>
> GCC/binutils currently seems to simply ignore that case (and round down), which also isn't ideal.
>
> I think this really should be a user-level error message, not an assert.
Changed this like:
```
auto handlePCRelFixupValue = [&](unsigned W) -> uint64_t {
- assert(Value % 2 == 0 && "Non-even PC relative offset.");
+ if (Value % 2 != 0)
+ Ctx.reportError(Fixup.getLoc(), "Non-even PC relative offset.");
if (!checkFixupInRange(minIntN(W) * 2, maxIntN(W) * 2))
return 0;
return (int64_t)Value / 2;
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114194/new/
https://reviews.llvm.org/D114194
More information about the llvm-commits
mailing list