[PATCH] D44669: Use local symbols for creating .stack-size

ben via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 27 11:55:04 PDT 2018


bd1976llvm added a comment.

> Why are extra symbols *in the assembly* a problem? We normally don't print assembly

I suppose I like the assembly to look good :) I think that the first of the
following options reads nicely compared to the others:

      .globl _start
  _start:
      ret
      .section ".stack_sizes","", at progbits
      .quad _start
      .uleb128 10

      .globl _start
  _start:
  .L_start:
      ret
      .section ".stack_sizes","", at progbits
      .quad .L_start
      .uleb128 10

      .globl first
  first:
      ret
      .globl _start
  _start:
      ret
      .section ".stack_sizes","", at progbits
      .quad .text+10
      .uleb128 10



> Using local symbols means that we have only one place that has to implement the logic for using section symbols in relocations. I quite like the rule: CodeGen and user written assembly files use local symbols everywhere and the assembler optimizes that when possible.

This sounds like a sound design choice to me. (Although, I have to say that
as I'm more of a binary tools man than a compiler engineer, I actually hate
it when the assembler doesn't output exactly the object file I expect given
what I typed in.)

> Having said that, if you really find the assembly verbosity problematic, getFunctionBegin could return a section symbol when the current function is at the start of a section.

This would certainly remove the extra local symbols. I like the purity of
your design principle with where only the assembler lowers to use section
symbols though. I'm on the fence here so unless someone else chimes in I
think leaving MC as-is is fine with me.


https://reviews.llvm.org/D44669





More information about the llvm-commits mailing list