<div dir="ltr"><div>FYI, this patch breaks our build:</div><div><br></div><div>lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp:41:55: error: non-virtual member function marked 'override' hides virtual member function</div><div> uint64_t Value, bool IsPCRel) const override;</div><div> ^</div><div><br></div><div>Please fix or revert.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 5, 2017 at 12:16 PM, Alex Bradbury via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: asb<br>
Date: Wed Apr 5 05:16:14 2017<br>
New Revision: 299529<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=299529&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=299529&view=rev</a><br>
Log:<br>
Add MCContext argument to MCAsmBackend::applyFixup for error reporting<br>
<br>
A number of backends (AArch64, MIPS, ARM) have been using<br>
MCContext::reportError to report issues such as out-of-range fixup values in<br>
their TgtAsmBackend. This is great, but because MCContext couldn't easily be<br>
threaded through to the adjustFixupValue helper function from its usual<br>
callsite (applyFixup), these backends ended up adding an MCContext* argument<br>
and adding another call to applyFixup to processFixupValue. Adding an<br>
MCContext parameter to applyFixup makes this unnecessary, and even better -<br>
applyFixup can take a reference to MCContext rather than a potentially null<br>
pointer.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D30264" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D30264</a><br>
<br>
Modified:<br>
llvm/trunk/include/llvm/MC/<wbr>MCAsmBackend.h<br>
llvm/trunk/lib/MC/MCAssembler.<wbr>cpp<br>
llvm/trunk/lib/Target/AArch64/<wbr>MCTargetDesc/<wbr>AArch64AsmBackend.cpp<br>
llvm/trunk/lib/Target/AMDGPU/<wbr>MCTargetDesc/AMDGPUAsmBackend.<wbr>cpp<br>
llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/ARMAsmBackend.cpp<br>
llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/ARMAsmBackend.h<br>
llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/<wbr>ARMELFObjectWriter.cpp<br>
llvm/trunk/lib/Target/BPF/<wbr>MCTargetDesc/BPFAsmBackend.cpp<br>
llvm/trunk/lib/Target/Hexagon/<wbr>MCTargetDesc/<wbr>HexagonAsmBackend.cpp<br>
llvm/trunk/lib/Target/Lanai/<wbr>MCTargetDesc/LanaiAsmBackend.<wbr>cpp<br>
llvm/trunk/lib/Target/Mips/<wbr>MCTargetDesc/MipsAsmBackend.<wbr>cpp<br>
llvm/trunk/lib/Target/Mips/<wbr>MCTargetDesc/MipsAsmBackend.h<br>
llvm/trunk/lib/Target/PowerPC/<wbr>MCTargetDesc/PPCAsmBackend.cpp<br>
llvm/trunk/lib/Target/RISCV/<wbr>MCTargetDesc/RISCVAsmBackend.<wbr>cpp<br>
llvm/trunk/lib/Target/Sparc/<wbr>MCTargetDesc/SparcAsmBackend.<wbr>cpp<br>
llvm/trunk/lib/Target/SystemZ/<wbr>MCTargetDesc/<wbr>SystemZMCAsmBackend.cpp<br>
llvm/trunk/lib/Target/X86/<wbr>MCTargetDesc/X86AsmBackend.cpp<br>
llvm/trunk/test/MC/ARM/quad-<wbr>relocation.s<br>
<br>
Modified: llvm/trunk/include/llvm/MC/<wbr>MCAsmBackend.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmBackend.h?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/MC/MCAsmBackend.h?rev=<wbr>299529&r1=299528&r2=299529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/MC/<wbr>MCAsmBackend.h (original)<br>
+++ llvm/trunk/include/llvm/MC/<wbr>MCAsmBackend.h Wed Apr 5 05:16:14 2017<br>
@@ -71,9 +71,11 @@ public:<br>
<br>
/// Apply the \p Value for given \p Fixup into the provided data fragment, at<br>
/// the offset specified by the fixup and following the fixup kind as<br>
- /// appropriate.<br>
+ /// appropriate. Errors (such as an out of range fixup value) should be<br>
+ /// reported via \p Ctx.<br>
virtual void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const = 0;<br>
+ uint64_t Value, bool IsPCRel,<br>
+ MCContext &Ctx) const = 0;<br>
<br>
/// @}<br>
<br>
<br>
Modified: llvm/trunk/lib/MC/MCAssembler.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/MC/<wbr>MCAssembler.cpp?rev=299529&r1=<wbr>299528&r2=299529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/MC/MCAssembler.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/MC/MCAssembler.<wbr>cpp Wed Apr 5 05:16:14 2017<br>
@@ -732,8 +732,8 @@ void MCAssembler::layout(<wbr>MCAsmLayout &La<br>
uint64_t FixedValue;<br>
bool IsPCRel;<br>
std::tie(FixedValue, IsPCRel) = handleFixup(Layout, Frag, Fixup);<br>
- getBackend().applyFixup(Fixup, Contents.data(),<br>
- Contents.size(), FixedValue, IsPCRel);<br>
+ getBackend().applyFixup(Fixup, Contents.data(), Contents.size(),<br>
+ FixedValue, IsPCRel, getContext());<br>
}<br>
}<br>
}<br>
<br>
Modified: llvm/trunk/lib/Target/AArch64/<wbr>MCTargetDesc/<wbr>AArch64AsmBackend.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>AArch64/MCTargetDesc/<wbr>AArch64AsmBackend.cpp?rev=<wbr>299529&r1=299528&r2=299529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/AArch64/<wbr>MCTargetDesc/<wbr>AArch64AsmBackend.cpp (original)<br>
+++ llvm/trunk/lib/Target/AArch64/<wbr>MCTargetDesc/<wbr>AArch64AsmBackend.cpp Wed Apr 5 05:16:14 2017<br>
@@ -73,7 +73,7 @@ public:<br>
}<br>
<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override;<br>
+ uint64_t Value, bool IsPCRel, MCContext &Ctx) const override;<br>
<br>
bool mayNeedRelaxation(const MCInst &Inst) const override;<br>
bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,<br>
@@ -138,15 +138,15 @@ static unsigned AdrImmBits(unsigned Valu<br>
}<br>
<br>
static uint64_t adjustFixupValue(const MCFixup &Fixup, uint64_t Value,<br>
- MCContext *Ctx) {<br>
+ MCContext &Ctx) {<br>
unsigned Kind = Fixup.getKind();<br>
int64_t SignedValue = static_cast<int64_t>(Value);<br>
switch (Kind) {<br>
default:<br>
llvm_unreachable("Unknown fixup kind!");<br>
case AArch64::fixup_aarch64_pcrel_<wbr>adr_imm21:<br>
- if (Ctx && (SignedValue > 2097151 || SignedValue < -2097152))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup value out of range");<br>
+ if (SignedValue > 2097151 || SignedValue < -2097152)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup value out of range");<br>
return AdrImmBits(Value & 0x1fffffULL);<br>
case AArch64::fixup_aarch64_pcrel_<wbr>adrp_imm21:<br>
return AdrImmBits((Value & 0x1fffff000ULL) >> 12);<br>
@@ -154,66 +154,65 @@ static uint64_t adjustFixupValue(const M<br>
case AArch64::fixup_aarch64_pcrel_<wbr>branch19:<br>
// Signed 21-bit immediate<br>
if (SignedValue > 2097151 || SignedValue < -2097152)<br>
- if (Ctx) Ctx->reportError(Fixup.getLoc(<wbr>), "fixup value out of range");<br>
- if (Ctx && (Value & 0x3))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup not sufficiently aligned");<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup value out of range");<br>
+ if (Value & 0x3)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup not sufficiently aligned");<br>
// Low two bits are not encoded.<br>
return (Value >> 2) & 0x7ffff;<br>
case AArch64::fixup_aarch64_add_<wbr>imm12:<br>
case AArch64::fixup_aarch64_ldst_<wbr>imm12_scale1:<br>
// Unsigned 12-bit immediate<br>
- if (Ctx && Value >= 0x1000)<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup value out of range");<br>
+ if (Value >= 0x1000)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup value out of range");<br>
return Value;<br>
case AArch64::fixup_aarch64_ldst_<wbr>imm12_scale2:<br>
// Unsigned 12-bit immediate which gets multiplied by 2<br>
- if (Ctx && (Value >= 0x2000))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup value out of range");<br>
- if (Ctx && (Value & 0x1))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup must be 2-byte aligned");<br>
+ if (Value >= 0x2000)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup value out of range");<br>
+ if (Value & 0x1)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup must be 2-byte aligned");<br>
return Value >> 1;<br>
case AArch64::fixup_aarch64_ldst_<wbr>imm12_scale4:<br>
// Unsigned 12-bit immediate which gets multiplied by 4<br>
- if (Ctx && (Value >= 0x4000))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup value out of range");<br>
- if (Ctx && (Value & 0x3))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup must be 4-byte aligned");<br>
+ if (Value >= 0x4000)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup value out of range");<br>
+ if (Value & 0x3)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup must be 4-byte aligned");<br>
return Value >> 2;<br>
case AArch64::fixup_aarch64_ldst_<wbr>imm12_scale8:<br>
// Unsigned 12-bit immediate which gets multiplied by 8<br>
- if (Ctx && (Value >= 0x8000))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup value out of range");<br>
- if (Ctx && (Value & 0x7))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup must be 8-byte aligned");<br>
+ if (Value >= 0x8000)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup value out of range");<br>
+ if (Value & 0x7)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup must be 8-byte aligned");<br>
return Value >> 3;<br>
case AArch64::fixup_aarch64_ldst_<wbr>imm12_scale16:<br>
// Unsigned 12-bit immediate which gets multiplied by 16<br>
- if (Ctx && (Value >= 0x10000))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup value out of range");<br>
- if (Ctx && (Value & 0xf))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup must be 16-byte aligned");<br>
+ if (Value >= 0x10000)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup value out of range");<br>
+ if (Value & 0xf)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup must be 16-byte aligned");<br>
return Value >> 4;<br>
case AArch64::fixup_aarch64_movw:<br>
- if (Ctx)<br>
- Ctx->reportError(Fixup.getLoc(<wbr>),<br>
- "no resolvable MOVZ/MOVK fixups supported yet");<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>,<br>
+ "no resolvable MOVZ/MOVK fixups supported yet");<br>
return Value;<br>
case AArch64::fixup_aarch64_pcrel_<wbr>branch14:<br>
// Signed 16-bit immediate<br>
- if (Ctx && (SignedValue > 32767 || SignedValue < -32768))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup value out of range");<br>
+ if (SignedValue > 32767 || SignedValue < -32768)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup value out of range");<br>
// Low two bits are not encoded (4-byte alignment assumed).<br>
- if (Ctx && (Value & 0x3))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup not sufficiently aligned");<br>
+ if (Value & 0x3)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup not sufficiently aligned");<br>
return (Value >> 2) & 0x3fff;<br>
case AArch64::fixup_aarch64_pcrel_<wbr>branch26:<br>
case AArch64::fixup_aarch64_pcrel_<wbr>call26:<br>
// Signed 28-bit immediate<br>
- if (Ctx && (SignedValue > 134217727 || SignedValue < -134217728))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup value out of range");<br>
+ if (SignedValue > 134217727 || SignedValue < -134217728)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup value out of range");<br>
// Low two bits are not encoded (4-byte alignment assumed).<br>
- if (Ctx && (Value & 0x3))<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "fixup not sufficiently aligned");<br>
+ if (Value & 0x3)<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "fixup not sufficiently aligned");<br>
return (Value >> 2) & 0x3ffffff;<br>
case FK_Data_1:<br>
case FK_Data_2:<br>
@@ -264,13 +263,13 @@ unsigned AArch64AsmBackend::<wbr>getFixupKind<br>
<br>
void AArch64AsmBackend::applyFixup(<wbr>const MCFixup &Fixup, char *Data,<br>
unsigned DataSize, uint64_t Value,<br>
- bool IsPCRel) const {<br>
+ bool IsPCRel, MCContext &Ctx) const {<br>
unsigned NumBytes = getFixupKindNumBytes(Fixup.<wbr>getKind());<br>
if (!Value)<br>
return; // Doesn't change encoding.<br>
MCFixupKindInfo Info = getFixupKindInfo(Fixup.<wbr>getKind());<br>
// Apply any target-specific value adjustments.<br>
- Value = adjustFixupValue(Fixup, Value, nullptr);<br>
+ Value = adjustFixupValue(Fixup, Value, Ctx);<br>
<br>
// Shift the value into position.<br>
Value <<= Info.TargetOffset;<br>
@@ -521,17 +520,6 @@ public:<br>
<br>
return CompactUnwindEncoding;<br>
}<br>
-<br>
- void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,<br>
- const MCFixup &Fixup, const MCFragment *DF,<br>
- const MCValue &Target, uint64_t &Value,<br>
- bool &IsResolved) override {<br>
- // Try to get the encoded value for the fixup as-if we're mapping it into<br>
- // the instruction. This allows adjustFixupValue() to issue a diagnostic<br>
- // if the value is invalid.<br>
- if (IsResolved)<br>
- (void)adjustFixupValue(Fixup, Value, &Asm.getContext());<br>
- }<br>
};<br>
<br>
} // end anonymous namespace<br>
@@ -575,12 +563,6 @@ void ELFAArch64AsmBackend::<wbr>processFixupV<br>
// to the linker -- a relocation!<br>
if ((uint32_t)Fixup.getKind() == AArch64::fixup_aarch64_pcrel_<wbr>adrp_imm21)<br>
IsResolved = false;<br>
-<br>
- // Try to get the encoded value for the fixup as-if we're mapping it into<br>
- // the instruction. This allows adjustFixupValue() to issue a diagnostic<br>
- // if the value is invalid.<br>
- if (IsResolved)<br>
- (void)adjustFixupValue(Fixup, Value, &Asm.getContext());<br>
}<br>
<br>
}<br>
<br>
Modified: llvm/trunk/lib/Target/AMDGPU/<wbr>MCTargetDesc/AMDGPUAsmBackend.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>AMDGPU/MCTargetDesc/<wbr>AMDGPUAsmBackend.cpp?rev=<wbr>299529&r1=299528&r2=299529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/AMDGPU/<wbr>MCTargetDesc/AMDGPUAsmBackend.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/Target/AMDGPU/<wbr>MCTargetDesc/AMDGPUAsmBackend.<wbr>cpp Wed Apr 5 05:16:14 2017<br>
@@ -37,7 +37,7 @@ public:<br>
bool &IsResolved) override;<br>
<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override;<br>
+ uint64_t Value, bool IsPCRel, MCContext &Ctx) const override;<br>
bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,<br>
const MCRelaxableFragment *DF,<br>
const MCAsmLayout &Layout) const override {<br>
@@ -131,7 +131,7 @@ void AMDGPUAsmBackend::<wbr>processFixupValue<br>
<br>
void AMDGPUAsmBackend::applyFixup(<wbr>const MCFixup &Fixup, char *Data,<br>
unsigned DataSize, uint64_t Value,<br>
- bool IsPCRel) const {<br>
+ bool IsPCRel, MCContext &Ctx) const {<br>
if (!Value)<br>
return; // Doesn't change encoding.<br>
<br>
<br>
Modified: llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/ARMAsmBackend.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>ARM/MCTargetDesc/<wbr>ARMAsmBackend.cpp?rev=299529&<wbr>r1=299528&r2=299529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/ARMAsmBackend.cpp (original)<br>
+++ llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/ARMAsmBackend.cpp Wed Apr 5 05:16:14 2017<br>
@@ -357,13 +357,13 @@ static uint32_t joinHalfWords(uint32_t F<br>
}<br>
<br>
unsigned ARMAsmBackend::<wbr>adjustFixupValue(const MCFixup &Fixup, uint64_t Value,<br>
- bool IsPCRel, MCContext *Ctx,<br>
+ bool IsPCRel, MCContext &Ctx,<br>
bool IsLittleEndian,<br>
bool IsResolved) const {<br>
unsigned Kind = Fixup.getKind();<br>
switch (Kind) {<br>
default:<br>
- if (Ctx) Ctx->reportError(Fixup.getLoc(<wbr>), "bad relocation fixup type");<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "bad relocation fixup type");<br>
return 0;<br>
case FK_Data_1:<br>
case FK_Data_2:<br>
@@ -413,8 +413,8 @@ unsigned ARMAsmBackend::<wbr>adjustFixupValue<br>
Value = -Value;<br>
isAdd = false;<br>
}<br>
- if (Ctx && Value >= 4096) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range pc-relative fixup value");<br>
+ if (Value >= 4096) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range pc-relative fixup value");<br>
return 0;<br>
}<br>
Value |= isAdd << 23;<br>
@@ -434,8 +434,8 @@ unsigned ARMAsmBackend::<wbr>adjustFixupValue<br>
Value = -Value;<br>
opc = 2; // 0b0010<br>
}<br>
- if (Ctx && ARM_AM::getSOImmVal(Value) == -1) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range pc-relative fixup value");<br>
+ if (ARM_AM::getSOImmVal(Value) == -1) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range pc-relative fixup value");<br>
return 0;<br>
}<br>
// Encode the immediate and shift the opcode into place.<br>
@@ -542,8 +542,8 @@ unsigned ARMAsmBackend::<wbr>adjustFixupValue<br>
//<br>
// Note that the halfwords are stored high first, low second; so we need<br>
// to transpose the fixup value here to map properly.<br>
- if (Ctx && Value % 4 != 0) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "misaligned ARM call destination");<br>
+ if (Value % 4 != 0) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "misaligned ARM call destination");<br>
return 0;<br>
}<br>
<br>
@@ -569,10 +569,10 @@ unsigned ARMAsmBackend::<wbr>adjustFixupValue<br>
case ARM::fixup_arm_thumb_cp:<br>
// On CPUs supporting Thumb2, this will be relaxed to an ldr.w, otherwise we<br>
// could have an error on our hands.<br>
- if (Ctx && !STI->getFeatureBits()[ARM::<wbr>FeatureThumb2] && IsResolved) {<br>
+ if (!STI->getFeatureBits()[ARM::<wbr>FeatureThumb2] && IsResolved) {<br>
const char *FixupDiagnostic = reasonForFixupRelaxation(<wbr>Fixup, Value);<br>
if (FixupDiagnostic) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), FixupDiagnostic);<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, FixupDiagnostic);<br>
return 0;<br>
}<br>
}<br>
@@ -582,8 +582,8 @@ unsigned ARMAsmBackend::<wbr>adjustFixupValue<br>
// CB instructions can only branch to offsets in [4, 126] in multiples of 2<br>
// so ensure that the raw value LSB is zero and it lies in [2, 130].<br>
// An offset of 2 will be relaxed to a NOP.<br>
- if (Ctx && ((int64_t)Value < 2 || Value > 0x82 || Value & 1)) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range pc-relative fixup value");<br>
+ if ((int64_t)Value < 2 || Value > 0x82 || Value & 1) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range pc-relative fixup value");<br>
return 0;<br>
}<br>
// Offset by 4 and don't encode the lower bit, which is always 0.<br>
@@ -593,21 +593,21 @@ unsigned ARMAsmBackend::<wbr>adjustFixupValue<br>
}<br>
case ARM::fixup_arm_thumb_br:<br>
// Offset by 4 and don't encode the lower bit, which is always 0.<br>
- if (Ctx && !STI->getFeatureBits()[ARM::<wbr>FeatureThumb2] &&<br>
- !STI->getFeatureBits()[ARM::<wbr>HasV8MBaselineOps]) {<br>
+ if (!STI->getFeatureBits()[ARM::<wbr>FeatureThumb2] &&<br>
+ !STI->getFeatureBits()[ARM::<wbr>HasV8MBaselineOps]) {<br>
const char *FixupDiagnostic = reasonForFixupRelaxation(<wbr>Fixup, Value);<br>
if (FixupDiagnostic) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), FixupDiagnostic);<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, FixupDiagnostic);<br>
return 0;<br>
}<br>
}<br>
return ((Value - 4) >> 1) & 0x7ff;<br>
case ARM::fixup_arm_thumb_bcc:<br>
// Offset by 4 and don't encode the lower bit, which is always 0.<br>
- if (Ctx && !STI->getFeatureBits()[ARM::<wbr>FeatureThumb2]) {<br>
+ if (!STI->getFeatureBits()[ARM::<wbr>FeatureThumb2]) {<br>
const char *FixupDiagnostic = reasonForFixupRelaxation(<wbr>Fixup, Value);<br>
if (FixupDiagnostic) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), FixupDiagnostic);<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, FixupDiagnostic);<br>
return 0;<br>
}<br>
}<br>
@@ -621,8 +621,8 @@ unsigned ARMAsmBackend::<wbr>adjustFixupValue<br>
isAdd = false;<br>
}<br>
// The value has the low 4 bits encoded in [3:0] and the high 4 in [11:8].<br>
- if (Ctx && Value >= 256) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range pc-relative fixup value");<br>
+ if (Value >= 256) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range pc-relative fixup value");<br>
return 0;<br>
}<br>
Value = (Value & 0xf) | ((Value & 0xf0) << 4);<br>
@@ -642,8 +642,8 @@ unsigned ARMAsmBackend::<wbr>adjustFixupValue<br>
}<br>
// These values don't encode the low two bits since they're always zero.<br>
Value >>= 2;<br>
- if (Ctx && Value >= 256) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range pc-relative fixup value");<br>
+ if (Value >= 256) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range pc-relative fixup value");<br>
return 0;<br>
}<br>
Value |= isAdd << 23;<br>
@@ -668,13 +668,13 @@ unsigned ARMAsmBackend::<wbr>adjustFixupValue<br>
isAdd = false;<br>
}<br>
// These values don't encode the low bit since it's always zero.<br>
- if (Ctx && (Value & 1)) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "invalid value for this fixup");<br>
+ if (Value & 1) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "invalid value for this fixup");<br>
return 0;<br>
}<br>
Value >>= 1;<br>
- if (Ctx && Value >= 256) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range pc-relative fixup value");<br>
+ if (Value >= 256) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range pc-relative fixup value");<br>
return 0;<br>
}<br>
Value |= isAdd << 23;<br>
@@ -688,8 +688,8 @@ unsigned ARMAsmBackend::<wbr>adjustFixupValue<br>
}<br>
case ARM::fixup_arm_mod_imm:<br>
Value = ARM_AM::getSOImmVal(Value);<br>
- if (Ctx && Value >> 12) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range immediate fixup value");<br>
+ if (Value >> 12) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range immediate fixup value");<br>
return 0;<br>
}<br>
return Value;<br>
@@ -738,12 +738,6 @@ void ARMAsmBackend::<wbr>processFixupValue(co<br>
(unsigned)Fixup.getKind() == ARM::fixup_arm_uncondbl ||<br>
(unsigned)Fixup.getKind() == ARM::fixup_arm_condbl))<br>
IsResolved = false;<br>
-<br>
- // Try to get the encoded value for the fixup as-if we're mapping it into<br>
- // the instruction. This allows adjustFixupValue() to issue a diagnostic<br>
- // if the value is invalid.<br>
- (void)adjustFixupValue(Fixup, Value, false, &Asm.getContext(),<br>
- IsLittleEndian, IsResolved);<br>
}<br>
<br>
/// getFixupKindNumBytes - The number of bytes the fixup may change.<br>
@@ -847,11 +841,10 @@ static unsigned getFixupKindContainerSiz<br>
}<br>
<br>
void ARMAsmBackend::applyFixup(<wbr>const MCFixup &Fixup, char *Data,<br>
- unsigned DataSize, uint64_t Value,<br>
- bool IsPCRel) const {<br>
+ unsigned DataSize, uint64_t Value, bool IsPCRel,<br>
+ MCContext &Ctx) const {<br>
unsigned NumBytes = getFixupKindNumBytes(Fixup.<wbr>getKind());<br>
- Value =<br>
- adjustFixupValue(Fixup, Value, IsPCRel, nullptr, IsLittleEndian, true);<br>
+ Value = adjustFixupValue(Fixup, Value, IsPCRel, Ctx, IsLittleEndian, true);<br>
if (!Value)<br>
return; // Doesn't change encoding.<br>
<br>
<br>
Modified: llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/ARMAsmBackend.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>ARM/MCTargetDesc/<wbr>ARMAsmBackend.h?rev=299529&r1=<wbr>299528&r2=299529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/ARMAsmBackend.h (original)<br>
+++ llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/ARMAsmBackend.h Wed Apr 5 05:16:14 2017<br>
@@ -46,11 +46,11 @@ public:<br>
bool &IsResolved) override;<br>
<br>
unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value, bool IsPCRel,<br>
- MCContext *Ctx, bool IsLittleEndian,<br>
+ MCContext &Ctx, bool IsLittleEndian,<br>
bool IsResolved) const;<br>
<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override;<br>
+ uint64_t Value, bool IsPCRel, MCContext &Ctx) const override;<br>
<br>
unsigned getRelaxedOpcode(unsigned Op) const;<br>
<br>
<br>
Modified: llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/<wbr>ARMELFObjectWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>ARM/MCTargetDesc/<wbr>ARMELFObjectWriter.cpp?rev=<wbr>299529&r1=299528&r2=299529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/<wbr>ARMELFObjectWriter.cpp (original)<br>
+++ llvm/trunk/lib/Target/ARM/<wbr>MCTargetDesc/<wbr>ARMELFObjectWriter.cpp Wed Apr 5 05:16:14 2017<br>
@@ -9,6 +9,7 @@<br>
<br>
#include "MCTargetDesc/ARMFixupKinds.h"<br>
#include "MCTargetDesc/ARMMCTargetDesc.<wbr>h"<br>
+#include "llvm/MC/MCContext.h"<br>
#include "llvm/MC/MCELFObjectWriter.h"<br>
#include "llvm/MC/MCExpr.h"<br>
#include "llvm/MC/MCFixup.h"<br>
@@ -25,9 +26,8 @@ namespace {<br>
class ARMELFObjectWriter : public MCELFObjectTargetWriter {<br>
enum { DefaultEABIVersion = 0x05000000U };<br>
<br>
- unsigned GetRelocTypeInner(const MCValue &Target,<br>
- const MCFixup &Fixup,<br>
- bool IsPCRel) const;<br>
+ unsigned GetRelocTypeInner(const MCValue &Target, const MCFixup &Fixup,<br>
+ bool IsPCRel, MCContext &Ctx) const;<br>
<br>
public:<br>
ARMELFObjectWriter(uint8_t OSABI);<br>
@@ -69,19 +69,20 @@ bool ARMELFObjectWriter::<wbr>needsRelocateWi<br>
unsigned ARMELFObjectWriter::<wbr>getRelocType(MCContext &Ctx, const MCValue &Target,<br>
const MCFixup &Fixup,<br>
bool IsPCRel) const {<br>
- return GetRelocTypeInner(Target, Fixup, IsPCRel);<br>
+ return GetRelocTypeInner(Target, Fixup, IsPCRel, Ctx);<br>
}<br>
<br>
unsigned ARMELFObjectWriter::<wbr>GetRelocTypeInner(const MCValue &Target,<br>
const MCFixup &Fixup,<br>
- bool IsPCRel) const {<br>
+ bool IsPCRel,<br>
+ MCContext &Ctx) const {<br>
MCSymbolRefExpr::VariantKind Modifier = Target.getAccessVariant();<br>
<br>
unsigned Type = 0;<br>
if (IsPCRel) {<br>
switch ((unsigned)Fixup.getKind()) {<br>
default:<br>
- report_fatal_error("<wbr>unsupported relocation on symbol");<br>
+ Ctx.reportFatalError(Fixup.<wbr>getLoc(), "unsupported relocation on symbol");<br>
return ELF::R_ARM_NONE;<br>
case FK_Data_4:<br>
switch (Modifier) {<br>
@@ -160,7 +161,7 @@ unsigned ARMELFObjectWriter::<wbr>GetRelocTyp<br>
} else {<br>
switch ((unsigned)Fixup.getKind()) {<br>
default:<br>
- report_fatal_error("<wbr>unsupported relocation on symbol");<br>
+ Ctx.reportFatalError(Fixup.<wbr>getLoc(), "unsupported relocation on symbol");<br>
return ELF::R_ARM_NONE;<br>
case FK_Data_1:<br>
switch (Modifier) {<br>
<br>
Modified: llvm/trunk/lib/Target/BPF/<wbr>MCTargetDesc/BPFAsmBackend.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>BPF/MCTargetDesc/<wbr>BPFAsmBackend.cpp?rev=299529&<wbr>r1=299528&r2=299529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/BPF/<wbr>MCTargetDesc/BPFAsmBackend.cpp (original)<br>
+++ llvm/trunk/lib/Target/BPF/<wbr>MCTargetDesc/BPFAsmBackend.cpp Wed Apr 5 05:16:14 2017<br>
@@ -28,7 +28,7 @@ public:<br>
~BPFAsmBackend() override = default;<br>
<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override;<br>
+ uint64_t Value, bool IsPCRel, MCContext &Ctx) const override;<br>
<br>
MCObjectWriter *createObjectWriter(raw_<wbr>pwrite_stream &OS) const override;<br>
<br>
@@ -62,8 +62,8 @@ bool BPFAsmBackend::writeNopData(<wbr>uint64_<br>
}<br>
<br>
void BPFAsmBackend::applyFixup(<wbr>const MCFixup &Fixup, char *Data,<br>
- unsigned DataSize, uint64_t Value,<br>
- bool IsPCRel) const {<br>
+ unsigned DataSize, uint64_t Value, bool IsPCRel,<br>
+ MCContext &Ctx) const {<br>
if (Fixup.getKind() == FK_SecRel_4 || Fixup.getKind() == FK_SecRel_8) {<br>
assert(Value == 0);<br>
} else if (Fixup.getKind() == FK_Data_4 || Fixup.getKind() == FK_Data_8) {<br>
<br>
Modified: llvm/trunk/lib/Target/Hexagon/<wbr>MCTargetDesc/<wbr>HexagonAsmBackend.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>Hexagon/MCTargetDesc/<wbr>HexagonAsmBackend.cpp?rev=<wbr>299529&r1=299528&r2=299529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/Hexagon/<wbr>MCTargetDesc/<wbr>HexagonAsmBackend.cpp (original)<br>
+++ llvm/trunk/lib/Target/Hexagon/<wbr>MCTargetDesc/<wbr>HexagonAsmBackend.cpp Wed Apr 5 05:16:14 2017<br>
@@ -402,7 +402,8 @@ public:<br>
/// data fragment, at the offset specified by the fixup and following the<br>
/// fixup kind as appropriate.<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t FixupValue, bool IsPCRel) const override {<br>
+ uint64_t FixupValue, bool IsPCRel,<br>
+ MCContext &Ctx) const override {<br>
<br>
// When FixupValue is 0 the relocation is external and there<br>
// is nothing for us to do.<br>
<br>
Modified: llvm/trunk/lib/Target/Lanai/<wbr>MCTargetDesc/LanaiAsmBackend.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>Lanai/MCTargetDesc/<wbr>LanaiAsmBackend.cpp?rev=<wbr>299529&r1=299528&r2=299529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/Lanai/<wbr>MCTargetDesc/LanaiAsmBackend.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/Target/Lanai/<wbr>MCTargetDesc/LanaiAsmBackend.<wbr>cpp Wed Apr 5 05:16:14 2017<br>
@@ -50,7 +50,7 @@ public:<br>
: MCAsmBackend(), OSType(OST) {}<br>
<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override;<br>
+ uint64_t Value, bool IsPCRel, MCContext &Ctx) const override;<br>
<br>
MCObjectWriter *createObjectWriter(raw_<wbr>pwrite_stream &OS) const override;<br>
<br>
@@ -90,7 +90,7 @@ bool LanaiAsmBackend::writeNopData(<wbr>uint6<br>
<br>
void LanaiAsmBackend::applyFixup(<wbr>const MCFixup &Fixup, char *Data,<br>
unsigned /*DataSize*/, uint64_t Value,<br>
- bool /*IsPCRel*/) const {<br>
+ bool /*IsPCRel*/, MCContext & /*Ctx*/) const {<br>
MCFixupKind Kind = Fixup.getKind();<br>
Value = adjustFixupValue(static_cast<<wbr>unsigned>(Kind), Value);<br>
<br>
<br>
Modified: llvm/trunk/lib/Target/Mips/<wbr>MCTargetDesc/MipsAsmBackend.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>Mips/MCTargetDesc/<wbr>MipsAsmBackend.cpp?rev=299529&<wbr>r1=299528&r2=299529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/Mips/<wbr>MCTargetDesc/MipsAsmBackend.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/Target/Mips/<wbr>MCTargetDesc/MipsAsmBackend.<wbr>cpp Wed Apr 5 05:16:14 2017<br>
@@ -34,7 +34,7 @@ using namespace llvm;<br>
<br>
// Prepare value for the target space for it<br>
static unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value,<br>
- MCContext *Ctx = nullptr) {<br>
+ MCContext &Ctx) {<br>
<br>
unsigned Kind = Fixup.getKind();<br>
<br>
@@ -74,8 +74,8 @@ static unsigned adjustFixupValue(const M<br>
// address range. Forcing a signed division because Value can be negative.<br>
Value = (int64_t)Value / 4;<br>
// We now check if Value can be encoded as a 16-bit signed immediate.<br>
- if (!isInt<16>(Value) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC16 fixup");<br>
+ if (!isInt<16>(Value)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC16 fixup");<br>
return 0;<br>
}<br>
break;<br>
@@ -84,8 +84,8 @@ static unsigned adjustFixupValue(const M<br>
// Forcing a signed division because Value can be negative.<br>
Value = (int64_t)Value / 4;<br>
// We now check if Value can be encoded as a 19-bit signed immediate.<br>
- if (!isInt<19>(Value) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC19 fixup");<br>
+ if (!isInt<19>(Value)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC19 fixup");<br>
return 0;<br>
}<br>
break;<br>
@@ -121,8 +121,8 @@ static unsigned adjustFixupValue(const M<br>
// Forcing a signed division because Value can be negative.<br>
Value = (int64_t) Value / 2;<br>
// We now check if Value can be encoded as a 7-bit signed immediate.<br>
- if (!isInt<7>(Value) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC7 fixup");<br>
+ if (!isInt<7>(Value)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC7 fixup");<br>
return 0;<br>
}<br>
break;<br>
@@ -131,8 +131,8 @@ static unsigned adjustFixupValue(const M<br>
// Forcing a signed division because Value can be negative.<br>
Value = (int64_t) Value / 2;<br>
// We now check if Value can be encoded as a 10-bit signed immediate.<br>
- if (!isInt<10>(Value) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC10 fixup");<br>
+ if (!isInt<10>(Value)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC10 fixup");<br>
return 0;<br>
}<br>
break;<br>
@@ -141,8 +141,8 @@ static unsigned adjustFixupValue(const M<br>
// Forcing a signed division because Value can be negative.<br>
Value = (int64_t)Value / 2;<br>
// We now check if Value can be encoded as a 16-bit signed immediate.<br>
- if (!isInt<16>(Value) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC16 fixup");<br>
+ if (!isInt<16>(Value)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC16 fixup");<br>
return 0;<br>
}<br>
break;<br>
@@ -150,21 +150,21 @@ static unsigned adjustFixupValue(const M<br>
// Forcing a signed division because Value can be negative.<br>
Value = (int64_t)Value / 8;<br>
// We now check if Value can be encoded as a 18-bit signed immediate.<br>
- if (!isInt<18>(Value) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC18 fixup");<br>
+ if (!isInt<18>(Value)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC18 fixup");<br>
return 0;<br>
}<br>
break;<br>
case Mips::fixup_MICROMIPS_PC18_S3:<br>
// Check alignment.<br>
- if ((Value & 7) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC18 fixup");<br>
+ if ((Value & 7)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC18 fixup");<br>
}<br>
// Forcing a signed division because Value can be negative.<br>
Value = (int64_t)Value / 8;<br>
// We now check if Value can be encoded as a 18-bit signed immediate.<br>
- if (!isInt<18>(Value) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC18 fixup");<br>
+ if (!isInt<18>(Value)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC18 fixup");<br>
return 0;<br>
}<br>
break;<br>
@@ -172,8 +172,8 @@ static unsigned adjustFixupValue(const M<br>
// Forcing a signed division because Value can be negative.<br>
Value = (int64_t) Value / 4;<br>
// We now check if Value can be encoded as a 21-bit signed immediate.<br>
- if (!isInt<21>(Value) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC21 fixup");<br>
+ if (!isInt<21>(Value)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC21 fixup");<br>
return 0;<br>
}<br>
break;<br>
@@ -181,8 +181,8 @@ static unsigned adjustFixupValue(const M<br>
// Forcing a signed division because Value can be negative.<br>
Value = (int64_t) Value / 4;<br>
// We now check if Value can be encoded as a 26-bit signed immediate.<br>
- if (!isInt<26>(Value) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC26 fixup");<br>
+ if (!isInt<26>(Value)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC26 fixup");<br>
return 0;<br>
}<br>
break;<br>
@@ -190,8 +190,8 @@ static unsigned adjustFixupValue(const M<br>
// Forcing a signed division because Value can be negative.<br>
Value = (int64_t)Value / 2;<br>
// We now check if Value can be encoded as a 26-bit signed immediate.<br>
- if (!isInt<26>(Value) && Ctx) {<br>
- Ctx->reportFatalError(Fixup.<wbr>getLoc(), "out of range PC26 fixup");<br>
+ if (!isInt<26>(Value)) {<br>
+ Ctx.reportFatalError(Fixup.<wbr>getLoc(), "out of range PC26 fixup");<br>
return 0;<br>
}<br>
break;<br>
@@ -199,8 +199,8 @@ static unsigned adjustFixupValue(const M<br>
// Forcing a signed division because Value can be negative.<br>
Value = (int64_t)Value / 2;<br>
// We now check if Value can be encoded as a 21-bit signed immediate.<br>
- if (!isInt<21>(Value) && Ctx) {<br>
- Ctx->reportError(Fixup.getLoc(<wbr>), "out of range PC21 fixup");<br>
+ if (!isInt<21>(Value)) {<br>
+ Ctx.reportError(Fixup.getLoc()<wbr>, "out of range PC21 fixup");<br>
return 0;<br>
}<br>
break;<br>
@@ -236,10 +236,10 @@ static unsigned calculateMMLEIndex(unsig<br>
/// data fragment, at the offset specified by the fixup and following the<br>
/// fixup kind as appropriate.<br>
void MipsAsmBackend::applyFixup(<wbr>const MCFixup &Fixup, char *Data,<br>
- unsigned DataSize, uint64_t Value,<br>
- bool IsPCRel) const {<br>
+ unsigned DataSize, uint64_t Value, bool IsPCRel,<br>
+ MCContext &Ctx) const {<br>
MCFixupKind Kind = Fixup.getKind();<br>
- Value = adjustFixupValue(Fixup, Value);<br>
+ Value = adjustFixupValue(Fixup, Value, Ctx);<br>
<br>
if (!Value)<br>
return; // Doesn't change encoding.<br>
@@ -471,24 +471,6 @@ bool MipsAsmBackend::writeNopData(<wbr>uint64<br>
return true;<br>
}<br>
<br>
-/// processFixupValue - Target hook to process the literal value of a fixup<br>
-/// if necessary.<br>
-void MipsAsmBackend::<wbr>processFixupValue(const MCAssembler &Asm,<br>
- const MCAsmLayout &Layout,<br>
- const MCFixup &Fixup,<br>
- const MCFragment *DF,<br>
- const MCValue &Target,<br>
- uint64_t &Value,<br>
- bool &IsResolved) {<br>
- // At this point we'll ignore the value returned by adjustFixupValue as<br>
- // we are only checking if the fixup can be applied correctly. We have<br>
- // access to MCContext from here which allows us to report a fatal error<br>
- // with *possibly* a source code location.<br>
- // The caller will also ignore any changes we make to Value<br>
- // (recordRelocation() overwrites it with it's own calculation).<br>
- (void)adjustFixupValue(Fixup, Value, &Asm.getContext());<br>
-}<br>
-<br>
// MCAsmBackend<br>
MCAsmBackend *llvm::<wbr>createMipsAsmBackendEL32(const Target &T,<br>
const MCRegisterInfo &MRI,<br>
<br>
Modified: llvm/trunk/lib/Target/Mips/<wbr>MCTargetDesc/MipsAsmBackend.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>Mips/MCTargetDesc/<wbr>MipsAsmBackend.h?rev=299529&<wbr>r1=299528&r2=299529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/Mips/<wbr>MCTargetDesc/MipsAsmBackend.h (original)<br>
+++ llvm/trunk/lib/Target/Mips/<wbr>MCTargetDesc/MipsAsmBackend.h Wed Apr 5 05:16:14 2017<br>
@@ -39,7 +39,7 @@ public:<br>
MCObjectWriter *createObjectWriter(raw_<wbr>pwrite_stream &OS) const override;<br>
<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override;<br>
+ uint64_t Value, bool IsPCRel, MCContext &Ctx) const override;<br>
<br>
Optional<MCFixupKind> getFixupKind(StringRef Name) const override;<br>
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;<br>
@@ -82,11 +82,6 @@ public:<br>
<br>
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;<br>
<br>
- void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,<br>
- const MCFixup &Fixup, const MCFragment *DF,<br>
- const MCValue &Target, uint64_t &Value,<br>
- bool &IsResolved) override;<br>
-<br>
}; // class MipsAsmBackend<br>
<br>
} // namespace<br>
<br>
Modified: llvm/trunk/lib/Target/PowerPC/<wbr>MCTargetDesc/PPCAsmBackend.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>PowerPC/MCTargetDesc/<wbr>PPCAsmBackend.cpp?rev=299529&<wbr>r1=299528&r2=299529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/PowerPC/<wbr>MCTargetDesc/PPCAsmBackend.cpp (original)<br>
+++ llvm/trunk/lib/Target/PowerPC/<wbr>MCTargetDesc/PPCAsmBackend.cpp Wed Apr 5 05:16:14 2017<br>
@@ -114,7 +114,7 @@ public:<br>
}<br>
<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override {<br>
+ uint64_t Value, bool IsPCRel, MCContext &Ctx) const override {<br>
Value = adjustFixupValue(Fixup.<wbr>getKind(), Value);<br>
if (!Value) return; // Doesn't change encoding.<br>
<br>
<br>
Modified: llvm/trunk/lib/Target/RISCV/<wbr>MCTargetDesc/RISCVAsmBackend.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>RISCV/MCTargetDesc/<wbr>RISCVAsmBackend.cpp?rev=<wbr>299529&r1=299528&r2=299529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/RISCV/<wbr>MCTargetDesc/RISCVAsmBackend.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/Target/RISCV/<wbr>MCTargetDesc/RISCVAsmBackend.<wbr>cpp Wed Apr 5 05:16:14 2017<br>
@@ -33,7 +33,7 @@ public:<br>
~RISCVAsmBackend() override {}<br>
<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override;<br>
+ uint64_t Value, bool IsPCRel, MCContext &Ctx) const override;<br>
<br>
MCObjectWriter *createObjectWriter(raw_<wbr>pwrite_stream &OS) const override;<br>
<br>
@@ -71,7 +71,7 @@ bool RISCVAsmBackend::writeNopData(<wbr>uint6<br>
<br>
void RISCVAsmBackend::applyFixup(<wbr>const MCFixup &Fixup, char *Data,<br>
unsigned DataSize, uint64_t Value,<br>
- bool IsPCRel) const {<br>
+ bool IsPCRel, MCContext &Ctx) const {<br>
return;<br>
}<br>
<br>
<br>
Modified: llvm/trunk/lib/Target/Sparc/<wbr>MCTargetDesc/SparcAsmBackend.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>Sparc/MCTargetDesc/<wbr>SparcAsmBackend.cpp?rev=<wbr>299529&r1=299528&r2=299529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/Sparc/<wbr>MCTargetDesc/SparcAsmBackend.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/Target/Sparc/<wbr>MCTargetDesc/SparcAsmBackend.<wbr>cpp Wed Apr 5 05:16:14 2017<br>
@@ -274,7 +274,8 @@ namespace {<br>
SparcAsmBackend(T), OSType(OSType) { }<br>
<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override {<br>
+ uint64_t Value, bool IsPCRel,<br>
+ MCContext &Ctx) const override {<br>
<br>
Value = adjustFixupValue(Fixup.<wbr>getKind(), Value);<br>
if (!Value) return; // Doesn't change encoding.<br>
<br>
Modified: llvm/trunk/lib/Target/SystemZ/<wbr>MCTargetDesc/<wbr>SystemZMCAsmBackend.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>SystemZ/MCTargetDesc/<wbr>SystemZMCAsmBackend.cpp?rev=<wbr>299529&r1=299528&r2=299529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/SystemZ/<wbr>MCTargetDesc/<wbr>SystemZMCAsmBackend.cpp (original)<br>
+++ llvm/trunk/lib/Target/SystemZ/<wbr>MCTargetDesc/<wbr>SystemZMCAsmBackend.cpp Wed Apr 5 05:16:14 2017<br>
@@ -51,7 +51,7 @@ public:<br>
}<br>
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override;<br>
+ uint64_t Value, bool IsPCRel, MCContext &Ctx) const override;<br>
bool mayNeedRelaxation(const MCInst &Inst) const override {<br>
return false;<br>
}<br>
@@ -91,7 +91,7 @@ SystemZMCAsmBackend::<wbr>getFixupKindInfo(MC<br>
<br>
void SystemZMCAsmBackend::<wbr>applyFixup(const MCFixup &Fixup, char *Data,<br>
unsigned DataSize, uint64_t Value,<br>
- bool IsPCRel) const {<br>
+ bool IsPCRel, MCContext &Ctx) const {<br>
MCFixupKind Kind = Fixup.getKind();<br>
unsigned Offset = Fixup.getOffset();<br>
unsigned BitSize = getFixupKindInfo(Kind).<wbr>TargetSize;<br>
<br>
Modified: llvm/trunk/lib/Target/X86/<wbr>MCTargetDesc/X86AsmBackend.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/Target/<wbr>X86/MCTargetDesc/<wbr>X86AsmBackend.cpp?rev=299529&<wbr>r1=299528&r2=299529&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Target/X86/<wbr>MCTargetDesc/X86AsmBackend.cpp (original)<br>
+++ llvm/trunk/lib/Target/X86/<wbr>MCTargetDesc/X86AsmBackend.cpp Wed Apr 5 05:16:14 2017<br>
@@ -109,7 +109,7 @@ public:<br>
}<br>
<br>
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,<br>
- uint64_t Value, bool IsPCRel) const override {<br>
+ uint64_t Value, bool IsPCRel, MCContext &Ctx) const override {<br>
unsigned Size = 1 << getFixupKindLog2Size(Fixup.<wbr>getKind());<br>
<br>
assert(Fixup.getOffset() + Size <= DataSize &&<br>
<br>
Modified: llvm/trunk/test/MC/ARM/quad-<wbr>relocation.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/quad-relocation.s?rev=299529&r1=299528&r2=299529&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/MC/<wbr>ARM/quad-relocation.s?rev=<wbr>299529&r1=299528&r2=299529&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/MC/ARM/quad-<wbr>relocation.s (original)<br>
+++ llvm/trunk/test/MC/ARM/quad-<wbr>relocation.s Wed Apr 5 05:16:14 2017<br>
@@ -4,6 +4,6 @@<br>
symbol:<br>
.quad(symbol)<br>
<br>
-@ CHECK: error: bad relocation fixup type<br>
+@ CHECK: error: unsupported relocation on symbol<br>
@ CHECK-NEXT: .quad(symbol)<br>
@ CHECK-NEXT: ^<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>