diff options
author | Chris Lattner <sabre@nondot.org> | 2004-03-16 08:38:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-03-16 08:38:56 +0000 |
commit | 5def7a57c19b0edbfcdd8fc35621ed056aabbe88 (patch) | |
tree | eba0dbef98fac3afcb712958732c060b4340999c /llvm/lib/ExecutionEngine/ExecutionEngine.cpp | |
parent | db5b8f4d6b6817cb7b8237cb2d83011d9a339979 (diff) | |
download | bcm5719-llvm-5def7a57c19b0edbfcdd8fc35621ed056aabbe88.tar.gz bcm5719-llvm-5def7a57c19b0edbfcdd8fc35621ed056aabbe88.zip |
Fix PR296: [execution engines] Unhandled cast constant expression
llvm-svn: 12435
Diffstat (limited to 'llvm/lib/ExecutionEngine/ExecutionEngine.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/ExecutionEngine.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp index 4e45bfa24ec..ba21f40ffac 100644 --- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp @@ -179,19 +179,30 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { // automatically fold, just the ones involving pointers won't. // Constant *Op = CE->getOperand(0); + GenericValue GV = getConstantValue(Op); // Handle cast of pointer to pointer... if (Op->getType()->getPrimitiveID() == C->getType()->getPrimitiveID()) - return getConstantValue(Op); + return GV; // Handle a cast of pointer to any integral type... if (isa<PointerType>(Op->getType()) && C->getType()->isIntegral()) - return getConstantValue(Op); + return GV; - // Handle cast of long to pointer... - if (isa<PointerType>(C->getType()) && (Op->getType() == Type::LongTy || - Op->getType() == Type::ULongTy)) - return getConstantValue(Op); + // Handle cast of integer to a pointer... + if (isa<PointerType>(C->getType()) && Op->getType()->isIntegral()) + switch (Op->getType()->getPrimitiveID()) { + case Type::BoolTyID: return PTOGV((void*)(uintptr_t)GV.BoolVal); + case Type::SByteTyID: return PTOGV((void*)( intptr_t)GV.SByteVal); + case Type::UByteTyID: return PTOGV((void*)(uintptr_t)GV.UByteVal); + case Type::ShortTyID: return PTOGV((void*)( intptr_t)GV.ShortVal); + case Type::UShortTyID: return PTOGV((void*)(uintptr_t)GV.UShortVal); + case Type::IntTyID: return PTOGV((void*)( intptr_t)GV.IntVal); + case Type::UIntTyID: return PTOGV((void*)(uintptr_t)GV.UIntVal); + case Type::LongTyID: return PTOGV((void*)( intptr_t)GV.LongVal); + case Type::ULongTyID: return PTOGV((void*)(uintptr_t)GV.ULongVal); + default: assert(0 && "Unknown integral type!"); + } break; } |