aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2012-03-02 16:24:25 +0000
committerDaniel Dunbar <daniel@zuster.org>2012-03-02 16:24:25 +0000
commitc169e08f3ad678df4ffb87cbbe5096208f6bf40a (patch)
tree9b76f7a4f425cacc7419422470ad95db795caf76 /lib/CodeGen/CGExprScalar.cpp
parentedd1caec02d5a698594ed4070574974b6b2b49e8 (diff)
Revert r151879, r151880, "PR12145: Avoid emitting loads of constexpr variables in contexts where there" and "Fix buildbot: make this test less dependent on the value names in the produced IR."
They broke bootstrap. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151922 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--lib/CodeGen/CGExprScalar.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index f7ab880e6c..125e431bff 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -212,21 +212,18 @@ public:
// l-values.
Value *VisitDeclRefExpr(DeclRefExpr *E) {
Expr::EvalResult Result;
- bool IsReferenceConstant = false;
- QualType EvalTy = E->getType();
- if (!E->EvaluateAsRValue(Result, CGF.getContext())) {
- // If this is a reference, try to determine what it is bound to.
- if (!E->getDecl()->getType()->isReferenceType() ||
- !E->EvaluateAsLValue(Result, CGF.getContext()))
- return EmitLoadOfLValue(E);
-
- IsReferenceConstant = true;
- EvalTy = E->getDecl()->getType();
- }
+ if (!E->EvaluateAsRValue(Result, CGF.getContext()))
+ return EmitLoadOfLValue(E);
assert(!Result.HasSideEffects && "Constant declref with side-effect?!");
- llvm::Constant *C = CGF.CGM.EmitConstantValue(Result.Val, EvalTy, &CGF);
+ llvm::Constant *C;
+ if (Result.Val.isInt())
+ C = Builder.getInt(Result.Val.getInt());
+ else if (Result.Val.isFloat())
+ C = llvm::ConstantFP::get(VMContext, Result.Val.getFloat());
+ else
+ return EmitLoadOfLValue(E);
// Make sure we emit a debug reference to the global variable.
if (VarDecl *VD = dyn_cast<VarDecl>(E->getDecl())) {
@@ -236,9 +233,6 @@ public:
CGF.EmitDeclRefExprDbgValue(E, C);
}
- if (IsReferenceConstant)
- return EmitLoadOfLValue(CGF.MakeNaturalAlignAddrLValue(C, E->getType()));
-
return C;
}
Value *VisitObjCSelectorExpr(ObjCSelectorExpr *E) {