This is an archive of the discontinued LLVM Phabricator instance.

[OCaml] Handle nullptr in Llvm.global_initializer
ClosedPublic

Authored by kren1 on Jul 24 2019, 2:17 AM.

Details

Summary

LLVMGetInitializer returns nullptr in case there is no
initializer. There is not much that can be done with nullptr in OCaml,
not even test if it is null. Also, there does not seem to be a C or
OCaml API to test if there is an initializer. So this diff changes
Llvm.global_initializer to return an option.

Event Timeline

kren1 created this revision.Jul 24 2019, 2:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2019, 2:17 AM
This revision is now accepted and ready to land.Jul 24 2019, 11:51 AM

Thanks @whitequark . @modocache could you commit this for me?

This revision was automatically updated to reflect the committed changes.

This change broke tests: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/18485. I reverted it in r373311.

Committers: please always run ninja check-all before committing.

kren1 reopened this revision.Oct 1 2019, 7:04 AM
This revision is now accepted and ready to land.Oct 1 2019, 7:04 AM
kren1 updated this revision to Diff 222615.Oct 1 2019, 7:45 AM

Apologies my bad, forgot to run the tests for this one...

I fixed the LLVM (ocaml) tests. I don't believe the clang failure was my fault and check-all passes in my setup.

This revision was automatically updated to reflect the committed changes.
vaivaswatha added inline comments.
llvm/bindings/ocaml/llvm/llvm_ocaml.c
1268

ptr_to_option was recently introduced and is defined in this same file above. So you could just do something like this: https://github.com/llvm/llvm-project/blob/main/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c#L839

jberdine added inline comments.Mar 19 2021, 8:19 AM
llvm/bindings/ocaml/llvm/llvm_ocaml.c
1268

Good call, I will send such a simplification.