Mahesh Attarde via llvm-dev
2018-Mar-21 06:22 UTC
[llvm-dev] How to read String value of GlobalVariable?
Hi I have IR Code like ... @path = private constant [6xi8] c"abcde\00" ... --- Code from Pass --- GlobalVariable * GVPath = .... // contains @path I want to convert "abcde" to StringRef. Can you help me with GlobalVariable API? GlobalVariable::getInitializer() --> Constant* // How to get exact value äbcde from here? ~mahesh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180321/fc70ed6d/attachment.html>
Zhang via llvm-dev
2018-Mar-21 06:26 UTC
[llvm-dev] How to read String value of GlobalVariable?
``` if(GVPath->hasInitializer()){ if(ConstantDataArray* CDA=dyn_cast<ConstantDataArray>(GVPath->getInitializer())){ StringRef str=CDA->getAsString(); } } ``` ------------------ Original ------------------ From: "Mahesh Attarde via llvm-dev"<llvm-dev at lists.llvm.org>; Date: Wed, Mar 21, 2018 06:52 AM To: "llvm-dev"<llvm-dev at lists.llvm.org>; Subject: [llvm-dev] How to read String value of GlobalVariable? Hi I have IR Code like ... @path = private constant [6xi8] c"abcde\00" ... --- Code from Pass --- GlobalVariable * GVPath = .... // contains @path I want to convert "abcde" to StringRef. Can you help me with GlobalVariable API? GlobalVariable::getInitializer() --> Constant* // How to get exact value äbcde from here? ~mahesh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180321/18aa5e2e/attachment.html>