Changes to move to jb-mr2 based llvm

Change-Id: Iae8b2164f25146807662a6025a254fec6d40bb52
diff --git a/build/Android.libart-compiler.mk b/build/Android.libart-compiler.mk
index 389cc08..ac4bf42 100644
--- a/build/Android.libart-compiler.mk
+++ b/build/Android.libart-compiler.mk
@@ -140,7 +140,7 @@
     endif
     LOCAL_SHARED_LIBRARIES += libart
   endif
-  LOCAL_SHARED_LIBRARIES += libbcc
+  LOCAL_SHARED_LIBRARIES += libbcc libLLVM
 
   ifeq ($(ART_USE_PORTABLE_COMPILER),true)
     LOCAL_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
diff --git a/src/compiler/dex/compiler_ir.h b/src/compiler/dex/compiler_ir.h
index caa23d7..efae1f5 100644
--- a/src/compiler/dex/compiler_ir.h
+++ b/src/compiler/dex/compiler_ir.h
@@ -19,7 +19,7 @@
 
 #include <vector>
 
-#include <llvm/Module.h>
+#include <llvm/IR/Module.h>
 
 #include "compiler/dex/quick/codegen.h"
 #include "compiler/driver/compiler_driver.h"
diff --git a/src/compiler/dex/portable/mir_to_gbc.cc b/src/compiler/dex/portable/mir_to_gbc.cc
index afef7bf..af8e459 100644
--- a/src/compiler/dex/portable/mir_to_gbc.cc
+++ b/src/compiler/dex/portable/mir_to_gbc.cc
@@ -16,16 +16,16 @@
 
 #include "object_utils.h"
 
-#include <llvm/Support/ToolOutputFile.h>
-#include <llvm/Bitcode/ReaderWriter.h>
-#include <llvm/Analysis/Verifier.h>
-#include <llvm/Metadata.h>
 #include <llvm/ADT/DepthFirstIterator.h>
-#include <llvm/Instruction.h>
-#include <llvm/Type.h>
-#include <llvm/Instructions.h>
+#include <llvm/Analysis/Verifier.h>
+#include <llvm/Bitcode/ReaderWriter.h>
+#include <llvm/IR/Instruction.h>
+#include <llvm/IR/Instructions.h>
+#include <llvm/IR/Metadata.h>
+#include <llvm/IR/Type.h>
 #include <llvm/Support/Casting.h>
 #include <llvm/Support/InstIterator.h>
+#include <llvm/Support/ToolOutputFile.h>
 
 #include "compiler/dex/compiler_internals.h"
 #include "compiler/dex/dataflow_iterator.h"
diff --git a/src/compiler/invoke_stubs/portable/stub_compiler.cc b/src/compiler/invoke_stubs/portable/stub_compiler.cc
index ec6dc30..bc49c7a 100644
--- a/src/compiler/invoke_stubs/portable/stub_compiler.cc
+++ b/src/compiler/invoke_stubs/portable/stub_compiler.cc
@@ -26,10 +26,10 @@
 #include "compiler/llvm/utils_llvm.h"
 #include "mirror/abstract_method.h"
 
-#include <llvm/BasicBlock.h>
-#include <llvm/Function.h>
-#include <llvm/GlobalVariable.h>
-#include <llvm/Intrinsics.h>
+#include <llvm/IR/BasicBlock.h>
+#include <llvm/IR/Function.h>
+#include <llvm/IR/GlobalVariable.h>
+#include <llvm/IR/Intrinsics.h>
 
 #include <string>
 #include <string.h>
diff --git a/src/compiler/jni/portable/jni_compiler.cc b/src/compiler/jni/portable/jni_compiler.cc
index ecc1eb7..2795d05 100644
--- a/src/compiler/jni/portable/jni_compiler.cc
+++ b/src/compiler/jni/portable/jni_compiler.cc
@@ -32,11 +32,11 @@
 #include "stack.h"
 #include "thread.h"
 
-#include <llvm/BasicBlock.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
 #include <llvm/ADT/SmallVector.h>
-#include <llvm/Type.h>
+#include <llvm/IR/BasicBlock.h>
+#include <llvm/IR/DerivedTypes.h>
+#include <llvm/IR/Function.h>
+#include <llvm/IR/Type.h>
 
 namespace art {
 namespace llvm {
diff --git a/src/compiler/llvm/compiler_llvm.cc b/src/compiler/llvm/compiler_llvm.cc
index 3fbc55a..b57cbd7 100644
--- a/src/compiler/llvm/compiler_llvm.cc
+++ b/src/compiler/llvm/compiler_llvm.cc
@@ -32,7 +32,6 @@
 #include "verifier/method_verifier.h"
 
 #include <llvm/LinkAllPasses.h>
-#include <llvm/LinkAllVMCore.h>
 #include <llvm/Support/ManagedStatic.h>
 #include <llvm/Support/TargetSelect.h>
 #include <llvm/Support/Threading.h>
diff --git a/src/compiler/llvm/gbc_expander.cc b/src/compiler/llvm/gbc_expander.cc
index 2ae77a1..24f2032 100644
--- a/src/compiler/llvm/gbc_expander.cc
+++ b/src/compiler/llvm/gbc_expander.cc
@@ -33,8 +33,8 @@
 using art::kMIRIgnoreRangeCheck;
 
 #include <llvm/ADT/STLExtras.h>
-#include <llvm/Intrinsics.h>
-#include <llvm/Metadata.h>
+#include <llvm/IR/Intrinsics.h>
+#include <llvm/IR/Metadata.h>
 #include <llvm/Pass.h>
 #include <llvm/Support/CFG.h>
 #include <llvm/Support/InstIterator.h>
diff --git a/src/compiler/llvm/generated/art_module.cc b/src/compiler/llvm/generated/art_module.cc
index 2748cd6..bcd90b9 100644
--- a/src/compiler/llvm/generated/art_module.cc
+++ b/src/compiler/llvm/generated/art_module.cc
@@ -1,14 +1,14 @@
-// Generated with ../tools/gen_art_module_cc.sh
+// Generated with ./gen_art_module_cc.sh
 
 
 #pragma GCC diagnostic ignored "-Wframe-larger-than="
 // TODO: Remove this pragma after llc can generate makeLLVMModuleContents()
 // with smaller frame size.
 
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/Module.h>
-#include <llvm/Type.h>
+#include <llvm/IR/DerivedTypes.h>
+#include <llvm/IR/Function.h>
+#include <llvm/IR/Module.h>
+#include <llvm/IR/Type.h>
 
 #include <vector>
 
@@ -383,7 +383,7 @@
  /*Name=*/"__art_type_list", mod); // (external, no body)
 func___art_type_list->setCallingConv(CallingConv::C);
 }
