[all-commits] [llvm/llvm-project] 4c8927: [Mips][MC] AttemptToFoldSymbolOffsetDifference: re...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Aug 16 23:12:14 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4c89277095ee7cda3d20e0f5f18b384212069778
      https://github.com/llvm/llvm-project/commit/4c89277095ee7cda3d20e0f5f18b384212069778
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-08-16 (Wed, 16 Aug 2023)

  Changed paths:
    M llvm/lib/MC/MCExpr.cpp
    M llvm/test/CodeGen/Mips/micromips-b-range.ll
    M llvm/test/CodeGen/Mips/micromips-gcc-except-table.ll
    M llvm/test/DebugInfo/Mips/eh_frame.ll

  Log Message:
  -----------
  [Mips][MC] AttemptToFoldSymbolOffsetDifference: revert isMicroMips special case

D52985/D57677 added a .gcc_except_table workaround, but the new behavior
doesn't match GNU assembler.
```
void foo();
int bar() {
  foo();
  try { throw 1; }
  catch (int) { return 1; }
  return 0;
}

clang --target=mipsel-linux-gnu -mmicromips -S a.cc
mipsel-linux-gnu-gcc -mmicromips -c a.s -o gnu.o

.uleb128 ($cst_end0)-($cst_begin0)     // bit 0 is not forced to 1
.uleb128 ($func_begin0)-($func_begin0) // bit 0 is not forced to 1
```

I have inspected `.gcc_except_table` output by `mipsel-linux-gnu-gcc -mmicromips -c a.cc`.
The `.uleb128` values are not forced to set the least significant bit.

In addition, D57677's adjustment (even->odd) to CodeGen/Mips/micromips-b-range.ll is wrong.
PC-relative `.long func - .` values will differ from GNU assembler as well.

The original intention of D52985 seems unclear to me. I think whatever
goal it wants to achieve should be moved to an upper layer.

This isMicroMips special case has caused problems to fix MCAssembler::relaxLEB to use evaluateAsAbsolute instead of evaluateKnownAbsolute,
which is needed to proper support R_RISCV_SET_ULEB128/R_RISCV_SUB_ULEB128.

Differential Revision: https://reviews.llvm.org/D157655




More information about the All-commits mailing list