This is an archive of the discontinued LLVM Phabricator instance.

[MetaRenamer] Don't rename library functions.
ClosedPublic

Authored by bryant on Mar 23 2017, 1:18 PM.

Details

Summary

I'm assuming is that bugpoint repros should behave the same before and after -metarenamer.

Diff Detail

Repository
rL LLVM

Event Timeline

bryant created this revision.Mar 23 2017, 1:18 PM
davide added a subscriber: davide.Mar 23 2017, 1:30 PM

You want to do this for all the external functions, maybe?

You want to do this for all the external functions, maybe?

Not sure that I understand. Externs are preserved with this patch. In the test case that I've added, for instance,

20:58:29 ~/3rd/llvm/test> opt -S -metarenamer Transforms/MetaRenamer/metarenamer.ll | tail -n 13
declare noalias i8* @malloc(i32)   <================

declare void @free(i8* nocapture)  <===============

define void @zot() {
bb:
  %tmp = call i8* @malloc(i32 23)
  call void @free(i8* %tmp)
  ret void
}

attributes #0 = { nounwind ssp uwtable }
attributes #1 = { argmemonly nounwind }

Am I missing your meaning?

I mean, all external functions, not just libcalls, e.g.

declare noalias i8* @blahgoo(i32)  
[...]
  call void @blahgoo(i8* %tmp)

... unless they're already preserved, in which case, feel free to ignore this comment.

What happens if there's a conflict between a meta-renamed function and originally named extern? For instance,

declare void @pluto()

define void @dont_rename_lib_funcs(...) {  ; metarenames to pluto.
  ...
}

?

What happens if there's a conflict between a meta-renamed function and originally named extern? For instance,

declare void @pluto()

define void @dont_rename_lib_funcs(...) {  ; metarenames to pluto.
  ...
}

?

If I understand your example correctly, that's a bug in the pass?

What I mean is that I don't see the reason for wanting to keep non-lib externs. Lib externs, on the other hand, need to stay un-renamed because some passes may behave differently in the presence of specific library functions. DSE, for instance, provides special handling for malloc-ed memory locations.

What happens if there's a conflict between a meta-renamed function and originally named extern? For instance,

declare void @pluto()

define void @dont_rename_lib_funcs(...) {  ; metarenames to pluto.
  ...
}

?

If I understand your example correctly, that's a bug in the pass?

Actually, I think it would rename dont_rename_lib_funcs to pluto.1, pluto.2, etc. as it does now when it runs out of meta names (and if it doesn't, it should). What I really meant to ask is the reply above.

davide accepted this revision.Mar 23 2017, 2:28 PM

Oh, sure. Sounds sensible (modulo nits).

lib/Transforms/Utils/MetaRenamer.cpp
118–122 ↗(On Diff #92853)

Add a comment explaining why you're skipping funcs.

test/Transforms/MetaRenamer/metarenamer.ll
104–105 ↗(On Diff #92853)
; CHECK-LABEL:
; CHECK-NEXT:
; CHECK-NEXT:
This revision is now accepted and ready to land.Mar 23 2017, 2:28 PM
bryant updated this revision to Diff 92873.Mar 23 2017, 3:14 PM
  • Explain why leave lib funcs alone.
  • Make test case FileChecks complete..
bryant marked 2 inline comments as done.Mar 23 2017, 3:14 PM
This revision was automatically updated to reflect the committed changes.