-AttrListPtr func___art_type_list_PAL;
+AttributeSet func___art_type_list_PAL;
 func___art_type_list->setAttributes(func___art_type_list_PAL);
 
 Function* func_art_portable_get_current_thread_from_code = mod->getFunction("art_portable_get_current_thread_from_code");
@@ -394,7 +394,7 @@
  /*Name=*/"art_portable_get_current_thread_from_code", mod); // (external, no body)
 func_art_portable_get_current_thread_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_get_current_thread_from_code_PAL;
+AttributeSet func_art_portable_get_current_thread_from_code_PAL;
 func_art_portable_get_current_thread_from_code->setAttributes(func_art_portable_get_current_thread_from_code_PAL);
 
 Function* func_art_portable_set_current_thread_from_code = mod->getFunction("art_portable_set_current_thread_from_code");
@@ -405,7 +405,7 @@
  /*Name=*/"art_portable_set_current_thread_from_code", mod); // (external, no body)
 func_art_portable_set_current_thread_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_set_current_thread_from_code_PAL;
+AttributeSet func_art_portable_set_current_thread_from_code_PAL;
 func_art_portable_set_current_thread_from_code->setAttributes(func_art_portable_set_current_thread_from_code_PAL);
 
 Function* func_art_portable_lock_object_from_code = mod->getFunction("art_portable_lock_object_from_code");
@@ -416,7 +416,7 @@
  /*Name=*/"art_portable_lock_object_from_code", mod); // (external, no body)
 func_art_portable_lock_object_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_lock_object_from_code_PAL;
+AttributeSet func_art_portable_lock_object_from_code_PAL;
 func_art_portable_lock_object_from_code->setAttributes(func_art_portable_lock_object_from_code_PAL);
 
 Function* func_art_portable_unlock_object_from_code = mod->getFunction("art_portable_unlock_object_from_code");
@@ -427,7 +427,7 @@
  /*Name=*/"art_portable_unlock_object_from_code", mod); // (external, no body)
 func_art_portable_unlock_object_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_unlock_object_from_code_PAL;
+AttributeSet func_art_portable_unlock_object_from_code_PAL;
 func_art_portable_unlock_object_from_code->setAttributes(func_art_portable_unlock_object_from_code_PAL);
 
 Function* func_art_portable_test_suspend_from_code = mod->getFunction("art_portable_test_suspend_from_code");
@@ -438,7 +438,7 @@
  /*Name=*/"art_portable_test_suspend_from_code", mod); // (external, no body)
 func_art_portable_test_suspend_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_test_suspend_from_code_PAL;
+AttributeSet func_art_portable_test_suspend_from_code_PAL;
 func_art_portable_test_suspend_from_code->setAttributes(func_art_portable_test_suspend_from_code_PAL);
 
 Function* func_art_portable_push_shadow_frame_from_code = mod->getFunction("art_portable_push_shadow_frame_from_code");
@@ -449,7 +449,7 @@
  /*Name=*/"art_portable_push_shadow_frame_from_code", mod); // (external, no body)
 func_art_portable_push_shadow_frame_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_push_shadow_frame_from_code_PAL;
+AttributeSet func_art_portable_push_shadow_frame_from_code_PAL;
 func_art_portable_push_shadow_frame_from_code->setAttributes(func_art_portable_push_shadow_frame_from_code_PAL);
 
 Function* func_art_portable_pop_shadow_frame_from_code = mod->getFunction("art_portable_pop_shadow_frame_from_code");
@@ -460,7 +460,7 @@
  /*Name=*/"art_portable_pop_shadow_frame_from_code", mod); // (external, no body)
 func_art_portable_pop_shadow_frame_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_pop_shadow_frame_from_code_PAL;
+AttributeSet func_art_portable_pop_shadow_frame_from_code_PAL;
 func_art_portable_pop_shadow_frame_from_code->setAttributes(func_art_portable_pop_shadow_frame_from_code_PAL);
 
 Function* func_art_portable_get_and_clear_exception = mod->getFunction("art_portable_get_and_clear_exception");
@@ -471,7 +471,7 @@
  /*Name=*/"art_portable_get_and_clear_exception", mod); // (external, no body)
 func_art_portable_get_and_clear_exception->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_get_and_clear_exception_PAL;
+AttributeSet func_art_portable_get_and_clear_exception_PAL;
 func_art_portable_get_and_clear_exception->setAttributes(func_art_portable_get_and_clear_exception_PAL);
 
 Function* func_art_portable_throw_div_zero_from_code = mod->getFunction("art_portable_throw_div_zero_from_code");
@@ -482,7 +482,7 @@
  /*Name=*/"art_portable_throw_div_zero_from_code", mod); // (external, no body)
 func_art_portable_throw_div_zero_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_throw_div_zero_from_code_PAL;
+AttributeSet func_art_portable_throw_div_zero_from_code_PAL;
 func_art_portable_throw_div_zero_from_code->setAttributes(func_art_portable_throw_div_zero_from_code_PAL);
 
 Function* func_art_portable_throw_array_bounds_from_code = mod->getFunction("art_portable_throw_array_bounds_from_code");
@@ -493,7 +493,7 @@
  /*Name=*/"art_portable_throw_array_bounds_from_code", mod); // (external, no body)
 func_art_portable_throw_array_bounds_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_throw_array_bounds_from_code_PAL;
+AttributeSet func_art_portable_throw_array_bounds_from_code_PAL;
 func_art_portable_throw_array_bounds_from_code->setAttributes(func_art_portable_throw_array_bounds_from_code_PAL);
 
 Function* func_art_portable_throw_no_such_method_from_code = mod->getFunction("art_portable_throw_no_such_method_from_code");
@@ -504,7 +504,7 @@
  /*Name=*/"art_portable_throw_no_such_method_from_code", mod); // (external, no body)
 func_art_portable_throw_no_such_method_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_throw_no_such_method_from_code_PAL;
+AttributeSet func_art_portable_throw_no_such_method_from_code_PAL;
 func_art_portable_throw_no_such_method_from_code->setAttributes(func_art_portable_throw_no_such_method_from_code_PAL);
 
 Function* func_art_portable_throw_null_pointer_exception_from_code = mod->getFunction("art_portable_throw_null_pointer_exception_from_code");
@@ -515,7 +515,7 @@
  /*Name=*/"art_portable_throw_null_pointer_exception_from_code", mod); // (external, no body)
 func_art_portable_throw_null_pointer_exception_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_throw_null_pointer_exception_from_code_PAL;
