[cfe-commits] r97540 - in /cfe/trunk: include/clang/Basic/Builtins.def lib/CodeGen/CGBuiltin.cpp

John McCall rjmccall at apple.com
Mon Mar 1 18:31:24 PST 2010


Author: rjmccall
Date: Mon Mar  1 20:31:24 2010
New Revision: 97540

URL: http://llvm.org/viewvc/llvm-project?rev=97540&view=rev
Log:
After much consultation aimed at figuring out what this builtin actually
does, document the results and then implement __builtin_extend_pointer for
platforms where it's a no-op.


Modified:
    cfe/trunk/include/clang/Basic/Builtins.def
    cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=97540&r1=97539&r2=97540&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Mon Mar  1 20:31:24 2010
@@ -317,7 +317,7 @@
 BUILTIN(__builtin_dwarf_cfa, "v*", "n")
 BUILTIN(__builtin_init_dwarf_reg_size_table, "vv*", "n")
 BUILTIN(__builtin_dwarf_sp_column, "Ui", "n")
-BUILTIN(__builtin_extend_pointer, "iv*", "n")
+BUILTIN(__builtin_extend_pointer, "zv*", "n") // Really _Unwind_Ptr -> _Unwind_Word
 
 // GCC Object size checking builtins
 BUILTIN(__builtin_object_size, "zv*i", "n")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=97540&r1=97539&r2=97540&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Mar  1 20:31:24 2010
@@ -365,6 +365,22 @@
     Value *F = CGM.getIntrinsic(Intrinsic::eh_unwind_init, 0, 0);
     return RValue::get(Builder.CreateCall(F));
   }
+  case Builtin::BI__builtin_extend_pointer: {
+    // Extends a pointer to the size of an _Unwind_Word, which is
+    // generally a uint64_t.  Generally this gets poked directly into
+    // a register (or a "register" depending on platform) and then
+    // called, so if the pointer is shorter than a word we need to
+    // zext / sext based on the platform's expectations for pointers
+    // in registers.
+    //
+    // See: http://gcc.gnu.org/ml/gcc-bugs/2002-02/msg00237.html
+    //
+    // FIXME: ptrtoint always zexts; use a target hook if we start
+    // supporting targets where this matters.
+    Value *Ptr = EmitScalarExpr(E->getArg(0));
+    const llvm::Type *Ty = CGM.getTypes().ConvertType(E->getType());
+    return RValue::get(Builder.CreatePtrToInt(Ptr, Ty));
+  }
 #if 0
   // FIXME: Finish/enable when LLVM backend support stabilizes
   case Builtin::BI__builtin_setjmp: {





More information about the cfe-commits mailing list