[LLVMdev] RFC: Patch for CFA on Darwin

Bill Wendling isanbard at gmail.com
Wed Aug 22 15:20:58 PDT 2007


Hi all,

Here's a potential patch for LLVM-GCC:

Index: llvm-convert.cpp
===================================================================
--- llvm-convert.cpp    (revision 41260)
+++ llvm-convert.cpp    (working copy)
@@ -4240,11 +4240,12 @@
    return false;

  int cfa_offset = ARG_POINTER_CFA_OFFSET(0);
-
-  Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule,
-                                                      Intrinsic::eh_dwarf_cfa),
-                              ConstantInt::get(Type::Int32Ty, cfa_offset));
-
+  Result =
+    Builder.CreateCall(Intrinsic::getDeclaration(TheModule,
+                                                 Intrinsic::eh_dwarf_cfa),
+                       Builder.CreateIntToPtr(ConstantInt::get(Type::Int32Ty,
+                                                               cfa_offset),
+                                              ConvertType(TREE_TYPE(exp))));
  return true;
}


The reason for it: when going to calculate the CFA in LLVM, the
original code was adding an offset of type i32 to a pointer. This is
fine if pointers are 32-bits, but we get an assert if the types are
different. By converting the cfa_offset to a pointer, we get it to be
that size.

Comments?

-bw



More information about the llvm-dev mailing list