+AttributeSet func_art_portable_throw_null_pointer_exception_from_code_PAL;
 func_art_portable_throw_null_pointer_exception_from_code->setAttributes(func_art_portable_throw_null_pointer_exception_from_code_PAL);
 
 Function* func_art_portable_throw_stack_overflow_from_code = mod->getFunction("art_portable_throw_stack_overflow_from_code");
@@ -526,7 +526,7 @@
  /*Name=*/"art_portable_throw_stack_overflow_from_code", mod); // (external, no body)
 func_art_portable_throw_stack_overflow_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_throw_stack_overflow_from_code_PAL;
+AttributeSet func_art_portable_throw_stack_overflow_from_code_PAL;
 func_art_portable_throw_stack_overflow_from_code->setAttributes(func_art_portable_throw_stack_overflow_from_code_PAL);
 
 Function* func_art_portable_throw_exception_from_code = mod->getFunction("art_portable_throw_exception_from_code");
@@ -537,7 +537,7 @@
  /*Name=*/"art_portable_throw_exception_from_code", mod); // (external, no body)
 func_art_portable_throw_exception_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_throw_exception_from_code_PAL;
+AttributeSet func_art_portable_throw_exception_from_code_PAL;
 func_art_portable_throw_exception_from_code->setAttributes(func_art_portable_throw_exception_from_code_PAL);
 
 Function* func_art_portable_find_catch_block_from_code = mod->getFunction("art_portable_find_catch_block_from_code");
@@ -548,7 +548,7 @@
  /*Name=*/"art_portable_find_catch_block_from_code", mod); // (external, no body)
 func_art_portable_find_catch_block_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_find_catch_block_from_code_PAL;
+AttributeSet func_art_portable_find_catch_block_from_code_PAL;
 func_art_portable_find_catch_block_from_code->setAttributes(func_art_portable_find_catch_block_from_code_PAL);
 
 Function* func_art_portable_alloc_object_from_code = mod->getFunction("art_portable_alloc_object_from_code");
@@ -559,7 +559,7 @@
  /*Name=*/"art_portable_alloc_object_from_code", mod); // (external, no body)
 func_art_portable_alloc_object_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_alloc_object_from_code_PAL;
+AttributeSet func_art_portable_alloc_object_from_code_PAL;
 func_art_portable_alloc_object_from_code->setAttributes(func_art_portable_alloc_object_from_code_PAL);
 
 Function* func_art_portable_alloc_object_from_code_with_access_check = mod->getFunction("art_portable_alloc_object_from_code_with_access_check");
@@ -570,7 +570,7 @@
  /*Name=*/"art_portable_alloc_object_from_code_with_access_check", mod); // (external, no body)
 func_art_portable_alloc_object_from_code_with_access_check->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_alloc_object_from_code_with_access_check_PAL;
+AttributeSet func_art_portable_alloc_object_from_code_with_access_check_PAL;
 func_art_portable_alloc_object_from_code_with_access_check->setAttributes(func_art_portable_alloc_object_from_code_with_access_check_PAL);
 
 Function* func_art_portable_alloc_array_from_code = mod->getFunction("art_portable_alloc_array_from_code");
@@ -581,7 +581,7 @@
  /*Name=*/"art_portable_alloc_array_from_code", mod); // (external, no body)
 func_art_portable_alloc_array_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_alloc_array_from_code_PAL;
+AttributeSet func_art_portable_alloc_array_from_code_PAL;
 func_art_portable_alloc_array_from_code->setAttributes(func_art_portable_alloc_array_from_code_PAL);
 
 Function* func_art_portable_alloc_array_from_code_with_access_check = mod->getFunction("art_portable_alloc_array_from_code_with_access_check");
@@ -592,7 +592,7 @@
  /*Name=*/"art_portable_alloc_array_from_code_with_access_check", mod); // (external, no body)
 func_art_portable_alloc_array_from_code_with_access_check->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_alloc_array_from_code_with_access_check_PAL;
+AttributeSet func_art_portable_alloc_array_from_code_with_access_check_PAL;
 func_art_portable_alloc_array_from_code_with_access_check->setAttributes(func_art_portable_alloc_array_from_code_with_access_check_PAL);
 
 Function* func_art_portable_check_and_alloc_array_from_code = mod->getFunction("art_portable_check_and_alloc_array_from_code");
@@ -603,7 +603,7 @@
  /*Name=*/"art_portable_check_and_alloc_array_from_code", mod); // (external, no body)
 func_art_portable_check_and_alloc_array_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_check_and_alloc_array_from_code_PAL;
+AttributeSet func_art_portable_check_and_alloc_array_from_code_PAL;
 func_art_portable_check_and_alloc_array_from_code->setAttributes(func_art_portable_check_and_alloc_array_from_code_PAL);
 
 Function* func_art_portable_check_and_alloc_array_from_code_with_access_check = mod->getFunction("art_portable_check_and_alloc_array_from_code_with_access_check");
@@ -614,7 +614,7 @@
  /*Name=*/"art_portable_check_and_alloc_array_from_code_with_access_check", mod); // (external, no body)
 func_art_portable_check_and_alloc_array_from_code_with_access_check->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_check_and_alloc_array_from_code_with_access_check_PAL;
+AttributeSet func_art_portable_check_and_alloc_array_from_code_with_access_check_PAL;
 func_art_portable_check_and_alloc_array_from_code_with_access_check->setAttributes(func_art_portable_check_and_alloc_array_from_code_with_access_check_PAL);
 
 Function* func_art_portable_find_instance_field_from_code = mod->getFunction("art_portable_find_instance_field_from_code");
@@ -625,7 +625,7 @@
  /*Name=*/"art_portable_find_instance_field_from_code", mod); // (external, no body)
 func_art_portable_find_instance_field_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_find_instance_field_from_code_PAL;
+AttributeSet func_art_portable_find_instance_field_from_code_PAL;
 func_art_portable_find_instance_field_from_code->setAttributes(func_art_portable_find_instance_field_from_code_PAL);
 
 Function* func_art_portable_find_static_field_from_code = mod->getFunction("art_portable_find_static_field_from_code");
@@ -636,7 +636,7 @@
  /*Name=*/"art_portable_find_static_field_from_code", mod); // (external, no body)
 func_art_portable_find_static_field_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_find_static_field_from_code_PAL;
+AttributeSet func_art_portable_find_static_field_from_code_PAL;
 func_art_portable_find_static_field_from_code->setAttributes(func_art_portable_find_static_field_from_code_PAL);
 
 Function* func_art_portable_find_static_method_from_code_with_access_check = mod->getFunction("art_portable_find_static_method_from_code_with_access_check");
