<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Support/MemoryBuffer.cpp, branch users/nico/python-1</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>[SystemZ][z/OS] Refactor AutoConvert.h to remove large MVS guard (#143174)</title>
<updated>2025-06-11T19:26:49+00:00</updated>
<author>
<name>Abhina Sree</name>
<email>Abhina.Sreeskantharajan@ibm.com</email>
</author>
<published>2025-06-11T19:26:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=22fd11fe66a0d64f5ef359e21ae67a7d40936eaf'/>
<id>22fd11fe66a0d64f5ef359e21ae67a7d40936eaf</id>
<content type='text'>
This AutoConvert.h header frequently gets mislabeled as an unused
include because it is guarded by MVS internally and every usage is also
guarded. This refactors the change to remove this guard and instead make
these functions a noop on other non-z/OS platforms.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This AutoConvert.h header frequently gets mislabeled as an unused
include because it is guarded by MVS internally and every usage is also
guarded. This refactors the change to remove this guard and instead make
these functions a noop on other non-z/OS platforms.</pre>
</div>
</content>
</entry>
<entry>
<title>[SystemZ][z/OS] Update autoconversion functions to improve support for UTF-8 (#98652)</title>
<updated>2024-12-11T12:46:51+00:00</updated>
<author>
<name>Abhina Sree</name>
<email>Abhina.Sreeskantharajan@ibm.com</email>
</author>
<published>2024-12-11T12:46:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=04379c98638ac3901257b5fa319f9ece828af767'/>
<id>04379c98638ac3901257b5fa319f9ece828af767</id>
<content type='text'>
This fixes the following error when reading source and header files on
z/OS: error: source file is not valid UTF-8</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes the following error when reading source and header files on
z/OS: error: source file is not valid UTF-8</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] Remove unused includes (NFC) (#116752)</title>
<updated>2024-11-20T14:51:43+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2024-11-20T14:51:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d44ea7186befe38eb2b3804b15cd1ee1777458ed'/>
<id>d44ea7186befe38eb2b3804b15cd1ee1777458ed</id>
<content type='text'>
Identified with misc-include-cleaner.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Identified with misc-include-cleaner.</pre>
</div>
</content>
</entry>
<entry>
<title>[NFC][SystemZ][z/OS] Rename autoconversion-related functions to be less generic (#107399)</title>
<updated>2024-09-05T17:25:06+00:00</updated>
<author>
<name>Abhina Sree</name>
<email>Abhina.Sreeskantharajan@ibm.com</email>
</author>
<published>2024-09-05T17:25:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=311ac6381649fa0f7cc495db8fa697d6a9b43988'/>
<id>311ac6381649fa0f7cc495db8fa697d6a9b43988</id>
<content type='text'>
This patch renames the functions in AutoConvert.h/cpp to have a less
generic name because they are z/OS specific.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch renames the functions in AutoConvert.h/cpp to have a less
generic name because they are z/OS specific.</pre>
</div>
</content>
</entry>
<entry>
<title>Correct mismatched allocation/deallocation calls</title>
<updated>2024-05-15T16:36:19+00:00</updated>
<author>
<name>Aaron Ballman</name>
<email>aaron@aaronballman.com</email>
</author>
<published>2024-05-15T16:33:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3f954f575156bce8ac81d6b4d94de443786befed'/>
<id>3f954f575156bce8ac81d6b4d94de443786befed</id>
<content type='text'>
This amends dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6 because ASAN
caught an issue where the allocation and deallocation were not properly
paired: https://lab.llvm.org/buildbot/#/builders/239/builds/7001

Use malloc and free throughout this file to ensure that all kinds of
memory buffers use the proper pairing.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This amends dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6 because ASAN
caught an issue where the allocation and deallocation were not properly
paired: https://lab.llvm.org/buildbot/#/builders/239/builds/7001

Use malloc and free throughout this file to ensure that all kinds of
memory buffers use the proper pairing.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] Use malloc instead of non-throwing new (#92157)</title>
<updated>2024-05-15T14:55:34+00:00</updated>
<author>
<name>Aaron Ballman</name>
<email>aaron@aaronballman.com</email>
</author>
<published>2024-05-15T14:55:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6'/>
<id>dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6</id>
<content type='text'>
When allocating a memory buffer, we use a non-throwing new so that we
can explicitly handle memory buffers that are too large to fit into
memory. However, when exceptions are disabled, LLVM installs a custom
new handler

(https://github.com/llvm/llvm-project/blob/90109d444839683b09f0aafdc50b749cb4b3203b/llvm/lib/Support/InitLLVM.cpp#L61)
that explicitly crashes when we run out of memory

(https://github.com/llvm/llvm-project/blob/de14b749fee41d4ded711e771e43043ae3100cb3/llvm/lib/Support/ErrorHandling.cpp#L188)
and that means this particular out-of-memory situation cannot be
gracefully handled.

This was discovered while working on #embed
(https://github.com/llvm/llvm-project/pull/68620) on Windows and
resulted in a crash rather than the preprocessor issuing a diagnostic as
expected.

This patch switches away from the non-throwing new to a call to malloc
(and free), which will return a null pointer without calling a custom
new handler. It is the only instance in Clang or LLVM that I could find
which used a non-throwing new, so I did not think we would need anything
more involved than this change.

Testing this would be highly platform dependent and so it does not come
with test coverage. And because it doesn't change behavior that users
are likely to be able to observe, it does not come with a release note.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When allocating a memory buffer, we use a non-throwing new so that we
can explicitly handle memory buffers that are too large to fit into
memory. However, when exceptions are disabled, LLVM installs a custom
new handler

(https://github.com/llvm/llvm-project/blob/90109d444839683b09f0aafdc50b749cb4b3203b/llvm/lib/Support/InitLLVM.cpp#L61)
that explicitly crashes when we run out of memory

(https://github.com/llvm/llvm-project/blob/de14b749fee41d4ded711e771e43043ae3100cb3/llvm/lib/Support/ErrorHandling.cpp#L188)
and that means this particular out-of-memory situation cannot be
gracefully handled.

This was discovered while working on #embed
(https://github.com/llvm/llvm-project/pull/68620) on Windows and
resulted in a crash rather than the preprocessor issuing a diagnostic as
expected.

This patch switches away from the non-throwing new to a call to malloc
(and free), which will return a null pointer without calling a custom
new handler. It is the only instance in Clang or LLVM that I could find
which used a non-throwing new, so I did not think we would need anything
more involved than this change.

Testing this would be highly platform dependent and so it does not come
with test coverage. And because it doesn't change behavior that users
are likely to be able to observe, it does not come with a release note.</pre>
</div>
</content>
</entry>
<entry>
<title>[Support][MemBuffer] Prevent UB on empty StringRefs</title>
<updated>2023-03-14T11:58:37+00:00</updated>
<author>
<name>Kadir Cetinkaya</name>
<email>kadircet@google.com</email>
</author>
<published>2023-02-24T08:36:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=710983ab540fa372e846d47e9fa80b7d8b96afb1'/>
<id>710983ab540fa372e846d47e9fa80b7d8b96afb1</id>
<content type='text'>
Empty StringRefs are usually identified by their length being zero, and
sometimes they'll have Data==nullptr (e.g. default constructed, or derived from
an operation like split/copy and result turned out to be empty).

If such StringRef objects are passed to llvm::MemoryBuffer::getMemBufferCopy,
it'll result in UB as neither src nor dst can be null, even if size is zero.

This patch prevents that UB by not issuing a copy whenever StringRef is empty.

Differential Revision: https://reviews.llvm.org/D144706
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Empty StringRefs are usually identified by their length being zero, and
sometimes they'll have Data==nullptr (e.g. default constructed, or derived from
an operation like split/copy and result turned out to be empty).

If such StringRef objects are passed to llvm::MemoryBuffer::getMemBufferCopy,
it'll result in UB as neither src nor dst can be null, even if size is zero.

This patch prevents that UB by not issuing a copy whenever StringRef is empty.

Differential Revision: https://reviews.llvm.org/D144706
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] llvm::Optional =&gt; std::optional</title>
<updated>2022-12-16T08:49:10+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2022-12-16T08:49:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b1df3a2c0b6a42570042934cb79ca0e4359f863b'/>
<id>b1df3a2c0b6a42570042934cb79ca0e4359f863b</id>
<content type='text'>
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
</pre>
</div>
</content>
</entry>
<entry>
<title>Cache memory buffer's name length</title>
<updated>2022-12-01T08:38:16+00:00</updated>
<author>
<name>serge-sans-paille</name>
<email>sguelton@mozilla.com</email>
</author>
<published>2022-11-23T06:45:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=37048d04d8eefd24af4871bd9428f389eaad0abe'/>
<id>37048d04d8eefd24af4871bd9428f389eaad0abe</id>
<content type='text'>
This avoids repeated calls to strlen while we already know its value.

When preprocessing sqlite3.c, this gives a surprising 2% speedup.

Full benchmark available here:

https://llvm-compile-time-tracker.com/compare.php?from=d14c2d408dccd8c6defa7d151e9a96be3cac8cc3&amp;to=04f0641c1cbdcd0bdbd11cd910ca6091420bf52e&amp;stat=instructions:u

Recommit 1824432174b3166b40bce59477beb5821170748e, with restored '\0' at the end of buffer name.

Differential Revision: https://reviews.llvm.org/D138555
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This avoids repeated calls to strlen while we already know its value.

When preprocessing sqlite3.c, this gives a surprising 2% speedup.

Full benchmark available here:

https://llvm-compile-time-tracker.com/compare.php?from=d14c2d408dccd8c6defa7d151e9a96be3cac8cc3&amp;to=04f0641c1cbdcd0bdbd11cd910ca6091420bf52e&amp;stat=instructions:u

Recommit 1824432174b3166b40bce59477beb5821170748e, with restored '\0' at the end of buffer name.

Differential Revision: https://reviews.llvm.org/D138555
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Cache memory buffer's name length"</title>
<updated>2022-11-29T13:22:52+00:00</updated>
<author>
<name>Florian Hahn</name>
<email>flo@fhahn.com</email>
</author>
<published>2022-11-29T13:22:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=dcac5a2f7a58f6c66520a1147c0bf3d24177c30b'/>
<id>dcac5a2f7a58f6c66520a1147c0bf3d24177c30b</id>
<content type='text'>
This reverts commit 1824432174b3166b40bce59477beb5821170748e.

The change triggers an assertion when building clang on macOS:

FAILED: tools/clang/include/clang/Tooling/Syntax/Nodes.inc
cd /Users/florianhahn/projects/llvm-project/builds/release-with-assertions/ccache-stage1 &amp;&amp; /Users/florianhahn/projects/llvm-project/builds/release-with-assertions/ccache-stage1/bin/clang-tblgen -gen-clang-syntax-node-list -I /Users/florianhahn/projects/llvm-project/clang/include/clang/Tooling/Syntax -I/Users/florianhahn/projects/llvm-project/clang/include -I/Users/florianhahn/projects/llvm-project/builds/release-with-assertions/ccache-stage1/tools/clang/include -I/Users/florianhahn/projects/llvm-project/builds/release-with-assertions/ccache-stage1/include -I/Users/florianhahn/projects/llvm-project/llvm/include /Users/florianhahn/projects/llvm-project/clang/include/clang/Tooling/Syntax/Nodes.td --write-if-changed -o tools/clang/include/clang/Tooling/Syntax/Nodes.inc -d tools/clang/include/clang/Tooling/Syntax/Nodes.inc.d
Assertion failed: ((!RequiresNullTerminator || BufEnd[0] == 0) &amp;&amp; "Buffer is not null terminated!"), function init, file MemoryBuffer.cpp, line 52.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clang-tblgen             0x000000010466b68c llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) + 56
1  clang-tblgen             0x000000010466a808 llvm::sys::RunSignalHandlers() + 64
2  clang-tblgen             0x000000010466bd60 SignalHandler(int) + 344
3  libsystem_platform.dylib 0x00000001877a92a4 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018777acec pthread_kill + 288
5  libsystem_c.dylib        0x00000001876b42c8 abort + 180
6  libsystem_c.dylib        0x00000001876b3620 err + 0
7  clang-tblgen             0x00000001046ce150 llvm::ErrorOr&lt;std::__1::unique_ptr&lt;llvm::MemoryBuffer, std::__1::default_delete&lt;llvm::MemoryBuffer&gt;&gt;&gt; getOpenFileImpl&lt;llvm::MemoryBuffer&gt;(int, llvm::Twine const&amp;, unsigned long long, unsigned long long, long long, bool, bool, llvm::Optional&lt;llvm::Align&gt;) (.cold.1) + 0
8  clang-tblgen             0x000000010464a548 llvm::WritableMemoryBuffer::getNewUninitMemBuffer(unsigned long, llvm::Twine const&amp;, llvm::Optional&lt;llvm::Align&gt;) + 496
9  clang-tblgen             0x000000010464a7a0 llvm::ErrorOr&lt;std::__1::unique_ptr&lt;llvm::MemoryBuffer, std::__1::default_delete&lt;llvm::MemoryBuffer&gt;&gt;&gt; getOpenFileImpl&lt;llvm::MemoryBuffer&gt;(int, llvm::Twine const&amp;, unsigned long long, unsigned long long, long long, bool, bool, llvm::Optional&lt;llvm::Align&gt;) + 528
10 clang-tblgen             0x000000010464a254 llvm::ErrorOr&lt;std::__1::unique_ptr&lt;llvm::MemoryBuffer, std::__1::default_delete&lt;llvm::MemoryBuffer&gt;&gt;&gt; getFileAux&lt;llvm::MemoryBuffer&gt;(llvm::Twine const&amp;, unsigned long long, unsigned long long, bool, bool, bool, llvm::Optional&lt;llvm::Align&gt;) + 176
11 clang-tblgen             0x000000010466fbbc llvm::TableGenMain(char const*, bool (*)(llvm::raw_ostream&amp;, llvm::RecordKeeper&amp;)) + 1428
12 clang-tblgen             0x0000000104626114 main + 156
13 dyld                     0x0000000187453e50 start + 2544
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 1824432174b3166b40bce59477beb5821170748e.

The change triggers an assertion when building clang on macOS:

FAILED: tools/clang/include/clang/Tooling/Syntax/Nodes.inc
cd /Users/florianhahn/projects/llvm-project/builds/release-with-assertions/ccache-stage1 &amp;&amp; /Users/florianhahn/projects/llvm-project/builds/release-with-assertions/ccache-stage1/bin/clang-tblgen -gen-clang-syntax-node-list -I /Users/florianhahn/projects/llvm-project/clang/include/clang/Tooling/Syntax -I/Users/florianhahn/projects/llvm-project/clang/include -I/Users/florianhahn/projects/llvm-project/builds/release-with-assertions/ccache-stage1/tools/clang/include -I/Users/florianhahn/projects/llvm-project/builds/release-with-assertions/ccache-stage1/include -I/Users/florianhahn/projects/llvm-project/llvm/include /Users/florianhahn/projects/llvm-project/clang/include/clang/Tooling/Syntax/Nodes.td --write-if-changed -o tools/clang/include/clang/Tooling/Syntax/Nodes.inc -d tools/clang/include/clang/Tooling/Syntax/Nodes.inc.d
Assertion failed: ((!RequiresNullTerminator || BufEnd[0] == 0) &amp;&amp; "Buffer is not null terminated!"), function init, file MemoryBuffer.cpp, line 52.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clang-tblgen             0x000000010466b68c llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) + 56
1  clang-tblgen             0x000000010466a808 llvm::sys::RunSignalHandlers() + 64
2  clang-tblgen             0x000000010466bd60 SignalHandler(int) + 344
3  libsystem_platform.dylib 0x00000001877a92a4 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018777acec pthread_kill + 288
5  libsystem_c.dylib        0x00000001876b42c8 abort + 180
6  libsystem_c.dylib        0x00000001876b3620 err + 0
7  clang-tblgen             0x00000001046ce150 llvm::ErrorOr&lt;std::__1::unique_ptr&lt;llvm::MemoryBuffer, std::__1::default_delete&lt;llvm::MemoryBuffer&gt;&gt;&gt; getOpenFileImpl&lt;llvm::MemoryBuffer&gt;(int, llvm::Twine const&amp;, unsigned long long, unsigned long long, long long, bool, bool, llvm::Optional&lt;llvm::Align&gt;) (.cold.1) + 0
8  clang-tblgen             0x000000010464a548 llvm::WritableMemoryBuffer::getNewUninitMemBuffer(unsigned long, llvm::Twine const&amp;, llvm::Optional&lt;llvm::Align&gt;) + 496
9  clang-tblgen             0x000000010464a7a0 llvm::ErrorOr&lt;std::__1::unique_ptr&lt;llvm::MemoryBuffer, std::__1::default_delete&lt;llvm::MemoryBuffer&gt;&gt;&gt; getOpenFileImpl&lt;llvm::MemoryBuffer&gt;(int, llvm::Twine const&amp;, unsigned long long, unsigned long long, long long, bool, bool, llvm::Optional&lt;llvm::Align&gt;) + 528
10 clang-tblgen             0x000000010464a254 llvm::ErrorOr&lt;std::__1::unique_ptr&lt;llvm::MemoryBuffer, std::__1::default_delete&lt;llvm::MemoryBuffer&gt;&gt;&gt; getFileAux&lt;llvm::MemoryBuffer&gt;(llvm::Twine const&amp;, unsigned long long, unsigned long long, bool, bool, bool, llvm::Optional&lt;llvm::Align&gt;) + 176
11 clang-tblgen             0x000000010466fbbc llvm::TableGenMain(char const*, bool (*)(llvm::raw_ostream&amp;, llvm::RecordKeeper&amp;)) + 1428
12 clang-tblgen             0x0000000104626114 main + 156
13 dyld                     0x0000000187453e50 start + 2544
</pre>
</div>
</content>
</entry>
</feed>
