[llvm-dev] DebugInfo, Metadata usage

Adrian Prantl via llvm-dev llvm-dev at lists.llvm.org
Wed May 24 11:43:31 PDT 2017


> On May 24, 2017, at 11:39 AM, DES <1ikb3zz at gmail.com> wrote:
> 
> I'll ask again that question.
> 
> Thank you Adrian, I've looked through IR Verifier and it helps me to
> understand some parts of retrieving metadata and debug info. But , after
> that,  I've faced with another problem:
> 
> Original Code:
> 
> std::wcout << L"WCHAR_HELLOWORLD" << std::endl;b
> 
> IR Code:
> 
> @.str.2 = private unnamed_addr constant [17 x i32] [i32 87, i32 67, i32
> 72, i32 65, i32 82, i32 95, i32 72, i32 69, i32 76, i32 76, i32 79, i32
> 87, i32 79, i32 82, i32 76, i32 68, i32 0], align 4
> 
> For that kind of Constant metadata is empty.

Clang only generates debug type information for named variables in the source program, not for every expression. If you want source type information for everything, you will need to modify clang to generate it. Depending on what you need the information for, there might be a better solution. What are you trying to achieve?

-- adrian

> The way, I could get
> metadata as mentioned in Verifier , is not working for Constants that
> are not created as Local Variables. I've tried to get the info via Users
> of that Value, but it wasn't working either.
> 
>  %call39 = invoke dereferenceable(160)
> %"class.std::__1::basic_ostream.13"*
> @_ZNSt3__1lsIwNS_11char_traitsIwEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_(%"class.std::__1::basic_ostream.13"*
> dereferenceable(160) @_ZNSt3__15wcoutE, i32* getelementptr inbounds ([17
> x i32], [17 x i32]* @.str.2, i32 0, i32 0))
>          to label %invoke.cont38 unwind label %lpad5, !dbg !5551
> 
> I'm digging around Verifier, Metadata, DebugInfo, though, it comes to me
> that I miss something
> 
> Is it some design decision that isString method does not return TRUE 
> for wide-character string?
> 
> Should I do some additional analysis for constants(like collect meta for
> all instructions in all functions and build a map after)?  
> Who knows sources where I could find some examples dealing with
> constants' metadata?
> 
> And again, in advance, thank you very much!
> 
> 
> ----------------------
> the best regards!
> 0x0859549A
> 
> On 05/22/2017 08:45 PM, Adrian Prantl wrote:
>>> On May 22, 2017, at 6:14 AM, DES via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>> 
>>> What way can I get  DIBasicType for ConstantDataSequential?
>>> Literally, I want to know is there any way to get the relationship
>>> between constant, globals and related debuginfo, metadata information?
>> To get to the source variables associated with a global you can use code like this (copied from the IR Verifier):
>> 
>>  SmallVector<MDNode *, 1> MDs;
>>  GV.getMetadata(LLVMContext::MD_dbg, MDs);
>>  for (auto *MD : MDs) {
>>    if (auto *GVE = dyn_cast<DIGlobalVariableExpression>(MD))
>>      // do stuff.
>> 
>> -- adrian
>> 
>>> I would appreciate it for any help.
>>> In advance, thank you very much.
>>> 
>>> -- 
>>> ----------------------
>>> the best regards!
>>> 0x0859549A
>>> 
>>> 
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> llvm-dev at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 
> 



More information about the llvm-dev mailing list