[lld] r272942 - Simplify *(x+y) to x[y]. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 16 12:48:07 PDT 2016
Author: ruiu
Date: Thu Jun 16 14:48:07 2016
New Revision: 272942
URL: http://llvm.org/viewvc/llvm-project?rev=272942&view=rev
Log:
Simplify *(x+y) to x[y]. NFC.
They are equivalent in C (and in C++ in this case).
Modified:
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=272942&r1=272941&r2=272942&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Jun 16 14:48:07 2016
@@ -824,11 +824,11 @@ void X86_64TargetInfo::relaxGotNoPic(uin
// 0x38 == 00 111 000 binary.
// We transfer reg2 to reg1 here as operand.
// See "2.1.3 ModR/M and SIB Bytes" (Vol. 2A 2-3).
- *(Loc - 1) = 0xc0 | (ModRm & 0x38) >> 3; // ModR/M byte.
+ Loc[-1] = 0xc0 | (ModRm & 0x38) >> 3; // ModR/M byte.
// Change opcode from TEST r/m64, r64 to TEST r/m64, imm32
// See "TEST-Logical Compare" (4-428 Vol. 2B).
- *(Loc - 2) = 0xf7;
+ Loc[-2] = 0xf7;
// Move R bit to the B bit in REX byte.
// REX byte is encoded as 0100WRXB, where
@@ -841,7 +841,7 @@ void X86_64TargetInfo::relaxGotNoPic(uin
// REX.B This 1-bit value is an extension to the MODRM.rm field or the
// SIB.base field.
// See "2.2.1.2 More on REX Prefix Fields " (2-8 Vol. 2A).
- *(Loc - 3) = (Rex & ~0x4) | (Rex & 0x4) >> 2;
+ Loc[-3] = (Rex & ~0x4) | (Rex & 0x4) >> 2;
relocateOne(Loc, R_X86_64_PC32, Val);
return;
}
@@ -852,7 +852,7 @@ void X86_64TargetInfo::relaxGotNoPic(uin
// Convert "binop foo at GOTPCREL(%rip), %reg" to "binop $foo, %reg".
// Logic is close to one for test instruction above, but we also
// write opcode extension here, see below for details.
- *(Loc - 1) = 0xc0 | (ModRm & 0x38) >> 3 | (Op & 0x3c); // ModR/M byte.
+ Loc[-1] = 0xc0 | (ModRm & 0x38) >> 3 | (Op & 0x3c); // ModR/M byte.
// Primary opcode is 0x81, opcode extension is one of:
// 000b = ADD, 001b is OR, 010b is ADC, 011b is SBB,
@@ -861,8 +861,8 @@ void X86_64TargetInfo::relaxGotNoPic(uin
// See "3.2 INSTRUCTIONS (A-M)" (Vol. 2A 3-15),
// "INSTRUCTION SET REFERENCE, N-Z" (Vol. 2B 4-1) for
// descriptions about each operation.
- *(Loc - 2) = 0x81;
- *(Loc - 3) = (Rex & ~0x4) | (Rex & 0x4) >> 2;
+ Loc[-2] = 0x81;
+ Loc[-3] = (Rex & ~0x4) | (Rex & 0x4) >> 2;
relocateOne(Loc, R_X86_64_PC32, Val);
}
@@ -872,7 +872,7 @@ void X86_64TargetInfo::relaxGot(uint8_t
// Convert mov foo at GOTPCREL(%rip), %reg to lea foo(%rip), %reg.
if (Op == 0x8b) {
- *(Loc - 2) = 0x8d;
+ Loc[-2] = 0x8d;
relocateOne(Loc, R_X86_64_PC32, Val);
return;
}
@@ -883,14 +883,14 @@ void X86_64TargetInfo::relaxGot(uint8_t
// ABI says we can convert call *foo at GOTPCREL(%rip) to nop call foo.
// Instead we convert to addr32 call foo, where addr32 is instruction
// prefix. That makes result expression to be a single instruction.
- *(Loc - 2) = 0x67; // addr32 prefix
- *(Loc - 1) = 0xe8; // call
+ Loc[-2] = 0x67; // addr32 prefix
+ Loc[-1] = 0xe8; // call
} else {
assert(ModRm == 0x25);
// Convert jmp *foo at GOTPCREL(%rip) to jmp foo nop.
// jmp doesn't return, so it is fine to use nop here, it is just a stub.
- *(Loc - 2) = 0xe9; // jmp
- *(Loc + 3) = 0x90; // nop
+ Loc[-2] = 0xe9; // jmp
+ Loc[3] = 0x90; // nop
Loc -= 1;
Val += 1;
}
More information about the llvm-commits
mailing list