Mark some functions as readonly for optimization.
Also, code cleanup, and fix comment.
Change-Id: Ia25e9bc6f02b5838b1cd18efc32d2084e6db0953
diff --git a/src/compiler_llvm/art_module.ll b/src/compiler_llvm/art_module.ll
index a2da2b6..35cfaac 100644
--- a/src/compiler_llvm/art_module.ll
+++ b/src/compiler_llvm/art_module.ll
@@ -35,7 +35,7 @@
; Thread
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-declare %JavaObject* @art_get_current_thread_from_code()
+declare %JavaObject* @art_get_current_thread_from_code() readonly
declare void @art_set_current_thread_from_code(%JavaObject*)
declare void @art_lock_object_from_code(%JavaObject*, %JavaObject*)
@@ -52,7 +52,7 @@
; Exception
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-declare i1 @art_is_exception_pending_from_code()
+declare i1 @art_is_exception_pending_from_code() readonly
declare void @art_throw_div_zero_from_code()
declare void @art_throw_array_bounds_from_code(i32, i32)
diff --git a/src/compiler_llvm/generated/art_module.cc b/src/compiler_llvm/generated/art_module.cc
index b3963ef..a337e40 100644
--- a/src/compiler_llvm/generated/art_module.cc
+++ b/src/compiler_llvm/generated/art_module.cc
@@ -359,6 +359,14 @@
func_art_get_current_thread_from_code->setCallingConv(CallingConv::C);
}
AttrListPtr func_art_get_current_thread_from_code_PAL;
+{
+ SmallVector<AttributeWithIndex, 4> Attrs;
+ AttributeWithIndex PAWI;
+ PAWI.Index = 4294967295U; PAWI.Attrs = Attribute::None | Attribute::ReadOnly;
+ Attrs.push_back(PAWI);
+ func_art_get_current_thread_from_code_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
+
+}
func_art_get_current_thread_from_code->setAttributes(func_art_get_current_thread_from_code_PAL);
Function* func_art_set_current_thread_from_code = mod->getFunction("art_set_current_thread_from_code");
@@ -436,6 +444,14 @@
func_art_is_exception_pending_from_code->setCallingConv(CallingConv::C);
}
AttrListPtr func_art_is_exception_pending_from_code_PAL;
+{
+ SmallVector<AttributeWithIndex, 4> Attrs;
+ AttributeWithIndex PAWI;
+ PAWI.Index = 4294967295U; PAWI.Attrs = Attribute::None | Attribute::ReadOnly;
+ Attrs.push_back(PAWI);
+ func_art_is_exception_pending_from_code_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
+
+}
func_art_is_exception_pending_from_code->setAttributes(func_art_is_exception_pending_from_code_PAL);
Function* func_art_throw_div_zero_from_code = mod->getFunction("art_throw_div_zero_from_code");
diff --git a/src/compiler_llvm/ir_builder.h b/src/compiler_llvm/ir_builder.h
index 4b7642d..93a7f19 100644
--- a/src/compiler_llvm/ir_builder.h
+++ b/src/compiler_llvm/ir_builder.h
@@ -90,10 +90,10 @@
return CreateStore(val, ptr, tbaa_.GetMemoryJType(special_ty, j_ty));
}
- llvm::Value* LoadFromObjectOffset(llvm::Value* object_addr,
- int64_t offset,
- llvm::Type* type,
- TBAASpecialType special_ty) {
+ llvm::LoadInst* LoadFromObjectOffset(llvm::Value* object_addr,
+ int64_t offset,
+ llvm::Type* type,
+ TBAASpecialType special_ty) {
return LoadFromObjectOffset(object_addr, offset, type, tbaa_.GetSpecialType(special_ty));
}
@@ -149,10 +149,10 @@
return CreatePtrDisp(base, total_offset, ret_ty);
}
- llvm::Value* LoadFromObjectOffset(llvm::Value* object_addr,
- int64_t offset,
- llvm::Type* type,
- llvm::MDNode* tbaa_info) {
+ llvm::LoadInst* LoadFromObjectOffset(llvm::Value* object_addr,
+ int64_t offset,
+ llvm::Type* type,
+ llvm::MDNode* tbaa_info) {
// Convert offset to llvm::value
llvm::Value* llvm_offset = getPtrEquivInt(offset);
// Calculate the value's address
diff --git a/src/compiler_llvm/runtime_support_builder.cc b/src/compiler_llvm/runtime_support_builder.cc
index 77cb468..f4343fc 100644
--- a/src/compiler_llvm/runtime_support_builder.cc
+++ b/src/compiler_llvm/runtime_support_builder.cc
@@ -56,15 +56,7 @@
void RuntimeSupportBuilder::MakeFunctionInline(llvm::Function* func) {
func->setLinkage(GlobalValue::LinkOnceODRLinkage);
-
- SmallVector<AttributeWithIndex, 4> Attrs;
- AttributeWithIndex PAWI;
- PAWI.Index = ~0U;
- PAWI.Attrs = Attribute::None | Attribute::NoUnwind | Attribute::AlwaysInline;
- Attrs.push_back(PAWI);
- AttrListPtr func_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
-
- func->setAttributes(func_PAL);
+ func->addFnAttr(Attribute::AlwaysInline);
}
void RuntimeSupportBuilder::OverrideRuntimeSupportFunction(RuntimeId id, llvm::Function* function) {
diff --git a/src/compiler_llvm/runtime_support_builder_arm.cc b/src/compiler_llvm/runtime_support_builder_arm.cc
index 6029d3e..6d5c1e7 100644
--- a/src/compiler_llvm/runtime_support_builder_arm.cc
+++ b/src/compiler_llvm/runtime_support_builder_arm.cc
@@ -44,7 +44,8 @@
irb_.SetInsertPoint(basic_block);
InlineAsm* get_r9 = InlineAsm::get(func->getFunctionType(), "mov $0, r9", "=r", false);
- Value* r9 = irb_.CreateCall(get_r9);
+ CallInst* r9 = irb_.CreateCall(get_r9);
+ r9->setOnlyReadsMemory();
irb_.CreateRet(r9);
VERIFY_LLVM_FUNCTION(*func);
diff --git a/src/compiler_llvm/runtime_support_builder_x86.cc b/src/compiler_llvm/runtime_support_builder_x86.cc
index ee5f6d8..fa73020 100644
--- a/src/compiler_llvm/runtime_support_builder_x86.cc
+++ b/src/compiler_llvm/runtime_support_builder_x86.cc
@@ -49,7 +49,8 @@
/*Params=*/func_ty_args,
/*isVarArg=*/false);
InlineAsm* get_fp = InlineAsm::get(func_ty, "movl %fs:($1), $0", "=r,r", false);
- Value* fp = irb_.CreateCall(get_fp, irb_.getPtrEquivInt(Thread::SelfOffset().Int32Value()));
+ CallInst* fp = irb_.CreateCall(get_fp, irb_.getPtrEquivInt(Thread::SelfOffset().Int32Value()));
+ fp->setOnlyReadsMemory();
irb_.CreateRet(fp);
VERIFY_LLVM_FUNCTION(*func);
diff --git a/src/compiler_llvm/tbaa_info.h b/src/compiler_llvm/tbaa_info.h
index 1fe9314..9c0e250 100644
--- a/src/compiler_llvm/tbaa_info.h
+++ b/src/compiler_llvm/tbaa_info.h
@@ -52,7 +52,7 @@
llvm::LLVMContext& context_;
llvm::MDNode* root_;
llvm::MDNode* special_type_[MAX_TBAA_SPECIAL_TYPE];
- // There are 3 categories of memory types will not alias: array element, identified field, and
+ // There are 3 categories of memory types will not alias: array element, instance field, and
// static field.
llvm::MDNode* memory_jtype_[3][MAX_JTYPE];
};