[llvm-branch-commits] [llvm-branch] r84052 - in /llvm/branches/Apple/Leela: include/llvm/Metadata.h lib/Analysis/DebugInfo.cpp lib/AsmParser/LLParser.cpp lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/Transforms/Scalar/InstructionCombining.cpp lib/Transforms/Scalar/LICM.cpp lib/Transforms/Scalar/LoopUnswitch.cpp lib/VMCore/Metadata.cpp lib/VMCore/Value.cpp test/FrontendC/2006-01-13-Includes.c

Bill Wendling isanbard at gmail.com
Tue Oct 13 16:26:50 PDT 2009


Author: void
Date: Tue Oct 13 18:26:49 2009
New Revision: 84052

URL: http://llvm.org/viewvc/llvm-project?rev=84052&view=rev
Log:
$ svn merge -c 83977 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r83977 into '.':
U    include/llvm/Metadata.h
U    lib/VMCore/Value.cpp
U    lib/VMCore/Metadata.cpp
$ svn merge -c 83984 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r83984 into '.':
U    lib/Analysis/DebugInfo.cpp
$ svn merge -c 84002 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84002 into '.':
U    lib/AsmParser/LLParser.cpp
$ svn merge -c 84004 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84004 into '.':
U    lib/Bitcode/Reader/BitcodeReader.cpp
$ svn merge -c 84006 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84006 into '.':
U    lib/Bitcode/Writer/BitcodeWriter.cpp
$ svn merge -c 84025 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84025 into '.':
U    test/FrontendC/2006-01-13-Includes.c
$ svn merge -c 84033 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84033 into '.':
U    lib/Transforms/Scalar/LoopUnswitch.cpp
U    lib/Transforms/Scalar/InstructionCombining.cpp
U    lib/Transforms/Scalar/LICM.cpp
$ svn merge -c 84049 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r84049 into '.':
G    lib/Transforms/Scalar/LoopUnswitch.cpp
G    lib/Transforms/Scalar/InstructionCombining.cpp
G    lib/Transforms/Scalar/LICM.cpp


Modified:
    llvm/branches/Apple/Leela/include/llvm/Metadata.h
    llvm/branches/Apple/Leela/lib/Analysis/DebugInfo.cpp
    llvm/branches/Apple/Leela/lib/AsmParser/LLParser.cpp
    llvm/branches/Apple/Leela/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/branches/Apple/Leela/lib/Bitcode/Writer/BitcodeWriter.cpp
    llvm/branches/Apple/Leela/lib/Transforms/Scalar/InstructionCombining.cpp
    llvm/branches/Apple/Leela/lib/Transforms/Scalar/LICM.cpp
    llvm/branches/Apple/Leela/lib/Transforms/Scalar/LoopUnswitch.cpp
    llvm/branches/Apple/Leela/lib/VMCore/Metadata.cpp
    llvm/branches/Apple/Leela/lib/VMCore/Value.cpp
    llvm/branches/Apple/Leela/test/FrontendC/2006-01-13-Includes.c

Modified: llvm/branches/Apple/Leela/include/llvm/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/include/llvm/Metadata.h?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/include/llvm/Metadata.h (original)
+++ llvm/branches/Apple/Leela/include/llvm/Metadata.h Tue Oct 13 18:26:49 2009
@@ -361,6 +361,7 @@
   void ValueIsDeleted(const Instruction *Inst) {
     removeMDs(Inst);
   }
+  void ValueIsRAUWd(Value *V1, Value *V2);
 
   /// ValueIsCloned - This handler is used to update metadata store
   /// when In1 is cloned to create In2.

Modified: llvm/branches/Apple/Leela/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Analysis/DebugInfo.cpp?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Analysis/DebugInfo.cpp Tue Oct 13 18:26:49 2009
@@ -969,8 +969,6 @@
 #ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
   MetadataContext &TheMetadata = M.getContext().getMetadata();
   unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
-  if (!MDDbgKind)
-    return;
 #endif
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
     for (Function::iterator FI = (*I).begin(), FE = (*I).end(); FI != FE; ++FI)
@@ -987,15 +985,17 @@
         else if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(BI))
           processDeclare(DDI);
 #ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
-        else if (MDNode *L = TheMetadata.getMD(MDDbgKind, BI)) {
-          DILocation Loc(L);
-          DIScope S(Loc.getScope().getNode());
-          if (S.isCompileUnit())
-            addCompileUnit(DICompileUnit(S.getNode()));
-          else if (S.isSubprogram())
-            processSubprogram(DISubprogram(S.getNode()));
-          else if (S.isLexicalBlock())
-            processLexicalBlock(DILexicalBlock(S.getNode()));
+        else if (MDDbgKind) {
+          if (MDNode *L = TheMetadata.getMD(MDDbgKind, BI)) {
+            DILocation Loc(L);
+            DIScope S(Loc.getScope().getNode());
+            if (S.isCompileUnit())
+              addCompileUnit(DICompileUnit(S.getNode()));
+            else if (S.isSubprogram())
+              processSubprogram(DISubprogram(S.getNode()));
+            else if (S.isLexicalBlock())
+              processLexicalBlock(DILexicalBlock(S.getNode()));
+          }
         }
 #endif
       }

