Add codegen support for stack address intrinsics.

llvm-svn: 51309
This commit is contained in:
Eli Friedman 2008-05-20 08:59:34 +00:00
parent 503731aa22
commit 53e38bd6b6
2 changed files with 24 additions and 0 deletions

View File

@ -262,6 +262,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
Builder.CreateCall(CGM.getMemCpyFn(), MemCpyOps, MemCpyOps+4);
return RValue::get(MemCpyOps[0]);
}
case Builtin::BI__builtin_return_address: {
Value *F = CGM.getIntrinsic(Intrinsic::returnaddress, 0, 0);
return RValue::get(Builder.CreateCall(F, EmitScalarExpr(E->getArg(0))));
}
case Builtin::BI__builtin_frame_address: {
Value *F = CGM.getIntrinsic(Intrinsic::frameaddress, 0, 0);
return RValue::get(Builder.CreateCall(F, EmitScalarExpr(E->getArg(0))));
}
case Builtin::BI__sync_fetch_and_add:
return EmitBinaryAtomic(*this, Intrinsic::atomic_las, E);
case Builtin::BI__sync_fetch_and_sub:

View File

@ -0,0 +1,16 @@
// RUN: clang -emit-llvm < %s
void* a(unsigned x) {
return __builtin_return_address(0);
}
void* c(unsigned x) {
return __builtin_frame_address(0);
}
// RUN: clang -emit-llvm < %s
void* a(unsigned x) {
return __builtin_return_address(0);
}
void* c(unsigned x) {
return __builtin_frame_address(0);
}