[llvm-commits] [llvm] r95467 - in /llvm/trunk: lib/Bitcode/Writer/ValueEnumerator.cpp test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll

Victor Hernandez vhernandez at apple.com
Fri Feb 5 17:21:09 PST 2010


Author: hernande
Date: Fri Feb  5 19:21:09 2010
New Revision: 95467

URL: http://llvm.org/viewvc/llvm-project?rev=95467&view=rev
Log:
Function-local metadata whose operands had been optimized to no longer refer to function-local IR were not getting written by BitcodeWriter; solution is for these metadata to be enumerated just like global metadata.

Added:
    llvm/trunk/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll
Modified:
    llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp

Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=95467&r1=95466&r2=95467&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Fri Feb  5 19:21:09 2010
@@ -93,7 +93,7 @@
         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())
+            if (MD->isFunctionLocal() && MD->getFunction())
               // These will get enumerated during function-incorporation.
               continue;
           EnumerateOperandType(*OI);
@@ -415,7 +415,7 @@
       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())
+          if (MD->isFunctionLocal() && MD->getFunction())
             // Enumerate metadata after the instructions they might refer to.
             FunctionLocalMDs.push_back(MD);
       }

Added: llvm/trunk/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll?rev=95467&view=auto

==============================================================================
--- llvm/trunk/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll (added)
+++ llvm/trunk/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll Fri Feb  5 19:21:09 2010
@@ -0,0 +1,25 @@
+; RUN: opt -std-compile-opts < %s | llvm-dis | not grep badref 
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-apple-darwin10.2"
+
+%struct.anon = type { i32, i32 }
+%struct.test = type { i64, %struct.anon, %struct.test* }
+
+ at TestArrayPtr = global %struct.test* getelementptr inbounds ([10 x %struct.test]* @TestArray, i64 0, i64 3) ; <%struct.test**> [#uses=1]
+ at TestArray = common global [10 x %struct.test] zeroinitializer, align 32 ; <[10 x %struct.test]*> [#uses=2]
+
+define i32 @main() nounwind readonly {
+  %diff1 = alloca i64                             ; <i64*> [#uses=2]
+  call void @llvm.dbg.declare(metadata !{i64* %diff1}, metadata !0)
+  store i64 72, i64* %diff1, align 8
+  %v1 = load %struct.test** @TestArrayPtr, align 8 ; <%struct.test*> [#uses=1]
+  %v2 = ptrtoint %struct.test* %v1 to i64 ; <i64> [#uses=1]
+  %v3 = sub i64 %v2, ptrtoint ([10 x %struct.test]* @TestArray to i64) ; <i64> [#uses=1]
+  store i64 %v3, i64* %diff1, align 8
+  ret i32 4
+}
+
+declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
+
+!0 = metadata !{i32 459008, metadata !0, metadata !0, metadata !0, i32 38, metadata !0} ; [ DW_TAG_auto_variable ]





More information about the llvm-commits mailing list