@@ -647,7 +647,7 @@
  /*Name=*/"art_portable_find_static_method_from_code_with_access_check", mod); // (external, no body)
 func_art_portable_find_static_method_from_code_with_access_check->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_find_static_method_from_code_with_access_check_PAL;
+AttributeSet func_art_portable_find_static_method_from_code_with_access_check_PAL;
 func_art_portable_find_static_method_from_code_with_access_check->setAttributes(func_art_portable_find_static_method_from_code_with_access_check_PAL);
 
 Function* func_art_portable_find_direct_method_from_code_with_access_check = mod->getFunction("art_portable_find_direct_method_from_code_with_access_check");
@@ -658,7 +658,7 @@
  /*Name=*/"art_portable_find_direct_method_from_code_with_access_check", mod); // (external, no body)
 func_art_portable_find_direct_method_from_code_with_access_check->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_find_direct_method_from_code_with_access_check_PAL;
+AttributeSet func_art_portable_find_direct_method_from_code_with_access_check_PAL;
 func_art_portable_find_direct_method_from_code_with_access_check->setAttributes(func_art_portable_find_direct_method_from_code_with_access_check_PAL);
 
 Function* func_art_portable_find_virtual_method_from_code_with_access_check = mod->getFunction("art_portable_find_virtual_method_from_code_with_access_check");
@@ -669,7 +669,7 @@
  /*Name=*/"art_portable_find_virtual_method_from_code_with_access_check", mod); // (external, no body)
 func_art_portable_find_virtual_method_from_code_with_access_check->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_find_virtual_method_from_code_with_access_check_PAL;
+AttributeSet func_art_portable_find_virtual_method_from_code_with_access_check_PAL;
 func_art_portable_find_virtual_method_from_code_with_access_check->setAttributes(func_art_portable_find_virtual_method_from_code_with_access_check_PAL);
 
 Function* func_art_portable_find_super_method_from_code_with_access_check = mod->getFunction("art_portable_find_super_method_from_code_with_access_check");
@@ -680,7 +680,7 @@
  /*Name=*/"art_portable_find_super_method_from_code_with_access_check", mod); // (external, no body)
 func_art_portable_find_super_method_from_code_with_access_check->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_find_super_method_from_code_with_access_check_PAL;
+AttributeSet func_art_portable_find_super_method_from_code_with_access_check_PAL;
 func_art_portable_find_super_method_from_code_with_access_check->setAttributes(func_art_portable_find_super_method_from_code_with_access_check_PAL);
 
 Function* func_art_portable_find_interface_method_from_code_with_access_check = mod->getFunction("art_portable_find_interface_method_from_code_with_access_check");
@@ -691,7 +691,7 @@
  /*Name=*/"art_portable_find_interface_method_from_code_with_access_check", mod); // (external, no body)
 func_art_portable_find_interface_method_from_code_with_access_check->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_find_interface_method_from_code_with_access_check_PAL;
+AttributeSet func_art_portable_find_interface_method_from_code_with_access_check_PAL;
 func_art_portable_find_interface_method_from_code_with_access_check->setAttributes(func_art_portable_find_interface_method_from_code_with_access_check_PAL);
 
 Function* func_art_portable_find_interface_method_from_code = mod->getFunction("art_portable_find_interface_method_from_code");
@@ -702,7 +702,7 @@
  /*Name=*/"art_portable_find_interface_method_from_code", mod); // (external, no body)
 func_art_portable_find_interface_method_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_find_interface_method_from_code_PAL;
+AttributeSet func_art_portable_find_interface_method_from_code_PAL;
 func_art_portable_find_interface_method_from_code->setAttributes(func_art_portable_find_interface_method_from_code_PAL);
 
 Function* func_art_portable_initialize_static_storage_from_code = mod->getFunction("art_portable_initialize_static_storage_from_code");
@@ -713,7 +713,7 @@
  /*Name=*/"art_portable_initialize_static_storage_from_code", mod); // (external, no body)
 func_art_portable_initialize_static_storage_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_initialize_static_storage_from_code_PAL;
+AttributeSet func_art_portable_initialize_static_storage_from_code_PAL;
 func_art_portable_initialize_static_storage_from_code->setAttributes(func_art_portable_initialize_static_storage_from_code_PAL);
 
 Function* func_art_portable_initialize_type_from_code = mod->getFunction("art_portable_initialize_type_from_code");
@@ -724,7 +724,7 @@
  /*Name=*/"art_portable_initialize_type_from_code", mod); // (external, no body)
 func_art_portable_initialize_type_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_initialize_type_from_code_PAL;
+AttributeSet func_art_portable_initialize_type_from_code_PAL;
 func_art_portable_initialize_type_from_code->setAttributes(func_art_portable_initialize_type_from_code_PAL);
 
 Function* func_art_portable_initialize_type_and_verify_access_from_code = mod->getFunction("art_portable_initialize_type_and_verify_access_from_code");
@@ -735,7 +735,7 @@
  /*Name=*/"art_portable_initialize_type_and_verify_access_from_code", mod); // (external, no body)
 func_art_portable_initialize_type_and_verify_access_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_initialize_type_and_verify_access_from_code_PAL;
+AttributeSet func_art_portable_initialize_type_and_verify_access_from_code_PAL;
 func_art_portable_initialize_type_and_verify_access_from_code->setAttributes(func_art_portable_initialize_type_and_verify_access_from_code_PAL);
 
 Function* func_art_portable_resolve_string_from_code = mod->getFunction("art_portable_resolve_string_from_code");
@@ -746,7 +746,7 @@
  /*Name=*/"art_portable_resolve_string_from_code", mod); // (external, no body)
 func_art_portable_resolve_string_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_resolve_string_from_code_PAL;
+AttributeSet func_art_portable_resolve_string_from_code_PAL;
 func_art_portable_resolve_string_from_code->setAttributes(func_art_portable_resolve_string_from_code_PAL);
 
 Function* func_art_portable_set32_static_from_code = mod->getFunction("art_portable_set32_static_from_code");
@@ -757,7 +757,7 @@
  /*Name=*/"art_portable_set32_static_from_code", mod); // (external, no body)
 func_art_portable_set32_static_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_set32_static_from_code_PAL;
+AttributeSet func_art_portable_set32_static_from_code_PAL;
 func_art_portable_set32_static_from_code->setAttributes(func_art_portable_set32_static_from_code_PAL);
 
 Function* func_art_portable_set64_static_from_code = mod->getFunction("art_portable_set64_static_from_code");
@@ -768,7 +768,7 @@
  /*Name=*/"art_portable_set64_static_from_code", mod); // (external, no body)
 func_art_portable_set64_static_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_set64_static_from_code_PAL;
