[LLVMdev] struct type parament
Mehdi Amini
mehdi.amini at apple.com
Wed Jun 3 08:03:39 PDT 2015
Do you really want to map the “source code level” type or does a comparison based on the structural equivalence would be OK?
See:
/// isLayoutIdentical - Return true if this is layout identical to the
/// specified struct.
bool isLayoutIdentical(StructType *Other) const;
—
Mehdi
> On Jun 2, 2015, at 2:30 PM, Haopeng Liu <hyliuhp at gmail.com> wrote:
>
> I tried to compare two types. Because of renaming, the comparison result is not as expected. How to deal with renaming while comparing types?
>
> Best,
> Haopeng
>
> On 6/2/15 4:09 PM, Mehdi Amini wrote:
>> Hi Haopeng,
>>
>> One more element, I just noticed you are using LTO, I am not sure how it is implemented but my guess is that there is a shared LLVMContext. If multiple files include this structure declaration, I wouldn’t be surprised if it trigger creating the type over and over in the IR.
>>
>> Why is it a problem for you by the way? Does the compilation fails in some way?
>>
>> —
>> Mehdi
>>
>>> On Jun 2, 2015, at 1:31 PM, Haopeng Liu <hyliuhp at gmail.com> wrote:
>>>
>>> Hi Mehdi,
>>>
>>> Thanks for your reply.
>>>
>>> It seems caused by random rename because I saw %struct.StructTyName.692.475*, which might be twice renaming.
>>>
>>> Does this collision occur because this type is declared more than once?
>>>
>>> I encountered this problem when used clang to compile transmission 1.42 (http://download.transmissionbt.com/files/) with configuration: "./configure --disable-gtk". Then in ./third-party/libevent/event.o.ll, you can see the function "event_base_get_method" is an example.
>>>
>>> Best,
>>> Haopeng
>>>
>>> On 6/2/15 1:48 PM, Mehdi Amini wrote:
>>>> Hi,
>>>>
>>>> I think this is when a collision is found on the name.
>>>> I would be interesting to have the full test, it might be that the API is used in a way such that type is constantly re-created even if it already exists, which might be inefficient.
>>>>
>>>> See in lib/IR/Type.cpp, StructType::setName(StringRef Name):
>>>>
>>>> ...
>>>> // While we have a name collision, try a random rename.
>>>> if (Entry->getValue()) {
>>>> SmallString<64> TempStr(Name);
>>>> TempStr.push_back('.');
>>>> raw_svector_ostream TmpStream(TempStr);
>>>> unsigned NameSize = Name.size();
>>>> do {
>>>> TempStr.resize(NameSize + 1);
>>>> TmpStream.resync();
>>>> TmpStream << getContext().pImpl->NamedStructTypesUniqueID++;
>>>> Entry = &getContext().pImpl->
>>>> NamedStructTypes.GetOrCreateValue(TmpStream.str());
>>>> } while (Entry->getValue());
>>>> }
>>>>
>>>>
>>>> —
>>>> Mehdi
>>>>
>>>>> On Jun 2, 2015, at 11:23 AM, Haopeng Liu <hyliuhp at gmail.com> wrote:
>>>>>
>>>>> Hi All,
>>>>>
>>>>> I generated the following code with "clang -flto" command.
>>>>>
>>>>> void test(struct StruTyName *a) {
>>>>> ...
>>>>> }
>>>>>
>>>>> Then the type of test function is "void (%struct.StruTyName.100*)" by calling function::getFunctionType API.
>>>>>
>>>>> What's the meaning of number 100?
>>>>>
>>>>> Best,
>>>>> Haopeng
>>>>> _______________________________________________
>>>>> LLVM Developers mailing list
>>>>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list