mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 13:35:38 +08:00
[ObjC] Mark loads from __NSArray0 and __NSDictionary0 as invariant.load.
Also, simplify code by calling MakeNaturalAlignAddrLValue. This is a follow-up to r300396. llvm-svn: 300454
This commit is contained in:
@@ -126,10 +126,12 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E,
|
||||
QualType IdTy(CGM.getContext().getObjCIdType());
|
||||
llvm::Constant *Constant =
|
||||
CGM.CreateRuntimeVariable(ConvertType(IdTy), ConstantName);
|
||||
Address Addr(Constant, Context.getTypeAlignInChars(IdTy));
|
||||
LValue LV = MakeAddrLValue(Addr, IdTy);
|
||||
return Builder.CreateBitCast(EmitLoadOfScalar(LV, E->getLocStart()),
|
||||
ConvertType(E->getType()));
|
||||
LValue LV = MakeNaturalAlignAddrLValue(Constant, IdTy);
|
||||
llvm::Value *Ptr = EmitLoadOfScalar(LV, E->getLocStart());
|
||||
cast<llvm::LoadInst>(Ptr)->setMetadata(
|
||||
CGM.getModule().getMDKindID("invariant.load"),
|
||||
llvm::MDNode::get(getLLVMContext(), None));
|
||||
return Builder.CreateBitCast(Ptr, ConvertType(E->getType()));
|
||||
}
|
||||
|
||||
// Compute the type of the array we're initializing.
|
||||
|
||||
@@ -41,7 +41,7 @@ void test_empty_dictionary() {
|
||||
|
||||
// CHECK-WITH-EMPTY-COLLECTIONS-LABEL: define void @test_empty_dictionary
|
||||
// CHECK-WITH-EMPTY-COLLECTIONS-NOT: ret void
|
||||
// CHECK-WITH-EMPTY-COLLECTIONS: load {{.*}} @__NSDictionary0__
|
||||
// CHECK-WITH-EMPTY-COLLECTIONS: load {{.*}} @__NSDictionary0__{{.*}}!invariant.load
|
||||
// CHECK-WITH-EMPTY-COLLECTIONS-NOT: ret void
|
||||
// CHECK-WITH-EMPTY-COLLECTIONS: {{call.*objc_retain\(}}
|
||||
// CHECK-WITH-EMPTY-COLLECTIONS-NOT: ret void
|
||||
|
||||
Reference in New Issue
Block a user