[llvm-dev] Should @llvm.used be a NamedMDNode?
Vedant Kumar via llvm-dev
llvm-dev at lists.llvm.org
Wed Mar 2 16:23:43 PST 2016
> On Mar 2, 2016, at 4:19 PM, Vedant Kumar <vsk at apple.com> wrote:
>
> Hi,
>
> Should @llvm.used be a NamedMDNode instead of a GlobalVariable?
>
> I think this would make it easier to mark globals as used. The current method
> involves (1) copying the existing elements of @llvm.used into a container, (2)
> erasing @llvm.used, (3) appending the new global to the container, (4)
> re-creating @llvm.used (thereby polluting the ConstantArray cache?), and (5)
> calling LLVMUsed->setSection("llvm.metadata"). See InstrProfiling::emitUses.
>
> If we use NamedMDNode, this could be as simple as:
>
> auto *LLVMUsed = M->getOrInsertNamedMetadata("llvm.used");
> LLVMUsed->addOperand(ConstantAsMetadata::get(C));
Actually, the ConstantAsMetadata would have to be wrapped in an MDTuple,
because Metadata doesn't inherit from MDNode.
The point still stands.
vedant
>
> I took a cursory look around and it doesn't seem like we really depend on
> @llvm.used being a GlobalVariable.
>
> Am I wrong about this? Other thoughts?
>
> thanks
> vedant
More information about the llvm-dev
mailing list