[llvm-commits] [llvm] r95269 - in /llvm/trunk: lib/Bitcode/Writer/ValueEnumerator.cpp test/Assembler/functionlocal-metadata.ll

Nick Lewycky nicholas at mxc.ca
Thu Feb 4 12:11:25 PST 2010


Victor Hernandez wrote:
> Author: hernande
> Date: Wed Feb  3 19:13:08 2010
> New Revision: 95269
>
> URL: http://llvm.org/viewvc/llvm-project?rev=95269&view=rev
> Log:
> Fix (and test) function-local metadata that occurs before the instruction that it refers to; fix is to not enumerate operands of function-local metadata until after all instructions have been enumerated

Does this fix PR5278?

Nick

> Modified:
>      llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
>      llvm/trunk/test/Assembler/functionlocal-metadata.ll
>
> Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=95269&r1=95268&r2=95269&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Wed Feb  3 19:13:08 2010
> @@ -408,21 +408,25 @@
>
>     FirstInstID = Values.size();
>
> +  SmallVector<MDNode *, 8>  FunctionLocalMDs;
>     // Add all of the instructions.
>     for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
>       for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) {
>         for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
>              OI != E; ++OI) {
>           if (MDNode *MD = dyn_cast<MDNode>(*OI))
> -          if (!MD->isFunctionLocal())
> -              // These were already enumerated during ValueEnumerator creation.
> -              continue;
> -        EnumerateOperandType(*OI);
> +          if (MD->isFunctionLocal())
> +            // Enumerate metadata after the instructions they might refer to.
> +            FunctionLocalMDs.push_back(MD);
>         }
>         if (!I->getType()->isVoidTy())
>           EnumerateValue(I);
>       }
>     }
> +
> +  // Add all of the function-local metadata.
> +  for (unsigned i = 0, e = FunctionLocalMDs.size(); i != e; ++i)
> +    EnumerateOperandType(FunctionLocalMDs[i]);
>   }
>
>   void ValueEnumerator::purgeFunction() {
>
> Modified: llvm/trunk/test/Assembler/functionlocal-metadata.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/functionlocal-metadata.ll?rev=95269&r1=95268&r2=95269&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Assembler/functionlocal-metadata.ll (original)
> +++ llvm/trunk/test/Assembler/functionlocal-metadata.ll Wed Feb  3 19:13:08 2010
> @@ -2,6 +2,8 @@
>
>   define void @Foo(i32 %a, i32 %b) {
>   entry:
> +  call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !"bar")
> +; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata !"bar")
>     %0 = add i32 %a, 1                              ;<i32>  [#uses=1]
>     %two = add i32 %b, %0                           ;<i32>  [#uses=0]
>     %1 = alloca i32                                 ;<i32*>  [#uses=1]
>
>
> _______________________________________________
> 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