diff options
author | Bob Wilson <bob.wilson@apple.com> | 2012-12-24 18:15:21 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2012-12-24 18:15:21 +0000 |
commit | a0be09f511c68a88ee95b73c8f0ebd78156a559e (patch) | |
tree | 678964cde398eea6351973aba975ccec327aad3b /lib/CodeGen | |
parent | fa45cdf646572cf11b03cfdaa63f75fd74fc7d34 (diff) |
Add LLVMContext::emitWarning methods and use them. <rdar://problem/12867368>
When the backend is used from clang, it should produce proper diagnostics
instead of just printing messages to errs(). Other clients may also want to
register their own error handlers with the LLVMContext, and the same handler
should work for warnings in the same way as the existing emitError methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171041 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/IntrinsicLowering.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp index 698d289f13..f289a9beac 100644 --- a/lib/CodeGen/IntrinsicLowering.cpp +++ b/lib/CodeGen/IntrinsicLowering.cpp @@ -413,22 +413,30 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { } case Intrinsic::stacksave: - case Intrinsic::stackrestore: { if (!Warned) - errs() << "WARNING: this target does not support the llvm.stack" - << (Callee->getIntrinsicID() == Intrinsic::stacksave ? - "save" : "restore") << " intrinsic.\n"; + Context.emitWarning("this target does not support the " + "llvm.stacksave intrinsic"); + Warned = true; + CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); + break; + + case Intrinsic::stackrestore: + if (!Warned) + Context.emitWarning("this target does not support the " + "llvm.stackrestore intrinsic"); Warned = true; - if (Callee->getIntrinsicID() == Intrinsic::stacksave) - CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); break; - } case Intrinsic::returnaddress: + Context.emitWarning("this target does not support the " + "llvm.returnaddress intrinsic"); + CI->replaceAllUsesWith(ConstantPointerNull::get( + cast<PointerType>(CI->getType()))); + break; + case Intrinsic::frameaddress: - errs() << "WARNING: this target does not support the llvm." - << (Callee->getIntrinsicID() == Intrinsic::returnaddress ? - "return" : "frame") << "address intrinsic.\n"; + Context.emitWarning("this target does not support the " + "llvm.frameaddress intrinsic"); CI->replaceAllUsesWith(ConstantPointerNull::get( cast<PointerType>(CI->getType()))); break; @@ -438,12 +446,12 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { case Intrinsic::pcmarker: break; // Simply strip out pcmarker on unsupported architectures - case Intrinsic::readcyclecounter: { - errs() << "WARNING: this target does not support the llvm.readcyclecoun" - << "ter intrinsic. It is being lowered to a constant 0\n"; + case Intrinsic::readcyclecounter: + Context.emitWarning("this target does not support the " + "llvm.readcyclecounter intrinsic; " + "it is being lowered to a constant 0"); CI->replaceAllUsesWith(ConstantInt::get(Type::getInt64Ty(Context), 0)); break; - } case Intrinsic::dbg_declare: break; // Simply strip out debugging intrinsics |