Modified: llvm/branches/Apple/Leela/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/AsmParser/LLParser.cpp?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/AsmParser/LLParser.cpp (original)
+++ llvm/branches/Apple/Leela/lib/AsmParser/LLParser.cpp Tue Oct 13 18:26:49 2009
@@ -3554,11 +3554,15 @@
 
   SmallVector<Value*, 16> Indices;
   while (EatIfPresent(lltok::comma)) {
+    if (Lex.getKind() == lltok::NamedOrCustomMD)
+      break;
     if (ParseTypeAndValue(Val, EltLoc, PFS)) return true;
     if (!isa<IntegerType>(Val->getType()))
       return Error(EltLoc, "getelementptr index must be an integer");
     Indices.push_back(Val);
   }
+  if (Lex.getKind() == lltok::NamedOrCustomMD)
+    if (ParseOptionalCustomMetadata()) return true;
 
   if (!GetElementPtrInst::getIndexedType(Ptr->getType(),
                                          Indices.begin(), Indices.end()))

Modified: llvm/branches/Apple/Leela/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Bitcode/Reader/BitcodeReader.cpp?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Bitcode/Reader/BitcodeReader.cpp Tue Oct 13 18:26:49 2009
@@ -840,9 +840,6 @@
       for (unsigned i = 1; i != RecordLength; ++i)
         Name[i-1] = Record[i];
       MetadataContext &TheMetadata = Context.getMetadata();
-      assert(TheMetadata.MDHandlerNames.find(Name.str())
-             == TheMetadata.MDHandlerNames.end() &&
-             "Already registered MDKind!");
       TheMetadata.MDHandlerNames[Name.str()] = Kind;
       break;
     }

Modified: llvm/branches/Apple/Leela/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Oct 13 18:26:49 2009
@@ -580,12 +580,14 @@
           Record.push_back(VE.getValueID(ND));
         }
       }
-      if (!StartedMetadataBlock)  {
-        Stream.EnterSubblock(bitc::METADATA_ATTACHMENT_ID, 3);
-        StartedMetadataBlock = true;
+      if (!Record.empty()) {
+        if (!StartedMetadataBlock)  {
+          Stream.EnterSubblock(bitc::METADATA_ATTACHMENT_ID, 3);
+          StartedMetadataBlock = true;
+        }
+        Stream.EmitRecord(bitc::METADATA_ATTACHMENT, Record, 0);
+        Record.clear();
       }
-      Stream.EmitRecord(bitc::METADATA_ATTACHMENT, Record, 0);
-      Record.clear();
     }
 
   if (StartedMetadataBlock)

Modified: llvm/branches/Apple/Leela/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Transforms/Scalar/InstructionCombining.cpp Tue Oct 13 18:26:49 2009
@@ -9979,7 +9979,9 @@
       new StoreInst(ConstantInt::getTrue(*Context),
                 UndefValue::get(Type::getInt1PtrTy(*Context)), 
                                   OldCall);
-      if (!OldCall->use_empty())
+      // If OldCall dues not return void then replaceAllUsesWith undef.
+      // This allows ValueHandlers and custom metadata to adjust itself.
+      if (OldCall->getType() != Type::getVoidTy(*Context))
         OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType()));
       if (isa<CallInst>(OldCall))   // Not worth removing an invoke here.
         return EraseInstFromFunction(*OldCall);
@@ -9994,7 +9996,9 @@
                UndefValue::get(Type::getInt1PtrTy(*Context)),
                   CS.getInstruction());
 
-    if (!CS.getInstruction()->use_empty())
+    // If CS dues not return void then replaceAllUsesWith undef.
+    // This allows ValueHandlers and custom metadata to adjust itself.
+    if (CS.getInstruction()->getType() != Type::getVoidTy(*Context))
       CS.getInstruction()->
         replaceAllUsesWith(UndefValue::get(CS.getInstruction()->getType()));
 
@@ -10251,7 +10255,7 @@
     }
   }
 
-  
+
   if (!Caller->use_empty())
     Caller->replaceAllUsesWith(NV);
   
@@ -10398,7 +10402,7 @@
           setCallingConv(cast<CallInst>(Caller)->getCallingConv());
         cast<CallInst>(NewCaller)->setAttributes(NewPAL);
       }
-      if (Caller->getType() != Type::getVoidTy(*Context) && !Caller->use_empty())
+      if (Caller->getType() != Type::getVoidTy(*Context))
         Caller->replaceAllUsesWith(NewCaller);
       Caller->eraseFromParent();
       Worklist.Remove(Caller);
@@ -12781,7 +12785,11 @@
             ++NumDeadInst;
             MadeIRChange = true;
           }
