diff options
author | Fangrui Song <i@maskray.me> | 2024-05-15 09:18:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-15 09:18:39 -0700 |
commit | 03c53c69a367008da689f0d2940e2197eb4a955c (patch) | |
tree | 3e90c01a80acab9f7c451844b4825bd79f2e883c /clang/tools/driver/cc1as_main.cpp | |
parent | 9bbefb7f600019c9d7025281132dd160729bfff2 (diff) | |
download | llvm-03c53c69a367008da689f0d2940e2197eb4a955c.zip llvm-03c53c69a367008da689f0d2940e2197eb4a955c.tar.gz llvm-03c53c69a367008da689f0d2940e2197eb4a955c.tar.bz2 |
[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
Diffstat (limited to 'clang/tools/driver/cc1as_main.cpp')
-rw-r--r-- | clang/tools/driver/cc1as_main.cpp | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp index 86afe22..4eb753a 100644 --- a/clang/tools/driver/cc1as_main.cpp +++ b/clang/tools/driver/cc1as_main.cpp @@ -576,9 +576,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts, Str.get()->emitZeros(1); } - // Assembly to object compilation should leverage assembly info. - Str->setUseAssemblerInfoForParsing(true); - bool Failed = false; std::unique_ptr<MCAsmParser> Parser( |