This is an archive of the discontinued LLVM Phabricator instance.

[LLVM-C] Add C API for removing global
AbandonedPublic

Authored by KihongHeo on Jun 7 2020, 6:42 AM.

Details

Summary

This commit adds the C API for removing global (removeFromParent).

Diff Detail

Event Timeline

KihongHeo created this revision.Jun 7 2020, 6:42 AM
Herald added a project: Restricted Project. · View Herald Transcript

Hi, I am new to LLVM phabricator.
I don't clrearly understand why this build fail happens. Any suggestion?

You can ignore the build failure; the infrastructure for pre-commit testing is new, and it looks like it failed spuriously.

If you're not using arcanist, please upload patches with full context (-U10000).

C APIs should have appropriate documentation. Some of the existing APIs are missing documentation, but please ensure new ones are properly documented.

How are you actually planning to use this API? As far as I can tell, given the other existing APIs, the GlobalVariable is guaranteed to leak.

KihongHeo updated this revision to Diff 269376.Jun 8 2020, 4:17 PM

Add documentation

@efriedma Thanks for your suggestion. I updated the diff via arc.

I wanted to make the C-library expose APIs consistently. LLVMRemoveBasicBlockFromParent and LLVMInstructionRemoveFromParent are already there but not for global variable.

What do you mean by leak?

What do you mean by leak?

Leak, as in a memory leak. After you've removed the global variable, there is no API to free the memory, or do anything useful with it.

KihongHeo abandoned this revision.Jun 8 2020, 6:42 PM

I see. My bad. It seems there is no way to delete it after then.
Let me find another way.

Thanks.