diff -r 3ce0c312a40b configure.ac
--- a/configure.ac	Mon Apr 29 18:39:07 2013 -0400
+++ b/configure.ac	Tue Apr 30 21:10:53 2013 +0800
@@ -766,6 +766,11 @@
     AC_CHECK_HEADER([llvm/Support/TargetSelect.h], [
       warn_llvm=
       XTRA_CXXFLAGS="$XTRA_CXXFLAGS $LLVM_CXXFLAGS $LLVM_CPPFLAGS"])
+    OCTAVE_LLVM_IRBUILDER_HEADER
+    OCTAVE_LLVM_DATALAYOUT_HEADER
+    OCTAVE_LLVM_FUNCTION_ADDATTRIBUTE_API
+    OCTAVE_LLVM_FUNCTION_ADDFNATTR_API
+    OCTAVE_LLVM_CALLINST_ADDATTRIBUTE_API
     AC_LANG_POP(C++)
     CPPFLAGS="$save_CPPFLAGS"
     CXXFLAGS="$save_CXXFLAGS"
diff -r 3ce0c312a40b libinterp/interp-core/jit-typeinfo.cc
--- a/libinterp/interp-core/jit-typeinfo.cc	Mon Apr 29 18:39:07 2013 -0400
+++ b/libinterp/interp-core/jit-typeinfo.cc	Tue Apr 30 21:10:53 2013 +0800
@@ -39,7 +39,11 @@
 #include <llvm/Function.h>
 #include <llvm/Instructions.h>
 #include <llvm/Intrinsics.h>
+#ifdef IRBUILDER_HEADER_IN_SUPPORT_DIR
 #include <llvm/Support/IRBuilder.h>
+#else
+#include <llvm/IRBuilder.h>
+#endif
 #include <llvm/Support/raw_os_ostream.h>
 
 #include "jit-ir.h"
@@ -576,11 +580,24 @@
   llvm_function = llvm::Function::Create (ft, llvm::Function::ExternalLinkage,
                                           aname, module);
 
-  if (sret ())
-    llvm_function->addAttribute (1, llvm::Attribute::StructRet);
+  if (sret ()) 
+    {
+#ifdef FUNCTION_ADDATTRIBUTE_ARG_IS_ATTRIBUTES
+      llvm::AttrBuilder attr_builder;
+      attr_builder.addAttribute(llvm::Attributes::StructRet);
+      llvm::Attributes attrs = llvm::Attributes::get(context, attr_builder);
+      llvm_function->addAttribute (1, attrs);
+#else
+      llvm_function->addAttribute (1, llvm::Attribute::StructRet);
+#endif
+    }
 
   if (call_conv == jit_convention::internal)
+#ifdef FUNCTION_ADDFNATTR_ARG_IS_ATTRIBUTES
+    llvm_function->addFnAttr (llvm::Attributes::AlwaysInline);
+#else
     llvm_function->addFnAttr (llvm::Attribute::AlwaysInline);
+#endif
 }
 
 jit_function::jit_function (const jit_function& fn, jit_type *aresult,
@@ -683,7 +700,14 @@
 
   if (sret ())
     {
+#ifdef CALLINST_ADDATTRIBUTE_ARG_IS_ATTRIBUTES
+      llvm::AttrBuilder attr_builder;
+      attr_builder.addAttribute(llvm::Attributes::StructRet);
+      llvm::Attributes attrs = llvm::Attributes::get(context, attr_builder); 
+      callinst->addAttribute (1, attrs);
+#else
       callinst->addAttribute (1, llvm::Attribute::StructRet);
+#endif
       ret = builder.CreateLoad (sret_mem);
     }
 
diff -r 3ce0c312a40b libinterp/interp-core/pt-jit.cc
--- a/libinterp/interp-core/pt-jit.cc	Mon Apr 29 18:39:07 2013 -0400
+++ b/libinterp/interp-core/pt-jit.cc	Tue Apr 30 21:10:53 2013 +0800
@@ -51,10 +51,18 @@
 #include <llvm/ExecutionEngine/JIT.h>
 #include <llvm/Module.h>
 #include <llvm/PassManager.h>
+#ifdef IRBUILDER_HEADER_IN_SUPPORT_DIR
 #include <llvm/Support/IRBuilder.h>
+#else
+#include <llvm/IRBuilder.h>
+#endif
 #include <llvm/Support/raw_os_ostream.h>
 #include <llvm/Support/TargetSelect.h>
+#ifdef HAVE_DATALAYOUT
+#include <llvm/DataLayout.h>
+#else
 #include <llvm/Target/TargetData.h>
+#endif
 #include <llvm/Transforms/IPO.h>
 #include <llvm/Transforms/Scalar.h>
 
@@ -1860,7 +1868,11 @@
   module_pass_manager->add (llvm::createAlwaysInlinerPass ());
 
   pass_manager = new llvm::FunctionPassManager (module);
+#if HAVE_DATALAYOUT
+  pass_manager->add (new llvm::DataLayout(*engine->getDataLayout ()));
+#else
   pass_manager->add (new llvm::TargetData(*engine->getTargetData ()));
+#endif
   pass_manager->add (llvm::createCFGSimplificationPass ());
   pass_manager->add (llvm::createBasicAliasAnalysisPass ());
   pass_manager->add (llvm::createPromoteMemoryToRegisterPass ());
diff -r 3ce0c312a40b m4/acinclude.m4
--- a/m4/acinclude.m4	Mon Apr 29 18:39:07 2013 -0400
+++ b/m4/acinclude.m4	Tue Apr 30 21:10:53 2013 +0800
@@ -1882,6 +1882,175 @@
       [Define to 1 if unordered_map requires the use of tr1 namespace.])
   fi
 ])
