[llvm] r179622 - Print out the target-independent attributes in a comment before the function definition.

Bill Wendling wendling at apple.com
Wed Apr 17 16:40:53 PDT 2013


Hi Reid,

I changed the code a bit. I'm hoping it'll work better for you now! :) Please let me know.

-bw

On Apr 17, 2013, at 12:03 PM, Reid Kleckner <rnk at google.com> wrote:

> Yep:
> 
> $ clang.exe -cc1 -triple i386-pc-win32 -emit-llvm -o -
> C:/Users/rnk/Downloads/preprocessed.c
> Assertion failed: begin() + idx < end(), file
> ..\include\llvm/ADT/SmallVector.h, line 140
> 
> 
> 
> On Wed, Apr 17, 2013 at 2:49 PM, Timur Iskhodzhanov <timurrrr at google.com> wrote:
>> $ bin\clang.exe -cc1 -triple i386-pc-win32 -emit-llvm -o -
>> ..\tools\clang\test\CodeGen\x86_32-arguments-win32.c
>> Assertion failed: begin() + idx < end(), file
>> ..\include\llvm/ADT/SmallVector.h, line 140
>> 
>> $ bin\clang.exe -cc1 -triple i386-pc-win32 -E
>> ..\tools\clang\test\CodeGen\x86_32-arguments-win32.c > preprocessed.c
>> [see the attached file]
>> 
>> Reid,
>> Does the problem reproduce for you too?
>> FTR, I'm using
>>  cmake -GNinja -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release
>> -DLLVM_TARGETS_TO_BUILD=X86 ..
>> 
>> 2013/4/17 Bill Wendling <isanbard at gmail.com>:
>>> Could you send me a test case? The preprocessed file and command line should be sufficient.
>>> 
>>> -bw
>>> 
>>> On Apr 17, 2013, at 3:53 AM, Timur Iskhodzhanov <timurrrr at google.com> wrote:
>>> 
>>>> Hi Bill,
>>>> 
>>>> I see
>>>> "Assertion failed: begin() + idx < end(), file
>>>> D:\src\llvm-dev\include\llvm/ADT/SmallVector.h, line 140"
>>>> // idx=1, size=1
>>>> failures on my Windows build which has
>>>> `anonymous namespace'::AssemblyWriter::printFunction() + 0x11E
>>>> bytes(s), lib\ir\asmwriter.cpp, line 1618 + 0xE byte(s)
>>>> `anonymous namespace'::AssemblyWriter::printModule() + 0x41F
>>>> bytes(s), lib\ir\asmwriter.cpp, line 1378 + 0x14 byte(s)
>>>> in the middle of a stack.
>>>> 
>>>> Just in case, I've observed these assertions on
>>>> python bin\llvm-lit -v ..\tools\clang\test --filter="microsoft|win32"
>>>> on Windows.
>>>> I think only -cc1 -emit-llvm is affected, not -c.
>>>> 
>>>> Reverting your change locally has fixed my test runs.
>>>> 
>>>> Mind taking a look?
>>>> 
>>>> Thanks,
>>>> Timur
>>>> 
>>>> 2013/4/17 Bill Wendling <isanbard at gmail.com>:
>>>>> Author: void
>>>>> Date: Tue Apr 16 15:55:47 2013
>>>>> New Revision: 179622
>>>>> 
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=179622&view=rev
>>>>> Log:
>>>>> Print out the target-independent attributes in a comment before the function definition.
>>>>> 
>>>>> Modified:
>>>>>   llvm/trunk/lib/IR/AsmWriter.cpp
>>>>> 
>>>>> Modified: llvm/trunk/lib/IR/AsmWriter.cpp
>>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=179622&r1=179621&r2=179622&view=diff
>>>>> ==============================================================================
>>>>> --- llvm/trunk/lib/IR/AsmWriter.cpp (original)
>>>>> +++ llvm/trunk/lib/IR/AsmWriter.cpp Tue Apr 16 15:55:47 2013
>>>>> @@ -1605,6 +1605,29 @@ void AssemblyWriter::printFunction(const
>>>>>  if (F->isMaterializable())
>>>>>    Out << "; Materializable\n";
>>>>> 
>>>>> +  const AttributeSet &Attrs = F->getAttributes();
>>>>> +  if (Attrs.hasAttributes(AttributeSet::FunctionIndex)) {
>>>>> +    AttributeSet AS = Attrs.getFnAttributes();
>>>>> +    std::string AttrStr;
>>>>> +
>>>>> +    unsigned Idx = 0;
>>>>> +    for (unsigned E = AS.getNumSlots(); Idx != E; ++Idx)
>>>>> +      if (AS.getSlotIndex(Idx) == AttributeSet::FunctionIndex)
>>>>> +        break;
>>>>> +
>>>>> +    for (AttributeSet::iterator I = AS.begin(Idx), E = AS.end(Idx);
>>>>> +         I != E; ++I) {
>>>>> +      Attribute Attr = *I;
>>>>> +      if (!Attr.isStringAttribute()) {
>>>>> +        if (!AttrStr.empty()) AttrStr += ' ';
>>>>> +        AttrStr += Attr.getAsString();
>>>>> +      }
>>>>> +    }
>>>>> +
>>>>> +    if (!AttrStr.empty())
>>>>> +      Out << "; Function Attrs: " << AttrStr << '\n';
>>>>> +  }
>>>>> +
>>>>>  if (F->isDeclaration())
>>>>>    Out << "declare ";
>>>>>  else
>>>>> @@ -1620,7 +1643,6 @@ void AssemblyWriter::printFunction(const
>>>>>  }
>>>>> 
>>>>>  FunctionType *FT = F->getFunctionType();
>>>>> -  const AttributeSet &Attrs = F->getAttributes();
>>>>>  if (Attrs.hasAttributes(AttributeSet::ReturnIndex))
>>>>>    Out <<  Attrs.getAsString(AttributeSet::ReturnIndex) << ' ';
>>>>>  TypePrinter.print(F->getReturnType(), Out);
>>>>> @@ -1761,10 +1783,8 @@ void AssemblyWriter::printBasicBlock(con
>>>>> /// which slot it occupies.
>>>>> ///
>>>>> void AssemblyWriter::printInfoComment(const Value &V) {
>>>>> -  if (AnnotationWriter) {
>>>>> +  if (AnnotationWriter)
>>>>>    AnnotationWriter->printInfoComment(V, Out);
>>>>> -    return;
>>>>> -  }
>>>>> }
>>>>> 
>>>>> // This member is called for each Instruction in a function..
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> llvm-commits mailing list
>>>>> llvm-commits at cs.uiuc.edu
>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list