+AttributeSet func_art_portable_set64_static_from_code_PAL;
 func_art_portable_set64_static_from_code->setAttributes(func_art_portable_set64_static_from_code_PAL);
 
 Function* func_art_portable_set_obj_static_from_code = mod->getFunction("art_portable_set_obj_static_from_code");
@@ -779,7 +779,7 @@
  /*Name=*/"art_portable_set_obj_static_from_code", mod); // (external, no body)
 func_art_portable_set_obj_static_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_set_obj_static_from_code_PAL;
+AttributeSet func_art_portable_set_obj_static_from_code_PAL;
 func_art_portable_set_obj_static_from_code->setAttributes(func_art_portable_set_obj_static_from_code_PAL);
 
 Function* func_art_portable_get32_static_from_code = mod->getFunction("art_portable_get32_static_from_code");
@@ -790,7 +790,7 @@
  /*Name=*/"art_portable_get32_static_from_code", mod); // (external, no body)
 func_art_portable_get32_static_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_get32_static_from_code_PAL;
+AttributeSet func_art_portable_get32_static_from_code_PAL;
 func_art_portable_get32_static_from_code->setAttributes(func_art_portable_get32_static_from_code_PAL);
 
 Function* func_art_portable_get64_static_from_code = mod->getFunction("art_portable_get64_static_from_code");
@@ -801,7 +801,7 @@
  /*Name=*/"art_portable_get64_static_from_code", mod); // (external, no body)
 func_art_portable_get64_static_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_get64_static_from_code_PAL;
+AttributeSet func_art_portable_get64_static_from_code_PAL;
 func_art_portable_get64_static_from_code->setAttributes(func_art_portable_get64_static_from_code_PAL);
 
 Function* func_art_portable_get_obj_static_from_code = mod->getFunction("art_portable_get_obj_static_from_code");
@@ -812,7 +812,7 @@
  /*Name=*/"art_portable_get_obj_static_from_code", mod); // (external, no body)
 func_art_portable_get_obj_static_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_get_obj_static_from_code_PAL;
+AttributeSet func_art_portable_get_obj_static_from_code_PAL;
 func_art_portable_get_obj_static_from_code->setAttributes(func_art_portable_get_obj_static_from_code_PAL);
 
 Function* func_art_portable_set32_instance_from_code = mod->getFunction("art_portable_set32_instance_from_code");
@@ -823,7 +823,7 @@
  /*Name=*/"art_portable_set32_instance_from_code", mod); // (external, no body)
 func_art_portable_set32_instance_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_set32_instance_from_code_PAL;
+AttributeSet func_art_portable_set32_instance_from_code_PAL;
 func_art_portable_set32_instance_from_code->setAttributes(func_art_portable_set32_instance_from_code_PAL);
 
 Function* func_art_portable_set64_instance_from_code = mod->getFunction("art_portable_set64_instance_from_code");
@@ -834,7 +834,7 @@
  /*Name=*/"art_portable_set64_instance_from_code", mod); // (external, no body)
 func_art_portable_set64_instance_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_set64_instance_from_code_PAL;
+AttributeSet func_art_portable_set64_instance_from_code_PAL;
 func_art_portable_set64_instance_from_code->setAttributes(func_art_portable_set64_instance_from_code_PAL);
 
 Function* func_art_portable_set_obj_instance_from_code = mod->getFunction("art_portable_set_obj_instance_from_code");
@@ -845,7 +845,7 @@
  /*Name=*/"art_portable_set_obj_instance_from_code", mod); // (external, no body)
 func_art_portable_set_obj_instance_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_set_obj_instance_from_code_PAL;
+AttributeSet func_art_portable_set_obj_instance_from_code_PAL;
 func_art_portable_set_obj_instance_from_code->setAttributes(func_art_portable_set_obj_instance_from_code_PAL);
 
 Function* func_art_portable_get32_instance_from_code = mod->getFunction("art_portable_get32_instance_from_code");
@@ -856,7 +856,7 @@
  /*Name=*/"art_portable_get32_instance_from_code", mod); // (external, no body)
 func_art_portable_get32_instance_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_get32_instance_from_code_PAL;
+AttributeSet func_art_portable_get32_instance_from_code_PAL;
 func_art_portable_get32_instance_from_code->setAttributes(func_art_portable_get32_instance_from_code_PAL);
 
 Function* func_art_portable_get64_instance_from_code = mod->getFunction("art_portable_get64_instance_from_code");
@@ -867,7 +867,7 @@
  /*Name=*/"art_portable_get64_instance_from_code", mod); // (external, no body)
 func_art_portable_get64_instance_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_get64_instance_from_code_PAL;
+AttributeSet func_art_portable_get64_instance_from_code_PAL;
 func_art_portable_get64_instance_from_code->setAttributes(func_art_portable_get64_instance_from_code_PAL);
 
 Function* func_art_portable_get_obj_instance_from_code = mod->getFunction("art_portable_get_obj_instance_from_code");
@@ -878,7 +878,7 @@
  /*Name=*/"art_portable_get_obj_instance_from_code", mod); // (external, no body)
 func_art_portable_get_obj_instance_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_get_obj_instance_from_code_PAL;
+AttributeSet func_art_portable_get_obj_instance_from_code_PAL;
 func_art_portable_get_obj_instance_from_code->setAttributes(func_art_portable_get_obj_instance_from_code_PAL);
 
 Function* func_art_portable_decode_jobject_in_thread = mod->getFunction("art_portable_decode_jobject_in_thread");
@@ -889,7 +889,7 @@
  /*Name=*/"art_portable_decode_jobject_in_thread", mod); // (external, no body)
 func_art_portable_decode_jobject_in_thread->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_decode_jobject_in_thread_PAL;
+AttributeSet func_art_portable_decode_jobject_in_thread_PAL;
 func_art_portable_decode_jobject_in_thread->setAttributes(func_art_portable_decode_jobject_in_thread_PAL);
 
 Function* func_art_portable_fill_array_data_from_code = mod->getFunction("art_portable_fill_array_data_from_code");
@@ -900,7 +900,7 @@
  /*Name=*/"art_portable_fill_array_data_from_code", mod); // (external, no body)
 func_art_portable_fill_array_data_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_fill_array_data_from_code_PAL;
+AttributeSet func_art_portable_fill_array_data_from_code_PAL;
 func_art_portable_fill_array_data_from_code->setAttributes(func_art_portable_fill_array_data_from_code_PAL);
 
 Function* func_art_portable_is_assignable_from_code = mod->getFunction("art_portable_is_assignable_from_code");
