diff options
author | Jay Foad <jay.foad@gmail.com> | 2010-01-15 08:32:58 +0000 |
---|---|---|
committer | Jay Foad <jay.foad@gmail.com> | 2010-01-15 08:32:58 +0000 |
commit | bcbdbfb3459fd41ed69319642336a79b64939f54 (patch) | |
tree | 2a8900e3ef09017138a0f6f0305153febd78a8c7 /llvm/lib/ExecutionEngine | |
parent | abf6ba16127674658fbe2c95af3254b8fc7ed4e7 (diff) | |
download | bcm5719-llvm-bcbdbfb3459fd41ed69319642336a79b64939f54.tar.gz bcm5719-llvm-bcbdbfb3459fd41ed69319642336a79b64939f54.zip |
Fix http://llvm.org/PR6028, an assertion failure when an UndefValue of
integer type is used.
llvm-svn: 93509
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r-- | llvm/lib/ExecutionEngine/ExecutionEngine.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp index c466400393e..89c4290f234 100644 --- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp @@ -491,8 +491,22 @@ void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) { /// @brief Get a GenericValue for a Constant* GenericValue ExecutionEngine::getConstantValue(const Constant *C) { // If its undefined, return the garbage. - if (isa<UndefValue>(C)) - return GenericValue(); + if (isa<UndefValue>(C)) { + GenericValue Result; + switch (C->getType()->getTypeID()) { + case Type::IntegerTyID: + case Type::X86_FP80TyID: + case Type::FP128TyID: + case Type::PPC_FP128TyID: + // Although the value is undefined, we still have to construct an APInt + // with the correct bit width. + Result.IntVal = APInt(C->getType()->getPrimitiveSizeInBits(), 0); + break; + default: + break; + } + return Result; + } // If the value is a ConstantExpr if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) { |