[cfe-commits] r92176 - /cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Anton Korobeynikov asl at math.spbu.ru
Sun Dec 27 06:27:22 PST 2009


Author: asl
Date: Sun Dec 27 08:27:22 2009
New Revision: 92176

URL: http://llvm.org/viewvc/llvm-project?rev=92176&view=rev
Log:
Promote arguments of frameaddr / returnaddr builtins to i32 type, when needed.
This is needed for the platforms, where bitwidth of "int" is not 32 bits
(e.g. 16 on msp430).

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=92176&r1=92175&r2=92176&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Dec 27 08:27:22 2009
@@ -340,12 +340,20 @@
     return RValue::get(Address);
   }
   case Builtin::BI__builtin_return_address: {
+    Value *Depth = EmitScalarExpr(E->getArg(0));
+    Depth = Builder.CreateIntCast(Depth,
+                                  llvm::Type::getInt32Ty(VMContext),
+                                  false, "tmp");
     Value *F = CGM.getIntrinsic(Intrinsic::returnaddress, 0, 0);
-    return RValue::get(Builder.CreateCall(F, EmitScalarExpr(E->getArg(0))));
+    return RValue::get(Builder.CreateCall(F, Depth));
   }
   case Builtin::BI__builtin_frame_address: {
+    Value *Depth = EmitScalarExpr(E->getArg(0));
+    Depth = Builder.CreateIntCast(Depth,
+                                  llvm::Type::getInt32Ty(VMContext),
+                                  false, "tmp");
     Value *F = CGM.getIntrinsic(Intrinsic::frameaddress, 0, 0);
-    return RValue::get(Builder.CreateCall(F, EmitScalarExpr(E->getArg(0))));
+    return RValue::get(Builder.CreateCall(F, Depth));
   }
   case Builtin::BI__builtin_extract_return_addr: {
     // FIXME: There should be a target hook for this





More information about the cfe-commits mailing list