@@ -911,7 +911,7 @@
  /*Name=*/"art_portable_is_assignable_from_code", mod); // (external, no body)
 func_art_portable_is_assignable_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_is_assignable_from_code_PAL;
+AttributeSet func_art_portable_is_assignable_from_code_PAL;
 func_art_portable_is_assignable_from_code->setAttributes(func_art_portable_is_assignable_from_code_PAL);
 
 Function* func_art_portable_check_cast_from_code = mod->getFunction("art_portable_check_cast_from_code");
@@ -922,7 +922,7 @@
  /*Name=*/"art_portable_check_cast_from_code", mod); // (external, no body)
 func_art_portable_check_cast_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_check_cast_from_code_PAL;
+AttributeSet func_art_portable_check_cast_from_code_PAL;
 func_art_portable_check_cast_from_code->setAttributes(func_art_portable_check_cast_from_code_PAL);
 
 Function* func_art_portable_check_put_array_element_from_code = mod->getFunction("art_portable_check_put_array_element_from_code");
@@ -933,7 +933,7 @@
  /*Name=*/"art_portable_check_put_array_element_from_code", mod); // (external, no body)
 func_art_portable_check_put_array_element_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_check_put_array_element_from_code_PAL;
+AttributeSet func_art_portable_check_put_array_element_from_code_PAL;
 func_art_portable_check_put_array_element_from_code->setAttributes(func_art_portable_check_put_array_element_from_code_PAL);
 
 Function* func_art_d2l = mod->getFunction("art_d2l");
@@ -944,7 +944,7 @@
  /*Name=*/"art_d2l", mod); // (external, no body)
 func_art_d2l->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_d2l_PAL;
+AttributeSet func_art_d2l_PAL;
 func_art_d2l->setAttributes(func_art_d2l_PAL);
 
 Function* func_art_d2i = mod->getFunction("art_d2i");
@@ -955,7 +955,7 @@
  /*Name=*/"art_d2i", mod); // (external, no body)
 func_art_d2i->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_d2i_PAL;
+AttributeSet func_art_d2i_PAL;
 func_art_d2i->setAttributes(func_art_d2i_PAL);
 
 Function* func_art_f2l = mod->getFunction("art_f2l");
@@ -966,7 +966,7 @@
  /*Name=*/"art_f2l", mod); // (external, no body)
 func_art_f2l->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_f2l_PAL;
+AttributeSet func_art_f2l_PAL;
 func_art_f2l->setAttributes(func_art_f2l_PAL);
 
 Function* func_art_f2i = mod->getFunction("art_f2i");
@@ -977,7 +977,7 @@
  /*Name=*/"art_f2i", mod); // (external, no body)
 func_art_f2i->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_f2i_PAL;
+AttributeSet func_art_f2i_PAL;
 func_art_f2i->setAttributes(func_art_f2i_PAL);
 
 Function* func_art_portable_jni_method_start = mod->getFunction("art_portable_jni_method_start");
@@ -988,7 +988,7 @@
  /*Name=*/"art_portable_jni_method_start", mod); // (external, no body)
 func_art_portable_jni_method_start->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_jni_method_start_PAL;
+AttributeSet func_art_portable_jni_method_start_PAL;
 func_art_portable_jni_method_start->setAttributes(func_art_portable_jni_method_start_PAL);
 
 Function* func_art_portable_jni_method_start_synchronized = mod->getFunction("art_portable_jni_method_start_synchronized");
@@ -999,7 +999,7 @@
  /*Name=*/"art_portable_jni_method_start_synchronized", mod); // (external, no body)
 func_art_portable_jni_method_start_synchronized->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_jni_method_start_synchronized_PAL;
+AttributeSet func_art_portable_jni_method_start_synchronized_PAL;
 func_art_portable_jni_method_start_synchronized->setAttributes(func_art_portable_jni_method_start_synchronized_PAL);
 
 Function* func_art_portable_jni_method_end = mod->getFunction("art_portable_jni_method_end");
@@ -1010,7 +1010,7 @@
  /*Name=*/"art_portable_jni_method_end", mod); // (external, no body)
 func_art_portable_jni_method_end->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_jni_method_end_PAL;
+AttributeSet func_art_portable_jni_method_end_PAL;
 func_art_portable_jni_method_end->setAttributes(func_art_portable_jni_method_end_PAL);
 
 Function* func_art_portable_jni_method_end_synchronized = mod->getFunction("art_portable_jni_method_end_synchronized");
@@ -1021,7 +1021,7 @@
  /*Name=*/"art_portable_jni_method_end_synchronized", mod); // (external, no body)
 func_art_portable_jni_method_end_synchronized->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_jni_method_end_synchronized_PAL;
+AttributeSet func_art_portable_jni_method_end_synchronized_PAL;
 func_art_portable_jni_method_end_synchronized->setAttributes(func_art_portable_jni_method_end_synchronized_PAL);
 
 Function* func_art_portable_jni_method_end_with_reference = mod->getFunction("art_portable_jni_method_end_with_reference");
@@ -1032,7 +1032,7 @@
  /*Name=*/"art_portable_jni_method_end_with_reference", mod); // (external, no body)
 func_art_portable_jni_method_end_with_reference->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_jni_method_end_with_reference_PAL;
+AttributeSet func_art_portable_jni_method_end_with_reference_PAL;
 func_art_portable_jni_method_end_with_reference->setAttributes(func_art_portable_jni_method_end_with_reference_PAL);
 
 Function* func_art_portable_jni_method_end_with_reference_synchronized = mod->getFunction("art_portable_jni_method_end_with_reference_synchronized");
@@ -1043,7 +1043,7 @@
  /*Name=*/"art_portable_jni_method_end_with_reference_synchronized", mod); // (external, no body)
 func_art_portable_jni_method_end_with_reference_synchronized->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_jni_method_end_with_reference_synchronized_PAL;
+AttributeSet func_art_portable_jni_method_end_with_reference_synchronized_PAL;
 func_art_portable_jni_method_end_with_reference_synchronized->setAttributes(func_art_portable_jni_method_end_with_reference_synchronized_PAL);
 
 Function* func_art_portable_is_exception_pending_from_code = mod->getFunction("art_portable_is_exception_pending_from_code");
@@ -1054,7 +1054,7 @@
  /*Name=*/"art_portable_is_exception_pending_from_code", mod); // (external, no body)
 func_art_portable_is_exception_pending_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_is_exception_pending_from_code_PAL;
+AttributeSet func_art_portable_is_exception_pending_from_code_PAL;
 func_art_portable_is_exception_pending_from_code->setAttributes(func_art_portable_is_exception_pending_from_code_PAL);
 
 Function* func_art_portable_mark_gc_card_from_code = mod->getFunction("art_portable_mark_gc_card_from_code");