-          if (!I->use_empty())
+
+
+          // If I is not void type then replaceAllUsesWith undef.
+          // This allows ValueHandlers and custom metadata to adjust itself.
+          if (I->getType() != Type::getVoidTy(*Context))
             I->replaceAllUsesWith(UndefValue::get(I->getType()));
           I->eraseFromParent();
         }

Modified: llvm/branches/Apple/Leela/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Transforms/Scalar/LICM.cpp?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Transforms/Scalar/LICM.cpp Tue Oct 13 18:26:49 2009
@@ -486,7 +486,10 @@
     if (!isExitBlockDominatedByBlockInLoop(ExitBlocks[0], I.getParent())) {
       // Instruction is not used, just delete it.
       CurAST->deleteValue(&I);
-      if (!I.use_empty())  // If I has users in unreachable blocks, eliminate.
+      // If I has users in unreachable blocks, eliminate.
+      // If I is not void type then replaceAllUsesWith undef.
+      // This allows ValueHandlers and custom metadata to adjust itself.
+      if (I.getType() != Type::getVoidTy(I.getContext()))
         I.replaceAllUsesWith(UndefValue::get(I.getType()));
       I.eraseFromParent();
     } else {
@@ -499,7 +502,10 @@
   } else if (ExitBlocks.empty()) {
     // The instruction is actually dead if there ARE NO exit blocks.
     CurAST->deleteValue(&I);
-    if (!I.use_empty())  // If I has users in unreachable blocks, eliminate.
+    // If I has users in unreachable blocks, eliminate.
+    // If I is not void type then replaceAllUsesWith undef.
+    // This allows ValueHandlers and custom metadata to adjust itself.
+    if (I.getType() != Type::getVoidTy(I.getContext()))
       I.replaceAllUsesWith(UndefValue::get(I.getType()));
     I.eraseFromParent();
   } else {

Modified: llvm/branches/Apple/Leela/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/branches/Apple/Leela/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 18:26:49 2009
@@ -793,7 +793,9 @@
     
     // Anything that uses the instructions in this basic block should have their
     // uses replaced with undefs.
-    if (!I->use_empty())
+    // If I is not void type then replaceAllUsesWith undef.
+    // This allows ValueHandlers and custom metadata to adjust itself.
+    if (I->getType() != Type::getVoidTy(I->getContext()))
       I->replaceAllUsesWith(UndefValue::get(I->getType()));
   }
   

Modified: llvm/branches/Apple/Leela/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/VMCore/Metadata.cpp?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/VMCore/Metadata.cpp (original)
+++ llvm/branches/Apple/Leela/lib/VMCore/Metadata.cpp Tue Oct 13 18:26:49 2009
@@ -404,3 +404,15 @@
     if (MDNode *MD = dyn_cast_or_null<MDNode>(I->second))
       addMD(I->first, MD, In2);
 }
+
+/// ValueIsRAUWd - This handler is used when V1's all uses are replaced by
+/// V2.
+void MetadataContext::ValueIsRAUWd(Value *V1, Value *V2) {
+  Instruction *I1 = dyn_cast<Instruction>(V1);
+  Instruction *I2 = dyn_cast<Instruction>(V2);
+  if (!I1 || !I2)
+    return;
+
+  // FIXME : Give custom handlers a chance to override this.
+  ValueIsCloned(I1, I2);
+}

Modified: llvm/branches/Apple/Leela/lib/VMCore/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/VMCore/Value.cpp?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/VMCore/Value.cpp (original)
+++ llvm/branches/Apple/Leela/lib/VMCore/Value.cpp Tue Oct 13 18:26:49 2009
@@ -309,6 +309,10 @@
   // Notify all ValueHandles (if present) that this value is going away.
   if (HasValueHandle)
     ValueHandleBase::ValueIsRAUWd(this, New);
+  if (HasMetadata) {
+    LLVMContext &Context = getContext();
+    Context.pImpl->TheMetadata.ValueIsRAUWd(this, New);
+  }
 
   while (!use_empty()) {
     Use &U = *UseList;

Modified: llvm/branches/Apple/Leela/test/FrontendC/2006-01-13-Includes.c
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/test/FrontendC/2006-01-13-Includes.c?rev=84052&r1=84051&r2=84052&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/test/FrontendC/2006-01-13-Includes.c (original)
+++ llvm/branches/Apple/Leela/test/FrontendC/2006-01-13-Includes.c Tue Oct 13 18:26:49 2009
@@ -1,7 +1,5 @@
-// RUN: %llvmgcc %s -g -S -o - | llvm-as | opt -std-compile-opts | \
-// RUN:   llvm-dis | grep {test/FrontendC}
+// RUN: %llvmgcc %s -g -S -o - | grep {test/FrontendC}
 // PR676
-// XFAIL: *
 
 #include <stdio.h>
 





More information about the llvm-branch-commits mailing list