This is an archive of the discontinued LLVM Phabricator instance.

[Polly] [ManagedMemoryRewrite] Rewrite malloc, free correctly so it works inside bitcasts as well.
ClosedPublic

Authored by bollu on Aug 17 2017, 5:13 AM.

Details

Summary

Reuse the machinery built for replacing global arrays to replace malloc/free as well. Example replacement that was missed earlier:

ll
call void bitcast (void (i8*)* @free to void (%struct.fson_string*)*)
    (%struct.fson_string* %13) #2

Event Timeline

bollu created this revision.Aug 17 2017, 5:13 AM
bollu retitled this revision from [ManagedMemoryRewrite] Rewrite malloc, free correctly so it works inside bitcasts as well. Reuse the machinery built for replacing global arrays to replace malloc/free as well. Example replacement that was missed earlier: ```ll call void... to [Polly] [ManagedMemoryRewrite] Rewrite malloc, free correctly so it works inside bitcasts as well..Aug 17 2017, 5:14 AM
bollu edited the summary of this revision. (Show Details)
bollu added inline comments.Aug 17 2017, 5:14 AM
lib/CodeGen/ManagedMemoryRewrite.cpp
324

Suggest a better name please :)

grosser edited edge metadata.Aug 17 2017, 6:17 AM

Hi Siddharth,

some first comment. Also, do you have a test case here?

bollu updated this revision to Diff 111540.Aug 17 2017, 11:57 AM
  • [NFC] add testcase

@grosser Dont, added tests.

grosser added inline comments.Aug 17 2017, 12:12 PM
lib/CodeGen/ManagedMemoryRewrite.cpp
324

I thought I sent this out, but I apparently did not. "Really" does not add any information. Can you instead explain what the difference is here.

Maybe name it:

replaceAllUsesAndConstantUses

And describe that constants are normally ignored by replaceAllUses, and how this function handles them differently.

bollu updated this revision to Diff 111550.Aug 17 2017, 1:07 PM
  • [NFC] rename function as what Tobias suggested and add comment explaining why
grosser accepted this revision.Aug 17 2017, 1:18 PM

LGTM.

lib/CodeGen/ManagedMemoryRewrite.cpp
320

Newline in between here.

322

actually

330

Two whitespaces?

This revision is now accepted and ready to land.Aug 17 2017, 1:18 PM
This revision was automatically updated to reflect the committed changes.
bollu marked 2 inline comments as done.