[llvm-dev] How to pass a StringRef to a function call inserted as instrumentation?

Dipanjan Das via llvm-dev
Wed, 03 May 2017 20:44:36 -0000

Hi Tim,

I think this is usually done via anonymous globals. For example if
you
> use Clang to compile this:
> .
> .
> .
> So you'll create a new global i8 array that gets initialized to your
> StringRef's data and then pass a pointer to its first element into
> your instrumentation function.
>


Sorry to reply late. It worked perfectly fine. For the sake of
completeness, this is what I did:

   Value* var_name = builder.CreateGlobalStringPtr(po->getName()); //
builder is an IRBuilder instance

Above created the following IR:

@0 = private unnamed_addr constant [2 x i8] c"a\00"

--

Thanks & Regards,
Dipanjan
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20170503/b80fcc9e/attachment.html>