This is an archive of the discontinued LLVM Phabricator instance.

[crt] Stringize __USER_LABEL_PREFIX__ in asm strings
AbandonedPublic

Authored by barannikov88 on Mar 28 2023, 2:09 PM.

Details

Summary

__USER_LABEL_PREFIX__ is not a string (usually it is just _ if not
empty). It must be stringized for string concatenation to work.

Diff Detail

Event Timeline

barannikov88 created this revision.Mar 28 2023, 2:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 2:09 PM
Herald added a subscriber: Enna1. · View Herald Transcript
barannikov88 requested review of this revision.Mar 28 2023, 2:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 2:09 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
barannikov88 edited the summary of this revision. (Show Details)
MaskRay added a subscriber: MaskRay.EditedMar 28 2023, 2:36 PM

The code only makes sense for some ELF platforms, not Mach-O platforms where __USER_LABEL_PREFIX__ is (usually) _.
What platforms are you building the code with and seeing a problem?

If we want to make some changes, likely we should just remove __USER_LABEL_PREFIX__.

(I'll take a vacation until 2023-04-10, so I will probably not respond in time.)

The code only makes sense for some ELF platforms, not Mach-O platforms where __USER_LABEL_PREFIX__ is (usually) _.
What platforms are you building the code with and seeing a problem?

An out-of-tree target with an unusual combination ELF + non-empty __USER_LABEL_PREFIX__.
The prefix has only caused troubles; it will probably go away once I am able to build newlib using clang.

If we want to make some changes, likely we should just remove __USER_LABEL_PREFIX__.

I don't know much about the prefix, but I noticed that the same target may configure it differently depending on the target triple.
If you are sure this is always a no-op, I don't mind removing it. (I would still have to keep an extra _ for my target under #ifdef.)
Note that there is also builtins component using the same functionality, and it also looks like the prefix is always empty. Otherwise the bug would have been spotted earlier -- please see D147077.

The prefix has only caused troubles; it will probably go away once I am able to build newlib using clang.

Ah, no, it will have to stay.
Speaking in X86 terms:

eax:
  lea eax, [eax]

causes ambiguity. Same for my target. So the labels are prefixed with _.

barannikov88 planned changes to this revision.Mar 28 2023, 4:22 PM

Wait for D147093 resolution.

barannikov88 abandoned this revision.Mar 28 2023, 9:06 PM

Abandoned in favor of D147093.