[PATCH] D64962: appendToGlobalCtors: allow for llvm.global_ctors functions of varying type

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 14 14:21:54 PDT 2019


rnk added a comment.

> Q: Why should appendToGlobalCtors take a Function * in the first place?

Probably just type safety for the existing clients. Clang doesn't actually use this utility anyway. It probably builds the array in bulk rather than repeatedly appending to the initializer.

Relaxing it to Constant and asserting that it has the right type (pointer to void function) seems reasonable. I would prefer that the caller be the one to insert the cast from the `void(int, char**, char**)` prototype to the void prototype, since only the caller can know that it is safe.

And it would need a test to proceed. A unit test would be best.



================
Comment at: lib/Transforms/Utils/ModuleUtils.cpp:45
   CSVals[0] = IRB.getInt32(Priority);
-  CSVals[1] = F;
+  CSVals[1] = ConstantExpr::getBitCast(F, FnTy);
   CSVals[2] = Data ? ConstantExpr::getPointerCast(Data, IRB.getInt8PtrTy())
----------------
This is probably not quite right, it should probably be a pointer to function type.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64962/new/

https://reviews.llvm.org/D64962





More information about the llvm-commits mailing list