This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix interaction between asm labels and inline builtins
ClosedPublic

Authored by serge-sans-paille on Sep 21 2022, 7:32 AM.

Details

Summary

One must pick the same name as the one referenced in CodeGenFunction when
generating .inline version of an inline builtin, otherwise they are not
correctly replaced.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2022, 7:32 AM
serge-sans-paille requested review of this revision.Sep 21 2022, 7:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2022, 7:32 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
serge-sans-paille added a reviewer: nikic.

(rebased on main branch)

Adding some more codegen reviewers. Can you add a release note for the fix?

clang/test/CodeGen/asm-label-inline-builtins.c
19–21

please be consistent wrt. the trailing open paren (.

Let's add a check for the declaration of @vprintf.inline?

clang/lib/CodeGen/CGExpr.cpp
5056–5057

I think you could use:

if (auto *A = FD->getAttr<AsmLabelAttr>())
  FDInlineName = A->getLabel().str();
else
  ...
efriedma added inline comments.Sep 21 2022, 12:01 PM
clang/lib/CodeGen/CGExpr.cpp
5057

This is throwing away the ".inline" suffix? Is that intentional?

Address reviews.

nickdesaulniers accepted this revision.Sep 21 2022, 3:08 PM

Please make sure to mark comments as "Done" in phab to help reviewers skip over stale feedback.

clang/lib/CodeGen/CGExpr.cpp
5055–5059

Might be able to DRY this up slightly more:

auto *A = FD->getAttr<AsmLabelAttr>();
StringRef Ident = A ? A->getLabel() : FD->getName();
std::string FDInlineName = (Ident + ".inline").str();
This revision is now accepted and ready to land.Sep 21 2022, 3:08 PM
serge-sans-paille marked 4 inline comments as done.Sep 22 2022, 12:25 AM
This revision was landed with ongoing or failed builds.Sep 22 2022, 12:25 AM
This revision was automatically updated to reflect the committed changes.