summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-15 22:51:47 +0000
committerChris Lattner <sabre@nondot.org>2004-02-15 22:51:47 +0000
commite42cde2a14bb1d4dbb659d8ecdf7c73131532f1c (patch)
tree73f4a6150eaa6af0aa6715ff0ff701f606de20ca /lib
parent9b700f7951b07cb7be885c7560066c73733ef101 (diff)
downloadllvm-e42cde2a14bb1d4dbb659d8ecdf7c73131532f1c.tar.gz
llvm-e42cde2a14bb1d4dbb659d8ecdf7c73131532f1c.tar.bz2
llvm-e42cde2a14bb1d4dbb659d8ecdf7c73131532f1c.tar.xz
Now that the lowerinvoke pass inserts calls to llvm.setjmp/llvm.longjmp, some
hacks can be banished. Also, this gives us the opportunity to emit special code for the setjmp/longjmps which alows the elimination of one GCC warning for every setjmp/longjmp site (which is often THOUSANDS in C++ programs). Yaay! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11484 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/CBackend/CBackend.cpp17
-rw-r--r--lib/Target/CBackend/Writer.cpp17
2 files changed, 30 insertions, 4 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 0d36ea73c3..b52db0346a 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -686,8 +686,7 @@ bool CWriter::doInitialization(Module &M) {
Out << "\n/* Function Declarations */\n";
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
// Don't print declarations for intrinsic functions.
- if (!I->getIntrinsicID() &&
- I->getName() != "setjmp" && I->getName() != "longjmp") {
+ if (!I->getIntrinsicID()) {
printFunctionSignature(I, true);
if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__";
Out << ";\n";
@@ -1187,6 +1186,8 @@ void CWriter::lowerIntrinsics(Module &M) {
case Intrinsic::va_end:
case Intrinsic::returnaddress:
case Intrinsic::frameaddress:
+ case Intrinsic::setjmp:
+ case Intrinsic::longjmp:
// We directly implement these intrinsics
break;
default:
@@ -1245,6 +1246,18 @@ void CWriter::visitCallInst(CallInst &I) {
writeOperand(I.getOperand(1));
Out << ")";
return;
+ case Intrinsic::setjmp:
+ Out << "setjmp(*(jmp_buf*)";
+ writeOperand(I.getOperand(1));
+ Out << ")";
+ return;
+ case Intrinsic::longjmp:
+ Out << "longjmp(*(jmp_buf*)";
+ writeOperand(I.getOperand(1));
+ Out << ", ";
+ writeOperand(I.getOperand(2));
+ Out << ")";
+ return;
}
}
visitCallSite(&I);
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index 0d36ea73c3..b52db0346a 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -686,8 +686,7 @@ bool CWriter::doInitialization(Module &M) {
Out << "\n/* Function Declarations */\n";
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
// Don't print declarations for intrinsic functions.
- if (!I->getIntrinsicID() &&
- I->getName() != "setjmp" && I->getName() != "longjmp") {
+ if (!I->getIntrinsicID()) {
printFunctionSignature(I, true);
if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__";
Out << ";\n";
@@ -1187,6 +1186,8 @@ void CWriter::lowerIntrinsics(Module &M) {
case Intrinsic::va_end:
case Intrinsic::returnaddress:
case Intrinsic::frameaddress:
+ case Intrinsic::setjmp:
+ case Intrinsic::longjmp:
// We directly implement these intrinsics
break;
default:
@@ -1245,6 +1246,18 @@ void CWriter::visitCallInst(CallInst &I) {
writeOperand(I.getOperand(1));
Out << ")";
return;
+ case Intrinsic::setjmp:
+ Out << "setjmp(*(jmp_buf*)";
+ writeOperand(I.getOperand(1));
+ Out << ")";
+ return;
+ case Intrinsic::longjmp:
+ Out << "longjmp(*(jmp_buf*)";
+ writeOperand(I.getOperand(1));
+ Out << ", ";
+ writeOperand(I.getOperand(2));
+ Out << ")";
+ return;
}
}
visitCallSite(&I);