Skip to content

Commit 38348fa

Browse files
committed
AArch64: treat MC expressions as 2s complement arithmetic.
We had a couple of over-zealous diagnostics that meant IR with a reasonable and valid interpretation was rejected.
1 parent 7d01bb8 commit 38348fa

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,6 @@ static unsigned AdrImmBits(unsigned Value) {
154154
return (hi19 << 5) | (lo2 << 29);
155155
}
156156

157-
static bool valueFitsIntoFixupKind(unsigned Kind, uint64_t Value) {
158-
unsigned NumBits;
159-
switch(Kind) {
160-
case FK_Data_1: NumBits = 8; break;
161-
case FK_Data_2: NumBits = 16; break;
162-
case FK_Data_4: NumBits = 32; break;
163-
case FK_Data_8: NumBits = 64; break;
164-
default: return true;
165-
}
166-
return isUIntN(NumBits, Value) ||
167-
isIntN(NumBits, static_cast<int64_t>(Value));
168-
}
169-
170157
static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
171158
uint64_t Value, MCContext &Ctx,
172159
const Triple &TheTriple, bool IsResolved) {
@@ -341,9 +328,6 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
341328
case FK_Data_2:
342329
case FK_Data_4:
343330
case FK_Data_8:
344-
if (!valueFitsIntoFixupKind(Fixup.getTargetKind(), Value))
345-
Ctx.reportError(Fixup.getLoc(), "fixup value too large for data type!");
346-
LLVM_FALLTHROUGH;
347331
case FK_SecRel_2:
348332
case FK_SecRel_4:
349333
return Value;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: llc -mtriple=arm64-apple-ios %s -filetype=obj -o - | llvm-objdump --macho --section __DATA,__data - | FileCheck %s
2+
3+
; CHECK: Contents of (__DATA,__data) section
4+
; CHECK: 0000002a 59ed145d
5+
@other = global i32 42
6+
@var = global i32 sub(i32 646102975,
7+
i32 add (i32 trunc(i64 sub(i64 ptrtoint(i32* @var to i64),
8+
i64 ptrtoint(i32* @other to i64)) to i32),
9+
i32 3432360802))

0 commit comments

Comments
 (0)