[all-commits] [llvm/llvm-project] 03c53c: [MC] Remove UseAssemblerInfoForParsing

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed May 15 09:19:01 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 03c53c69a367008da689f0d2940e2197eb4a955c
      https://github.com/llvm/llvm-project/commit/03c53c69a367008da689f0d2940e2197eb4a955c
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-05-15 (Wed, 15 May 2024)

  Changed paths:
    M clang/tools/driver/cc1as_main.cpp
    M llvm/include/llvm/MC/MCStreamer.h
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
    M llvm/lib/MC/MCObjectStreamer.cpp
    M llvm/lib/MC/MCStreamer.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
    M llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
    M llvm/test/MC/AsmParser/assembler-expressions-inlineasm.ll
    M llvm/tools/llvm-mc/llvm-mc.cpp
    M llvm/tools/llvm-ml/llvm-ml.cpp

  Log Message:
  -----------
  [MC] Remove UseAssemblerInfoForParsing

Commit 6c0665e22174d474050e85ca367424f6e02476be
(https://reviews.llvm.org/D45164) enabled certain constant expression
evaluation for `MCObjectStreamer` at parse time (e.g. `.if` directives,
see llvm/test/MC/AsmParser/assembler-expressions.s).

`getUseAssemblerInfoForParsing` was added to make `clang -c` handling
inline assembly similar to `MCAsmStreamer` (e.g. `llvm-mc -filetype=asm`),
where such expression folding (related to
`AttemptToFoldSymbolOffsetDifference`) is unavailable.

I believe this is overly conservative. We can make some parse-time
expression folding work for `clang -c` even if `clang -S` would still
report an error, a MCAsmStreamer issue (we cannot print `.if`
directives) that should not restrict the functionality of
MCObjectStreamer.

```
% cat b.cc
asm(R"(
.pushsection .text,"ax"
.globl _start; _start: ret
.if . -_start == 1
  ret
.endif
.popsection
)");
% gcc -S b.cc && gcc -c b.cc
% clang -S -fno-integrated-as b.cc     # succeeded

% clang -c b.cc     # succeeded with this patch
% clang -S b.cc     # still failed
<inline asm>:4:5: error: expected absolute expression
    4 | .if . -_start == 1
      |     ^
1 error generated.
```

Close #62520
Link: https://discourse.llvm.org/t/rfc-clang-assembly-object-equivalence-for-files-with-inline-assembly/78841

Pull Request: https://github.com/llvm/llvm-project/pull/91082



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list