[lld] r272915 - Early return. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 11:29:00 PDT 2016


Yup. I'd think I prefer this style for this code. I thought I would use
switch but chose to use `if` since we only have two if's.

On Thu, Jun 16, 2016 at 11:15 AM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
> On Thu, Jun 16, 2016 at 9:40 AM, Rui Ueyama via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: ruiu
>> Date: Thu Jun 16 11:40:36 2016
>> New Revision: 272915
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=272915&view=rev
>> Log:
>> Early return. NFC.
>>
>> 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=272915&r1=272914&r2=272915&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/ELF/Target.cpp (original)
>> +++ lld/trunk/ELF/Target.cpp Thu Jun 16 11:40:36 2016
>> @@ -1414,20 +1414,19 @@ void AArch64TargetInfo::relaxTlsIeToLe(u
>>                                         uint64_t Val) const {
>>    checkUInt<32>(Val, Type);
>>
>> -  uint32_t Inst = read32le(Loc);
>> -  uint32_t NewInst;
>>    if (Type == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21) {
>> -    // Generate movz.
>> -    unsigned RegNo = (Inst & 0x1f);
>> -    NewInst = (0xd2a00000 | RegNo) | (((Val >> 16) & 0xffff) << 5);
>> -  } else if (Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC) {
>> -    // Generate movk
>> -    unsigned RegNo = (Inst & 0x1f);
>> -    NewInst = (0xf2800000 | RegNo) | ((Val & 0xffff) << 5);
>> -  } else {
>> -    llvm_unreachable("invalid Relocation for TLS IE to LE Relax");
>> +    // Generate MOVZ.
>> +    uint32_t RegNo = read32le(Loc) & 0x1f;
>> +    write32le(Loc, (0xd2a00000 | RegNo) | (((Val >> 16) & 0xffff) << 5));
>> +    return;
>>    }
>> -  write32le(Loc, NewInst);
>> +  if (Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC) {
>> +    // Generate MOVK.
>> +    uint32_t RegNo = read32le(Loc) & 0x1f;
>> +    write32le(Loc, (0xf2800000 | RegNo) | ((Val & 0xffff) << 5));
>> +    return;
>> +  }
>> +  llvm_unreachable("invalid relocation for TLS IE to LE relaxation");
>>
>
> Generally we try not to branch-to-unreachable (which this unreachable sort
> of is) & instead assert the inverse condition (replace the above 'if' with
> an assert). But I realize that symmetry (if the code is a series of if
> conditions) may be valuable & that's OK if you prefer it that way - just
> thought I'd mention in case it suited.
>
> - Dave
>
>
>>  }
>>
>>  // Implementing relocations for AMDGPU is low priority since most
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160616/5b3f3de8/attachment.html>


More information about the llvm-commits mailing list