mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
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
This commit is contained in:
@ -686,8 +686,7 @@ bool CWriter::doInitialization(Module &M) {
|
|||||||
Out << "\n/* Function Declarations */\n";
|
Out << "\n/* Function Declarations */\n";
|
||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
||||||
// Don't print declarations for intrinsic functions.
|
// Don't print declarations for intrinsic functions.
|
||||||
if (!I->getIntrinsicID() &&
|
if (!I->getIntrinsicID()) {
|
||||||
I->getName() != "setjmp" && I->getName() != "longjmp") {
|
|
||||||
printFunctionSignature(I, true);
|
printFunctionSignature(I, true);
|
||||||
if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__";
|
if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__";
|
||||||
Out << ";\n";
|
Out << ";\n";
|
||||||
@ -1187,6 +1186,8 @@ void CWriter::lowerIntrinsics(Module &M) {
|
|||||||
case Intrinsic::va_end:
|
case Intrinsic::va_end:
|
||||||
case Intrinsic::returnaddress:
|
case Intrinsic::returnaddress:
|
||||||
case Intrinsic::frameaddress:
|
case Intrinsic::frameaddress:
|
||||||
|
case Intrinsic::setjmp:
|
||||||
|
case Intrinsic::longjmp:
|
||||||
// We directly implement these intrinsics
|
// We directly implement these intrinsics
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1245,6 +1246,18 @@ void CWriter::visitCallInst(CallInst &I) {
|
|||||||
writeOperand(I.getOperand(1));
|
writeOperand(I.getOperand(1));
|
||||||
Out << ")";
|
Out << ")";
|
||||||
return;
|
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);
|
visitCallSite(&I);
|
||||||
|
@ -686,8 +686,7 @@ bool CWriter::doInitialization(Module &M) {
|
|||||||
Out << "\n/* Function Declarations */\n";
|
Out << "\n/* Function Declarations */\n";
|
||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
||||||
// Don't print declarations for intrinsic functions.
|
// Don't print declarations for intrinsic functions.
|
||||||
if (!I->getIntrinsicID() &&
|
if (!I->getIntrinsicID()) {
|
||||||
I->getName() != "setjmp" && I->getName() != "longjmp") {
|
|
||||||
printFunctionSignature(I, true);
|
printFunctionSignature(I, true);
|
||||||
if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__";
|
if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__";
|
||||||
Out << ";\n";
|
Out << ";\n";
|
||||||
@ -1187,6 +1186,8 @@ void CWriter::lowerIntrinsics(Module &M) {
|
|||||||
case Intrinsic::va_end:
|
case Intrinsic::va_end:
|
||||||
case Intrinsic::returnaddress:
|
case Intrinsic::returnaddress:
|
||||||
case Intrinsic::frameaddress:
|
case Intrinsic::frameaddress:
|
||||||
|
case Intrinsic::setjmp:
|
||||||
|
case Intrinsic::longjmp:
|
||||||
// We directly implement these intrinsics
|
// We directly implement these intrinsics
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1245,6 +1246,18 @@ void CWriter::visitCallInst(CallInst &I) {
|
|||||||
writeOperand(I.getOperand(1));
|
writeOperand(I.getOperand(1));
|
||||||
Out << ")";
|
Out << ")";
|
||||||
return;
|
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);
|
visitCallSite(&I);
|
||||||
|
Reference in New Issue
Block a user