aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-05-19 20:40:02 +0000
committerAnders Carlsson <andersca@mac.com>2009-05-19 20:40:02 +0000
commitc8667a866bfc1d9f807282f2de5644d6aa4e9423 (patch)
tree02837bf44a5437baecfe5690b05287f1e5bc4d54 /lib
parentcd938172a40c6f1aca357cf7bad3cf6c208b6136 (diff)
Improve support for irgen of references.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72133 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/CGExpr.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index f7c3fd0976..ad0baa32f9 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -634,8 +634,10 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
LValue LV;
bool GCable = VD->hasLocalStorage() && !VD->hasAttr<BlocksAttr>();
if (VD->hasExternalStorage()) {
- LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD),
- E->getType().getCVRQualifiers(),
+ llvm::Value *V = CGM.GetAddrOfGlobalVar(VD);
+ if (VD->getType()->isReferenceType())
+ V = Builder.CreateLoad(V, "tmp");
+ LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers(),
getContext().getObjCGCAttrKind(E->getType()));
}
else {
@@ -657,13 +659,17 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
V = Builder.CreateBitCast(V, PtrStructTy);
V = Builder.CreateStructGEP(V, needsCopyDispose*2 + 4, "x");
}
+ if (VD->getType()->isReferenceType())
+ V = Builder.CreateLoad(V, "tmp");
LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers(), attr);
}
LValue::SetObjCNonGC(LV, GCable);
return LV;
} else if (VD && VD->isFileVarDecl()) {
- LValue LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD),
- E->getType().getCVRQualifiers(),
+ llvm::Value *V = CGM.GetAddrOfGlobalVar(VD);
+ if (VD->getType()->isReferenceType())
+ V = Builder.CreateLoad(V, "tmp");
+ LValue LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers(),
getContext().getObjCGCAttrKind(E->getType()));
if (LV.isObjCStrong())
LV.SetGlobalObjCRef(LV, true);