+dnl
+dnl Check whether IRBuilder.h is in Support directory.
+dnl
+AC_DEFUN([OCTAVE_LLVM_IRBUILDER_HEADER], [
+  AC_CHECK_HEADER([llvm/IRBuilder.h], [
+    octave_irbuilder_header_in_support_dir=no], [
+    AC_CHECK_HEADER([llvm/Support/IRBuilder.h], [
+      octave_irbuilder_header_in_support_dir=yes], [
+      AC_MSG_ERROR("IRBuilder.h is required.")
+    ])
+  ])
+  if test $octave_irbuilder_header_in_support_dir = yes; then
+    AC_DEFINE(IRBUILDER_HEADER_IN_SUPPORT_DIR, 1, 
+      [Define to 1 if IRBuilder.h in Support directory.])
+  fi
+])
+dnl
+dnl Detect TargetData.h or DataLayout.h.
+dnl
+AC_DEFUN([OCTAVE_LLVM_DATALAYOUT_HEADER], [
+  AC_CHECK_HEADER([llvm/DataLayout.h], [
+    octave_is_datalayout_header=yes], [
+    AC_CHECK_HEADER([llvm/Target/TargetData.h], [
+      octave_is_datalayout_header=no], [
+      AC_MSG_ERROR("DataLayout.h or Target/TargetData.h is required.")
+    ])
+  ])
+  if test $octave_is_datalayout_header = yes; then
+    AC_DEFINE(HAVE_DATALAYOUT, 1, 
+      [Define to 1 if DataLayout.h exist.])
+  fi
+])
+dnl
+dnl Check for Function::addAttribute API
+dnl
+AC_DEFUN([OCTAVE_LLVM_FUNCTION_ADDATTRIBUTE_API], [
+  AC_CACHE_CHECK([check llvm::Function::addAttribute arg type is llvm::Attributes], 
+    [octave_cv_function_addattribute_arg_is_attributes],
+    [AC_LANG_PUSH(C++)
+      AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([[
+          #include <llvm/Function.h>
+          #include <llvm/Attributes.h>
+          #include <llvm/LLVMContext.h>
+          ]], [[
+          llvm::Function *llvm_function;
+          llvm::AttrBuilder attr_builder;
+          attr_builder.addAttribute(llvm::Attributes::StructRet);
+          llvm::Attributes attrs = llvm::Attributes::get(llvm::getGlobalContext(), attr_builder);
+          llvm_function->addAttribute (1, attrs);
+        ]])],
+        octave_cv_function_addattribute_arg_is_attributes=yes, 
+        octave_cv_function_addattribute_arg_is_attributes=no)
+    AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_function_addattribute_arg_is_attributes = yes; then
+    AC_DEFINE(FUNCTION_ADDATTRIBUTE_ARG_IS_ATTRIBUTES, 1, 
+      [Define to 1 if llvm::Function:addAttribute arg type is llvm::Attributes.])
+  else
+    AC_CACHE_CHECK([check llvm::Function::addAttribute arg type is llvm::Attribute], 
+      [octave_cv_function_addattribute_arg_is_attribute],
+      [AC_LANG_PUSH(C++)
+        AC_COMPILE_IFELSE(
+          [AC_LANG_PROGRAM([[
+            #include <llvm/Function.h>
+            #include <llvm/Attributes.h>
+            ]], [[
+            llvm::Function *llvm_function;
+            llvm_function->addAttribute (1, llvm::Attribute::StructRet);
+          ]])],
+          octave_cv_function_addattribute_arg_is_attribute=yes, 
+          octave_cv_function_addattribute_arg_is_attribute=no)
+      AC_LANG_POP(C++)
+    ])
+    if test $octave_cv_function_addattribute_arg_is_attribute = no; then
+      AC_MSG_ERROR("llvm::Function::addAttribute is required.")      
+    fi
+  fi
+])
+dnl
+dnl Check for Function::addFnAttr API
+dnl
+AC_DEFUN([OCTAVE_LLVM_FUNCTION_ADDFNATTR_API], [
+  AC_CACHE_CHECK([check LLVM::Function::addFnAttr arg type is llvm::Attributes], 
+    [octave_cv_function_addfnattr_arg_is_attributes],
+    [AC_LANG_PUSH(C++)
+      AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([[
+          #include <llvm/Function.h>
+          #include <llvm/Attributes.h>
+          ]], [[
+          llvm::Function *llvm_function;
+          llvm_function->addFnAttr (llvm::Attributes::AlwaysInline);
+        ]])],
+        octave_cv_function_addfnattr_arg_is_attributes=yes, 
+        octave_cv_function_addfnattr_arg_is_attributes=no)
+    AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_function_addfnattr_arg_is_attributes = yes; then
+    AC_DEFINE(FUNCTION_ADDFNATTR_ARG_IS_ATTRIBUTES, 1, 
+      [Define to 1 if llvm::Function:addFnAttr arg type is llvm::Attributes.])
+  else
+    AC_CACHE_CHECK([check llvm::Function::addFnAttr arg type is llvm::Attribute], 
+      [octave_cv_function_addfnattr_arg_is_attribute],
+      [AC_LANG_PUSH(C++)
+        AC_COMPILE_IFELSE(
+          [AC_LANG_PROGRAM([[
+            #include <llvm/Function.h>
+            #include <llvm/Attributes.h>
+            ]], [[
+            llvm::Function *llvm_function;
+            llvm_function->addFnAttr (llvm::Attribute::AlwaysInline);
+          ]])],
+          octave_cv_function_addfnattr_arg_is_attribute=yes, 
+          octave_cv_function_addfnattr_arg_is_attribute=no)
+      AC_LANG_POP(C++)
+    ])
+    if test $octave_cv_function_addfnattr_arg_is_attribute = no; then
+      AC_MSG_ERROR("llvm::Function::addFnAttr is required.")      
+    fi
+  fi
+])
+dnl
+dnl Check for CallInst::addAttribute API
+dnl
+AC_DEFUN([OCTAVE_LLVM_CALLINST_ADDATTRIBUTE_API], [
+  AC_CACHE_CHECK([check LLVM::CallInst::addAttribute arg type is llvm::Attributes], 
+    [octave_cv_callinst_addattribute_arg_is_attributes],
+    [AC_LANG_PUSH(C++)
+      AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([[
+          #include <llvm/Instructions.h>
+          #include <llvm/Attributes.h>
+          #include <llvm/LLVMContext.h>
+          ]], [[
+          llvm::CallInst *callinst;
+          llvm::AttrBuilder attr_builder;
+          attr_builder.addAttribute(llvm::Attributes::StructRet);
+          llvm::Attributes attrs = llvm::Attributes::get(llvm::getGlobalContext(), attr_builder); 
+          callinst->addAttribute (1, attrs);
+        ]])],
+        octave_cv_callinst_addattribute_arg_is_attributes=yes, 
+        octave_cv_callinst_addattribute_arg_is_attributes=no)
+    AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_callinst_addattribute_arg_is_attributes = yes; then
+    AC_DEFINE(CALLINST_ADDATTRIBUTE_ARG_IS_ATTRIBUTES, 1, 
+      [Define to 1 if llvm::CallInst:addAttribute arg type is llvm::Attributes.])
+  else
+    AC_CACHE_CHECK([check LLVM::CallInst::addAttribute arg type is llvm::Attribute], 
+      [octave_cv_callinst_addattribute_arg_is_attribute],
+      [AC_LANG_PUSH(C++)
+        AC_COMPILE_IFELSE(
+          [AC_LANG_PROGRAM([[
+            #include <llvm/Instructions.h>
+            #include <llvm/Attributes.h>
+            ]], [[
+            llvm::CallInst *callinst;
+            callinst->addAttribute (1, llvm::Attribute::StructRet);
+          ]])],
+          octave_cv_callinst_addattribute_arg_is_attribute=yes, 
+          octave_cv_callinst_addattribute_arg_is_attribute=no)
+      AC_LANG_POP(C++)
+    ])
+    if test $octave_cv_callinst_addattribute_arg_is_attribute = no; then
+      AC_MSG_ERROR("llvm::CallInst::addAttribute is required.")      
+    fi    
+  fi
+])
 
 dnl         End of macros written by Octave developers
 dnl ------------------------------------------------------------
