Add support for undef
authorChris Lattner <sabre@nondot.org>
Sat, 16 Oct 2004 18:19:26 +0000 (18:19 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 16 Oct 2004 18:19:26 +0000 (18:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17055 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/Local.cpp
lib/CodeGen/AsmPrinter.cpp
lib/ExecutionEngine/ExecutionEngine.cpp

index b497c3849c93d2d1fe34598cdc9453db4c3c6831..473fb630dc4de7906794f20a6617a2fb92bbf35b 100644 (file)
@@ -246,6 +246,9 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) {
     } else if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(C)) {
       // Random constants are unknown mem
       return NH = createNode()->setUnknownNodeMarker();
+    } else if (isa<UndefValue>(C)) {
+      ScalarMap.erase(V);
+      return 0;
     } else {
       assert(0 && "Unknown constant type!");
     }
index 11565dff0b3fd46d2e21d201c31e9f170ade1d72..eb57cced13ee9a7b918b7a6aa7c691b2de7c1763 100644 (file)
@@ -55,7 +55,7 @@ void AsmPrinter::emitZeros(unsigned NumZeros) const {
 // Print out the specified constant, without a storage class.  Only the
 // constants valid in constant expressions can occur here.
 void AsmPrinter::emitConstantValueOnly(const Constant *CV) {
-  if (CV->isNullValue())
+  if (CV->isNullValue() || isa<UndefValue>(CV))
     O << "0";
   else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
     assert(CB == ConstantBool::True);
@@ -171,7 +171,7 @@ static void printAsCString(std::ostream &O, const ConstantArray *CVA) {
 void AsmPrinter::emitGlobalConstant(const Constant *CV) {  
   const TargetData &TD = TM.getTargetData();
 
-  if (CV->isNullValue()) {
+  if (CV->isNullValue() || isa<UndefValue>(CV)) {
     emitZeros(TD.getTypeSize(CV->getType()));
     return;
   } else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
index b239cc2a53e7ed9a4ca01cac9bec6e2238881f59..208f8e2e834a2b22eb43e219feec089fca291850 100644 (file)
@@ -440,7 +440,9 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
 // specified memory location...
 //
 void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {
-  if (Init->getType()->isFirstClassType()) {
+  if (isa<UndefValue>(Init)) {
+    return;
+  } else if (Init->getType()->isFirstClassType()) {
     GenericValue Val = getConstantValue(Init);
     StoreValueToMemory(Val, (GenericValue*)Addr, Init->getType());
     return;