Add support for undef

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17055 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-10-16 18:19:26 +00:00
parent a79e7cca0d
commit bd1d382cc4
3 changed files with 8 additions and 3 deletions

View 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!");
}

View 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)) {

View 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;