<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/CodeGen/LLVMTargetMachine.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>Overhaul the TargetMachine and LLVMTargetMachine Classes (#111234)</title>
<updated>2024-11-14T21:30:05+00:00</updated>
<author>
<name>Matin Raayai</name>
<email>30674652+matinraayai@users.noreply.github.com</email>
</author>
<published>2024-11-14T21:30:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=bb3f5e1fed7c6ba733b7f273e93f5d3930976185'/>
<id>bb3f5e1fed7c6ba733b7f273e93f5d3930976185</id>
<content type='text'>
Following discussions in #110443, and the following earlier discussions
in https://lists.llvm.org/pipermail/llvm-dev/2017-October/117907.html,
https://reviews.llvm.org/D38482, https://reviews.llvm.org/D38489, this
PR attempts to overhaul the `TargetMachine` and `LLVMTargetMachine`
interface classes. More specifically:
1. Makes `TargetMachine` the only class implemented under
`TargetMachine.h` in the `Target` library.
2. `TargetMachine` contains target-specific interface functions that
relate to IR/CodeGen/MC constructs, whereas before (at least on paper)
it was supposed to have only IR/MC constructs. Any Target that doesn't
want to use the independent code generator simply does not implement
them, and returns either `false` or `nullptr`.
3. Renames `LLVMTargetMachine` to `CodeGenCommonTMImpl`. This renaming
aims to make the purpose of `LLVMTargetMachine` clearer. Its interface
was moved under the CodeGen library, to further emphasis its usage in
Targets that use CodeGen directly.
4. Makes `TargetMachine` the only interface used across LLVM and its
projects. With these changes, `CodeGenCommonTMImpl` is simply a set of
shared function implementations of `TargetMachine`, and CodeGen users
don't need to static cast to `LLVMTargetMachine` every time they need a
CodeGen-specific feature of the `TargetMachine`.
5. More importantly, does not change any requirements regarding library
linking.

cc @arsenm @aeubanks</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Following discussions in #110443, and the following earlier discussions
in https://lists.llvm.org/pipermail/llvm-dev/2017-October/117907.html,
https://reviews.llvm.org/D38482, https://reviews.llvm.org/D38489, this
PR attempts to overhaul the `TargetMachine` and `LLVMTargetMachine`
interface classes. More specifically:
1. Makes `TargetMachine` the only class implemented under
`TargetMachine.h` in the `Target` library.
2. `TargetMachine` contains target-specific interface functions that
relate to IR/CodeGen/MC constructs, whereas before (at least on paper)
it was supposed to have only IR/MC constructs. Any Target that doesn't
want to use the independent code generator simply does not implement
them, and returns either `false` or `nullptr`.
3. Renames `LLVMTargetMachine` to `CodeGenCommonTMImpl`. This renaming
aims to make the purpose of `LLVMTargetMachine` clearer. Its interface
was moved under the CodeGen library, to further emphasis its usage in
Targets that use CodeGen directly.
4. Makes `TargetMachine` the only interface used across LLVM and its
projects. With these changes, `CodeGenCommonTMImpl` is simply a set of
shared function implementations of `TargetMachine`, and CodeGen users
don't need to static cast to `LLVMTargetMachine` every time they need a
CodeGen-specific feature of the `TargetMachine`.
5. More importantly, does not change any requirements regarding library
linking.

cc @arsenm @aeubanks</pre>
</div>
</content>
</entry>
<entry>
<title>[clang] Add cc1 --output-asm-variant= to set output syntax</title>
<updated>2024-09-24T22:59:33+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-09-24T22:59:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=4a9da96dc68d878893399210888a03117b39b802'/>
<id>4a9da96dc68d878893399210888a03117b39b802</id>
<content type='text'>
2fcaa549a824efeb56e807fcf750a56bf985296b (2010) added cc1as option
`-output-asm-variant` (untested) to set the output syntax.
`clang -cc1as -filetype asm -output-asm-variant 1` allows AT&amp;T input and
Intel output (`AssemblerDialect` is also used by non-x86 targets).

This patch renames the cc1as option (to avoid collision with -o) and
makes it available for cc1 to set output syntax. This allows different
input &amp; output syntax:

```
echo 'asm("mov $1, %eax");' | clang -xc - -S -o - -Xclang --output-asm-variant=1
```

Note: `AsmWriterFlavor` (with a misleading name), used to initialize
MCAsmInfo::AssemblerDialect, is primarily used for assembly input, not
for output.
Therefore,
`echo 'asm("mov $1, %eax");' | clang -x c - -mllvm --x86-asm-syntax=intel -S -o -`,
which achieves a similar goal before Clang 19, was unintended.

Close #109157

Pull Request: https://github.com/llvm/llvm-project/pull/109360
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
2fcaa549a824efeb56e807fcf750a56bf985296b (2010) added cc1as option
`-output-asm-variant` (untested) to set the output syntax.
`clang -cc1as -filetype asm -output-asm-variant 1` allows AT&amp;T input and
Intel output (`AssemblerDialect` is also used by non-x86 targets).

This patch renames the cc1as option (to avoid collision with -o) and
makes it available for cc1 to set output syntax. This allows different
input &amp; output syntax:

```
echo 'asm("mov $1, %eax");' | clang -xc - -S -o - -Xclang --output-asm-variant=1
```

Note: `AsmWriterFlavor` (with a misleading name), used to initialize
MCAsmInfo::AssemblerDialect, is primarily used for assembly input, not
for output.
Therefore,
`echo 'asm("mov $1, %eax");' | clang -x c - -mllvm --x86-asm-syntax=intel -S -o -`,
which achieves a similar goal before Clang 19, was unintended.

Close #109157

Pull Request: https://github.com/llvm/llvm-project/pull/109360
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix memory leak in LLVMTargetMachine.cpp (#109610)</title>
<updated>2024-09-23T09:11:56+00:00</updated>
<author>
<name>abhishek-kaushik22</name>
<email>abhishek.kaushik@intel.com</email>
</author>
<published>2024-09-23T09:11:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f28a0355364b9f09fa3d47720af4cf7431721de6'/>
<id>f28a0355364b9f09fa3d47720af4cf7431721de6</id>
<content type='text'>
Because `MAB` is a raw pointer, it could potentially leak memory because
of the `||` in the null check.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Because `MAB` is a raw pointer, it could potentially leak memory because
of the `||` in the null check.</pre>
</div>
</content>
</entry>
<entry>
<title>[MC] Migrate to new createAsmStreamer that avoids unused bool parameters</title>
<updated>2024-07-21T16:23:45+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-07-21T16:23:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=7f17b6b740bd49b84430a46b366381bfc8b74fb0'/>
<id>7f17b6b740bd49b84430a46b366381bfc8b74fb0</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[MC] MCAsmStreamer: use MCTargetOptions</title>
<updated>2024-07-21T05:57:01+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-07-21T05:57:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=52e79ed1e078f69103dcd9234c2494e7dd64b5f7'/>
<id>52e79ed1e078f69103dcd9234c2494e7dd64b5f7</id>
<content type='text'>
Some bool parameters duplicate MCTargetOptions and might cause
inconsistency/confusion.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Some bool parameters duplicate MCTargetOptions and might cause
inconsistency/confusion.
</pre>
</div>
</content>
</entry>
<entry>
<title>[MC] Remove unused bool arguments from createMCObjectStreamer callers</title>
<updated>2024-07-21T04:27:36+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-07-21T04:27:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b8220b986dcc8c5d0c44a125642009d8175fc11d'/>
<id>b8220b986dcc8c5d0c44a125642009d8175fc11d</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[MC] Remove unnecessary DWARFMustBeAtTheEnd check</title>
<updated>2024-07-20T17:43:52+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-07-20T17:43:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=aa86f4f18549583f9227276cd116dbaf5625aa78'/>
<id>aa86f4f18549583f9227276cd116dbaf5625aa78</id>
<content type='text'>
36a15cb975334403216e6145d4abece3026af17a introduced the
DWARFMustBeAtTheEnd check to ensure DWARF sections were placed after all
text sections to help avoid out-of-range branches for Darwin ARM. The
commit removed a Darwin ARM hack from
20e5f5ed7930efdf2bd34bf099f24ac88798c5ea (2009), likely due to a
no-longer-relevant assembler limitation.

However, this check is no longer relevant due to the following:

* Our CodeGen approach reliably places DWARF sections at the end.
* Darwin AArch32 is less relevant today.

Removing this check also addresses a minor clang cc1as crash that could
occur when text sections were placed after DWARF sections
(e9ad54b3ee905ea3a77c35ca7d6e843b2c552e0b (2015)).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
36a15cb975334403216e6145d4abece3026af17a introduced the
DWARFMustBeAtTheEnd check to ensure DWARF sections were placed after all
text sections to help avoid out-of-range branches for Darwin ARM. The
commit removed a Darwin ARM hack from
20e5f5ed7930efdf2bd34bf099f24ac88798c5ea (2009), likely due to a
no-longer-relevant assembler limitation.

However, this check is no longer relevant due to the following:

* Our CodeGen approach reliably places DWARF sections at the end.
* Darwin AArch32 is less relevant today.

Removing this check also addresses a minor clang cc1as crash that could
occur when text sections were placed after DWARF sections
(e9ad54b3ee905ea3a77c35ca7d6e843b2c552e0b (2015)).
</pre>
</div>
</content>
</entry>
<entry>
<title>[MC] Move AllowTemporaryLabels setting to MCContext::MCContext</title>
<updated>2024-06-12T23:42:58+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-06-12T23:42:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ca91538c9c6f5328f398ac849dcc4230824b007e'/>
<id>ca91538c9c6f5328f398ac849dcc4230824b007e</id>
<content type='text'>
Also delete `AllowTemporaryLabels = true` from MCContext::reset: when
llc supports -save-temp-labels in the next change, this assignment
should be removed to support -compile-twice.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Also delete `AllowTemporaryLabels = true` from MCContext::reset: when
llc supports -save-temp-labels in the next change, this assignment
should be removed to support -compile-twice.
</pre>
</div>
</content>
</entry>
<entry>
<title>[MC] Move CompressDebugSections/RelaxELFRelocations from TargetOptions/MCAsmInfo to MCTargetOptions</title>
<updated>2024-03-07T07:19:59+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2024-03-07T07:19:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a3319371970b599ef65ef1567c440fbdc3a330f4'/>
<id>a3319371970b599ef65ef1567c440fbdc3a330f4</id>
<content type='text'>
The convention is for such MC-specific options to reside in
MCTargetOptions. However, CompressDebugSections/RelaxELFRelocations do
not follow the convention: `CompressDebugSections` is defined in both
TargetOptions and MCAsmInfo and there is forwarding complexity.

Move the option to MCTargetOptions and hereby simplify the code. Rename
the misleading RelaxELFRelocations to X86RelaxRelocations. llvm-mc
-relax-relocations and llc -x86-relax-relocations can now be unified.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The convention is for such MC-specific options to reside in
MCTargetOptions. However, CompressDebugSections/RelaxELFRelocations do
not follow the convention: `CompressDebugSections` is defined in both
TargetOptions and MCAsmInfo and there is forwarding complexity.

Move the option to MCTargetOptions and hereby simplify the code. Rename
the misleading RelaxELFRelocations to X86RelaxRelocations. llvm-mc
-relax-relocations and llc -x86-relax-relocations can now be unified.
</pre>
</div>
</content>
</entry>
<entry>
<title>[PowerPC] Add an alias for -mregnames so that full register names used in assembly. (#70255)</title>
<updated>2023-11-06T17:30:19+00:00</updated>
<author>
<name>Stefan Pintilie</name>
<email>stefanp@ca.ibm.com</email>
</author>
<published>2023-11-06T17:30:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=423ad04c67b7fbe7c6a6b4e0591bff40844c6027'/>
<id>423ad04c67b7fbe7c6a6b4e0591bff40844c6027</id>
<content type='text'>
This option already exists on GCC and so it is being added to LLVM so
that we use the same option as them.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This option already exists on GCC and so it is being added to LLVM so
that we use the same option as them.</pre>
</div>
</content>
</entry>
</feed>
