This is an archive of the discontinued LLVM Phabricator instance.

IR: Give function GlobalValue::getRealLinkageName() a less misleading name: getPGOName().
ClosedPublic

Authored by pcc on May 12 2017, 8:19 PM.

Details

Summary

This function gives the wrong answer on some non-ELF platforms in some
cases. The function that does the right thing lives in Mangler.h. To try to
discourage people from using this function, give it a different name.

Yes, this introduces calls to a function named getPGOName() in code that
has nothing to do with PGO, but don't shoot the messenger.

Event Timeline

pcc created this revision.May 12 2017, 8:19 PM

Most of the uses reads quite wrong since it has nothing to do with PGO. I'm not fond of this renaming right now, can we find another alternative name?

llvm/include/llvm/IR/GlobalValue.h
443–444

Is this still up to date? How does it play with the getPGOName name and the rest of the comment?

pcc added a comment.May 13 2017, 2:30 PM

Most of the uses reads quite wrong since it has nothing to do with PGO.

Yes, that's the point :)

Use of a function named getPGOName() in code that has nothing to do with PGO stands out and makes it more obvious that there is a bug. Using a "better" name would increase the chance of the function being used incorrectly in other places.

llvm/include/llvm/IR/GlobalValue.h
443–444

That part of the comment is still technically accurate, if a little misleading. I'll reword it.

In D33162#754180, @pcc wrote:

Most of the uses reads quite wrong since it has nothing to do with PGO.

Yes, that's the point :)

Use of a function named getPGOName() in code that has nothing to do with PGO stands out and makes it more obvious that there is a bug. Using a "better" name would increase the chance of the function being used incorrectly in other places.

What is the plan for all these uses your updating in this patch? Why don't you change these to use the "right" thing?

pcc added a comment.May 13 2017, 2:57 PM
In D33162#754180, @pcc wrote:

Most of the uses reads quite wrong since it has nothing to do with PGO.

Yes, that's the point :)

Use of a function named getPGOName() in code that has nothing to do with PGO stands out and makes it more obvious that there is a bug. Using a "better" name would increase the chance of the function being used incorrectly in other places.

What is the plan for all these uses your updating in this patch? Why don't you change these to use the "right" thing?

I wasn't planning to do that, I just wanted to make a change to prevent accidental use of this function, which I think is better than the status quo.

rnk edited edge metadata.May 15 2017, 2:32 PM
In D33162#754180, @pcc wrote:

Most of the uses reads quite wrong since it has nothing to do with PGO.

Yes, that's the point :)

Use of a function named getPGOName() in code that has nothing to do with PGO stands out and makes it more obvious that there is a bug. Using a "better" name would increase the chance of the function being used incorrectly in other places.

Let's go ahead and try to come up with a better name without solving the real problem. I'd focus on something really mechanical, since this is truly a low-level mechanical function. If you really want the object file name, you need DataLayout. Actually, why not fold Mangler into DataLayout? Mangler::getNameWithPrefix doesn't use any instance variables.

Anyway, I nominate something like dropLLVMManglingEscape. In contexts like DiagnosticInfo.cpp it should be clear to the reader that this is correct. In contexts like ASan, DataLayout should be available and we should use it.

pcc updated this revision to Diff 99068.May 15 2017, 3:19 PM
  • Rename and reword a comment
pcc added a comment.May 15 2017, 3:19 PM
In D33162#755514, @rnk wrote:
In D33162#754180, @pcc wrote:

Most of the uses reads quite wrong since it has nothing to do with PGO.

Yes, that's the point :)

Use of a function named getPGOName() in code that has nothing to do with PGO stands out and makes it more obvious that there is a bug. Using a "better" name would increase the chance of the function being used incorrectly in other places.

Let's go ahead and try to come up with a better name without solving the real problem. I'd focus on something really mechanical, since this is truly a low-level mechanical function. If you really want the object file name, you need DataLayout. Actually, why not fold Mangler into DataLayout? Mangler::getNameWithPrefix doesn't use any instance variables.

Anyway, I nominate something like dropLLVMManglingEscape. In contexts like DiagnosticInfo.cpp it should be clear to the reader that this is correct. In contexts like ASan, DataLayout should be available and we should use it.

That name works for me; done.

rnk accepted this revision.May 15 2017, 5:41 PM

lgtm, ship it

This revision is now accepted and ready to land.May 15 2017, 5:41 PM
This revision was automatically updated to reflect the committed changes.

(thanks, with this naming it looks better to me!)