@@ -1065,7 +1065,7 @@
  /*Name=*/"art_portable_mark_gc_card_from_code", mod); // (external, no body)
 func_art_portable_mark_gc_card_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_mark_gc_card_from_code_PAL;
+AttributeSet func_art_portable_mark_gc_card_from_code_PAL;
 func_art_portable_mark_gc_card_from_code->setAttributes(func_art_portable_mark_gc_card_from_code_PAL);
 
 Function* func_art_portable_proxy_invoke_handler_from_code = mod->getFunction("art_portable_proxy_invoke_handler_from_code");
@@ -1076,7 +1076,7 @@
  /*Name=*/"art_portable_proxy_invoke_handler_from_code", mod); // (external, no body)
 func_art_portable_proxy_invoke_handler_from_code->setCallingConv(CallingConv::C);
 }
-AttrListPtr func_art_portable_proxy_invoke_handler_from_code_PAL;
+AttributeSet func_art_portable_proxy_invoke_handler_from_code_PAL;
 func_art_portable_proxy_invoke_handler_from_code->setAttributes(func_art_portable_proxy_invoke_handler_from_code_PAL);
 
 // Global Variable Declarations
diff --git a/src/compiler/llvm/intrinsic_helper.cc b/src/compiler/llvm/intrinsic_helper.cc
index ac34f707..a34cb33 100644
--- a/src/compiler/llvm/intrinsic_helper.cc
+++ b/src/compiler/llvm/intrinsic_helper.cc
@@ -18,10 +18,11 @@
 
 #include "ir_builder.h"
 
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/IRBuilder.h>
-#include <llvm/Intrinsics.h>
+#include <llvm/IR/Attributes.h>
+#include <llvm/IR/DerivedTypes.h>
+#include <llvm/IR/Function.h>
+#include <llvm/IR/IRBuilder.h>
+#include <llvm/IR/Intrinsics.h>
 
 namespace art {
 namespace llvm {
@@ -136,10 +137,14 @@
                                                     ::llvm::Function::ExternalLinkage,
                                                      info.name_, &module);
 
-    fn->setOnlyReadsMemory(info.attr_ & kAttrReadOnly);
-    fn->setDoesNotAccessMemory(info.attr_ & kAttrReadNone);
+    if (info.attr_ & kAttrReadOnly) {
+        fn->setOnlyReadsMemory();
+    }
+    if (info.attr_ & kAttrReadNone) {
+        fn->setDoesNotAccessMemory();
+    }
     // None of the intrinsics throws exception
-    fn->setDoesNotThrow(true);
+    fn->setDoesNotThrow();
 
     intrinsic_funcs_[id] = fn;
 
@@ -150,8 +155,13 @@
     for (::llvm::Function::arg_iterator arg_iter = fn->arg_begin(),
             arg_end = fn->arg_end(); arg_iter != arg_end; arg_iter++) {
       if (arg_iter->getType()->isPointerTy()) {
-        arg_iter->addAttr(::llvm::Attribute::NoCapture);
-        arg_iter->addAttr(::llvm::Attribute::NoAlias);
+        std::vector< ::llvm::Attribute::AttrKind> attributes;
+        attributes.push_back(::llvm::Attribute::NoCapture);
+        attributes.push_back(::llvm::Attribute::NoAlias);
+        ::llvm::AttributeSet attribute_set = ::llvm::AttributeSet::get(fn->getContext(),
+                                                                       arg_iter->getArgNo(),
+                                                                       attributes);
+        arg_iter->addAttr(attribute_set);
       }
     }
 
diff --git a/src/compiler/llvm/ir_builder.cc b/src/compiler/llvm/ir_builder.cc
index 1fd1c90..a65cf2b 100644
--- a/src/compiler/llvm/ir_builder.cc
+++ b/src/compiler/llvm/ir_builder.cc
@@ -18,7 +18,7 @@
 
 #include "base/stringprintf.h"
 
-#include <llvm/Module.h>
+#include <llvm/IR/Module.h>
 
 namespace art {
 namespace llvm {
diff --git a/src/compiler/llvm/ir_builder.h b/src/compiler/llvm/ir_builder.h
index 32f0bf9..39f8fb1 100644
--- a/src/compiler/llvm/ir_builder.h
+++ b/src/compiler/llvm/ir_builder.h
@@ -24,12 +24,12 @@
 #include "runtime_support_builder.h"
 #include "runtime_support_func.h"
 
-#include <llvm/Constants.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/IRBuilder.h>
-#include <llvm/LLVMContext.h>
+#include <llvm/IR/Constants.h>
+#include <llvm/IR/DerivedTypes.h>
+#include <llvm/IR/IRBuilder.h>
+#include <llvm/IR/LLVMContext.h>
+#include <llvm/IR/Type.h>
 #include <llvm/Support/NoFolder.h>
-#include <llvm/Type.h>
 
 #include <stdint.h>
 
diff --git a/src/compiler/llvm/llvm_compilation_unit.cc b/src/compiler/llvm/llvm_compilation_unit.cc
index 94dfe72..8a674c0 100644
--- a/src/compiler/llvm/llvm_compilation_unit.cc
+++ b/src/compiler/llvm/llvm_compilation_unit.cc
@@ -14,6 +14,15 @@
  * limitations under the License.
  */
 
+// TODO: TargetLibraryInfo is included before sys/... because on Android bionic does #define tricks like:
+//
+// #define  stat64    stat
+// #define  fstat64   fstat
+// #define  lstat64   lstat
+// 
+// which causes grief. bionic probably should not do that.
+#include <llvm/Target/TargetLibraryInfo.h>
+
 #include "llvm_compilation_unit.h"
 
 #include <sys/types.h>
@@ -26,6 +35,7 @@
 #include <llvm/ADT/StringSet.h>
 #include <llvm/ADT/Triple.h>
 #include <llvm/Analysis/CallGraph.h>
+#include <llvm/Analysis/CallGraphSCCPass.h>
 #include <llvm/Analysis/Dominators.h>
 #include <llvm/Analysis/LoopInfo.h>
 #include <llvm/Analysis/LoopPass.h>
@@ -34,14 +44,14 @@
 #include <llvm/Analysis/Verifier.h>
 #include <llvm/Assembly/PrintModulePass.h>
 #include <llvm/Bitcode/ReaderWriter.h>
-#include <llvm/CallGraphSCCPass.h>
 #include <llvm/CodeGen/MachineFrameInfo.h>
 #include <llvm/CodeGen/MachineFunction.h>
 #include <llvm/CodeGen/MachineFunctionPass.h>
 #include <llvm/DebugInfo.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/LLVMContext.h>
-#include <llvm/Module.h>
+#include <llvm/IR/DataLayout.h>
+#include <llvm/IR/DerivedTypes.h>
+#include <llvm/IR/LLVMContext.h>
+#include <llvm/IR/Module.h>
 #include <llvm/Object/ObjectFile.h>
 #include <llvm/PassManager.h>
 #include <llvm/Support/Debug.h>
@@ -59,8 +69,6 @@
 #include <llvm/Support/ToolOutputFile.h>
 #include <llvm/Support/raw_ostream.h>
 #include <llvm/Support/system_error.h>
-#include <llvm/Target/TargetData.h>
-#include <llvm/Target/TargetLibraryInfo.h>
 #include <llvm/Target/TargetMachine.h>
 #include <llvm/Transforms/IPO.h>
 #include <llvm/Transforms/IPO/PassManagerBuilder.h>
@@ -220,15 +228,15 @@
   CHECK(target_machine.get() != NULL) << "Failed to create target machine";
 
   // Add target data
-  const ::llvm::TargetData* target_data = target_machine->getTargetData();
+  const ::llvm::DataLayout* data_layout = target_machine->getDataLayout();
 
   // PassManager for code generation passes
   ::llvm::PassManager pm;
-  pm.add(new ::llvm::TargetData(*target_data));
+  pm.add(new ::llvm::DataLayout(*data_layout));
 
   // FunctionPassManager for optimization pass
   ::llvm::FunctionPassManager fpm(module_);
-  fpm.add(new ::llvm::TargetData(*target_data));
+  fpm.add(new ::llvm::DataLayout(*data_layout));
 
   if (bitcode_filename_.empty()) {
     // If we don't need write the bitcode to file, add the AddSuspendCheckToLoopLatchPass to the
diff --git a/src/compiler/llvm/md_builder.cc b/src/compiler/llvm/md_builder.cc
index 657adc5..3884f51 100644
--- a/src/compiler/llvm/md_builder.cc
+++ b/src/compiler/llvm/md_builder.cc
@@ -17,7 +17,7 @@
 
 #include "md_builder.h"
 
-#include "llvm/MDBuilder.h"
+#include "llvm/IR/MDBuilder.h"
 
 #include <string>
 
diff --git a/src/compiler/llvm/md_builder.h b/src/compiler/llvm/md_builder.h
index 5272ee5..79a7caa 100644
--- a/src/compiler/llvm/md_builder.h
+++ b/src/compiler/llvm/md_builder.h
@@ -19,7 +19,7 @@
 
 #include "backend_types.h"
 
-#include "llvm/MDBuilder.h"
+#include "llvm/IR/MDBuilder.h"
 
 #include <cstring>
 
diff --git a/src/compiler/llvm/runtime_support_builder.cc b/src/compiler/llvm/runtime_support_builder.cc
index 4548d18..b4ddb55 100644
--- a/src/compiler/llvm/runtime_support_builder.cc
+++ b/src/compiler/llvm/runtime_support_builder.cc
@@ -22,10 +22,10 @@
 #include "mirror/object.h"
 #include "thread.h"
 
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/Module.h>
-#include <llvm/Type.h>
+#include <llvm/IR/DerivedTypes.h>
+#include <llvm/IR/Function.h>
+#include <llvm/IR/Module.h>
+#include <llvm/IR/Type.h>
 
 using namespace llvm;
 
diff --git a/src/compiler/llvm/runtime_support_builder_arm.cc b/src/compiler/llvm/runtime_support_builder_arm.cc
index 753ae9a..57a9971 100644
--- a/src/compiler/llvm/runtime_support_builder_arm.cc
+++ b/src/compiler/llvm/runtime_support_builder_arm.cc
@@ -20,11 +20,11 @@
 #include "thread.h"
 #include "utils_llvm.h"
 
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/InlineAsm.h>
-#include <llvm/Module.h>
-#include <llvm/Type.h>
+#include <llvm/IR/DerivedTypes.h>
+#include <llvm/IR/Function.h>
+#include <llvm/IR/InlineAsm.h>
+#include <llvm/IR/Module.h>
+#include <llvm/IR/Type.h>
 
 #include <vector>
 
diff --git a/src/compiler/llvm/runtime_support_builder_thumb2.cc b/src/compiler/llvm/runtime_support_builder_thumb2.cc
index c16717b..2b9170c 100644
--- a/src/compiler/llvm/runtime_support_builder_thumb2.cc
+++ b/src/compiler/llvm/runtime_support_builder_thumb2.cc
@@ -22,11 +22,11 @@
 #include "thread.h"
 #include "utils_llvm.h"
 
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/InlineAsm.h>
-#include <llvm/Module.h>
-#include <llvm/Type.h>
+#include <llvm/IR/DerivedTypes.h>
+#include <llvm/IR/Function.h>
+#include <llvm/IR/InlineAsm.h>
+#include <llvm/IR/Module.h>
+#include <llvm/IR/Type.h>
 
 #include <inttypes.h>
 #include <vector>
diff --git a/src/compiler/llvm/runtime_support_builder_x86.cc b/src/compiler/llvm/runtime_support_builder_x86.cc
index cd00b0b..eed0b63 100644
--- a/src/compiler/llvm/runtime_support_builder_x86.cc
+++ b/src/compiler/llvm/runtime_support_builder_x86.cc
@@ -21,11 +21,11 @@
 #include "thread.h"
 #include "utils_llvm.h"
 
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/InlineAsm.h>
-#include <llvm/Module.h>
-#include <llvm/Type.h>
+#include <llvm/IR/DerivedTypes.h>
+#include <llvm/IR/Function.h>
+#include <llvm/IR/InlineAsm.h>
+#include <llvm/IR/Module.h>
+#include <llvm/IR/Type.h>
 
 #include <vector>
 
diff --git a/src/compiler/llvm/tools/gen_art_module_cc.sh b/src/compiler/llvm/tools/gen_art_module_cc.sh
index b691bbf..c5df333 100755
--- a/src/compiler/llvm/tools/gen_art_module_cc.sh
+++ b/src/compiler/llvm/tools/gen_art_module_cc.sh
@@ -29,10 +29,10 @@
 // TODO: Remove this pragma after llc can generate makeLLVMModuleContents()
 // with smaller frame size.
 
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/Module.h>
-#include <llvm/Type.h>
+#include <llvm/IR/DerivedTypes.h>
+#include <llvm/IR/Function.h>
+#include <llvm/IR/Module.h>
+#include <llvm/IR/Type.h>
 
 #include <vector>