[llvm-bugs] [Bug 45720] New: Attribute "cold" not permitted on Blocks language extension
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Apr 28 15:28:31 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45720
Bug ID: 45720
Summary: Attribute "cold" not permitted on Blocks language
extension
Product: clang
Version: 10.0
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: cem at FreeBSD.org
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
It seems like block code is function-like enough that it makes sense to be able
to annotate the objects with __attribute__((cold)) (or hot). Currently this is
rejected by Basic/Attr.td due to Cold/Hot SubjectLists containing only
"Function." And I'm sure some support would be needed internally to actually
map hot/cold attributes to meaningful behavior internally.
My observation is that:
1. Blocks are useful for generating known-cold code via macros, such as in
assert or (conditional) debug-level log constructs.
2. Clang attempts to inline all blocks.
3. Even when blocks are not inlined, they are laid out adjacent to their parent
function in .text.
The desired behavior of cold-attribute Blocks is basically that the cold
attribute is passed down to the generated LLVM function corresponding to Block
invocation. This affects NeverInline (2) and perhaps code placement (3).
As a giant kludge for (3), it seems to work to use -ffunction-sections to put
non-inlined blocks in their own sections and carefully use a linker script to
place them far away from other code. I don't have any good workarounds for
(2).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200428/9c7d3b00/attachment.html>
More information about the llvm-bugs
mailing list