[llvm] [IR] Allow uses of `llvm.global_ctors` and `llvm.global_dtors` (PR #96477)

Daniil Kovalev via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 04:12:52 PDT 2024


kovdan01 wrote:

> @kovdan01 Can you use some special value as the discriminator to indicate to the backend that you want a self-reference? That way only the backend has to deal with it.

In common case, we can't, since for stuff like `ret ptr ptrauth (ptr @g, i32 0, i64 42, ptr storage_addr)` we need some actual storage address and not just a flag or a special discriminator value indicating that we need a self-reference (because here we can't say, self-reference to what).

In a particular case of ctors/dtors, I can try to implement some special handling. One thought I now have is that we can just look at llvm module flags - we already store info regarding pauth features enabled for module, which includes info whether address discrimination is enabled for ctors/dtors, so, when doing further lowering, we can manually apply address discrimination to them. @nikic Please let me know if such approach looks reasonable to you. If yes, I'll still leave this PR opened until I publish corresponding changes in #96478.

https://github.com/llvm/llvm-project/pull/96477


More information about the llvm-commits mailing list