diff options
Diffstat (limited to 'backend/src')
-rw-r--r-- | backend/src/llvm/llvm_printf_parser.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/backend/src/llvm/llvm_printf_parser.cpp b/backend/src/llvm/llvm_printf_parser.cpp index 8e662b37..ab8e1a0a 100644 --- a/backend/src/llvm/llvm_printf_parser.cpp +++ b/backend/src/llvm/llvm_printf_parser.cpp @@ -822,6 +822,12 @@ error: case Type::DoubleTyID: case Type::FloatTyID: { + /* llvm 3.6 will give a undef value for NAN. */ + if (dyn_cast<llvm::UndefValue>(arg)) { + APFloat nan = APFloat::getNaN(APFloat::IEEEsingle, false); + arg = ConstantFP::get(module->getContext(), nan); + } + /* Because the printf is a variable parameter function, it does not have the function prototype, so the compiler will always promote the arg to the longest precise type for float. So here, we can always find it is double. */ |