[cfe-commits] r51309 - in /cfe/trunk: lib/CodeGen/CGBuiltin.cpp test/CodeGen/builtin-stackaddress.c
Eli Friedman
eli.friedman at gmail.com
Tue May 20 01:59:34 PDT 2008
Author: efriedma
Date: Tue May 20 03:59:34 2008
New Revision: 51309
URL: http://llvm.org/viewvc/llvm-project?rev=51309&view=rev
Log:
Add codegen support for stack address intrinsics.
Added:
cfe/trunk/test/CodeGen/builtin-stackaddress.c
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=51309&r1=51308&r2=51309&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May 20 03:59:34 2008
@@ -262,6 +262,14 @@
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:
Added: cfe/trunk/test/CodeGen/builtin-stackaddress.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-stackaddress.c?rev=51309&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/builtin-stackaddress.c (added)
+++ cfe/trunk/test/CodeGen/builtin-stackaddress.c Tue May 20 03:59:34 2008
@@ -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);
+}
More information about the cfe-commits
mailing list