r209663 - Revert small change to EmitDeclRefLValue
Renato Golin
renato.golin at linaro.org
Tue May 27 09:46:27 PDT 2014
Author: rengolin
Date: Tue May 27 11:46:27 2014
New Revision: 209663
URL: http://llvm.org/viewvc/llvm-project?rev=209663&view=rev
Log:
Revert small change to EmitDeclRefLValue
That small change, although it looked harmless, it made emitting the LValue
on the PHI node without the proper cast. Reverting it fixes PR19841.
Added:
cfe/trunk/test/CodeGen/pr19841.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=209663&r1=209662&r2=209663&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue May 27 11:46:27 2014
@@ -1798,16 +1798,15 @@ LValue CodeGenFunction::EmitDeclRefLValu
const NamedDecl *ND = E->getDecl();
CharUnits Alignment = getContext().getDeclAlign(ND);
QualType T = E->getType();
- const auto *VD = dyn_cast<VarDecl>(ND);
- // Global Named registers access via intrinsics only
- if (VD && VD->getStorageClass() == SC_Register &&
- VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
- return EmitGlobalNamedRegister(VD, CGM, Alignment);
+ if (const auto *VD = dyn_cast<VarDecl>(ND)) {
+ // Global Named registers access via intrinsics only
+ if (VD->getStorageClass() == SC_Register &&
+ VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
+ return EmitGlobalNamedRegister(VD, CGM, Alignment);
- // A DeclRefExpr for a reference initialized by a constant expression can
- // appear without being odr-used. Directly emit the constant initializer.
- if (VD) {
+ // A DeclRefExpr for a reference initialized by a constant expression can
+ // appear without being odr-used. Directly emit the constant initializer.
const Expr *Init = VD->getAnyInitializer(VD);
if (Init && !isa<ParmVarDecl>(VD) && VD->getType()->isReferenceType() &&
VD->isUsableInConstantExpressions(getContext()) &&
@@ -1833,7 +1832,7 @@ LValue CodeGenFunction::EmitDeclRefLValu
return MakeAddrLValue(Aliasee, T, Alignment);
}
- if (VD) {
+ if (const auto *VD = dyn_cast<VarDecl>(ND)) {
// Check if this is a global variable.
if (VD->hasLinkage() || VD->isStaticDataMember())
return EmitGlobalVarDeclLValue(*this, E, VD);
Added: cfe/trunk/test/CodeGen/pr19841.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pr19841.cpp?rev=209663&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/pr19841.cpp (added)
+++ cfe/trunk/test/CodeGen/pr19841.cpp Tue May 27 11:46:27 2014
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+namespace Common {
+enum RenderMode {
+ kRenderEGA,
+ kRenderCGA
+};
+class C;
+class A {
+ A();
+ C *_vm;
+ unsigned char _highlightColorTableVGA[];
+ static const unsigned char b[];
+};
+class B {
+public:
+ Common::RenderMode _configRenderMode;
+};
+class C : public B {};
+A::A() {
+ 0 == Common::kRenderCGA || _vm->_configRenderMode == Common::kRenderEGA
+ ? b
+ : _highlightColorTableVGA;
+// Make sure the PHI value is casted correctly to the PHI type
+// CHECK: %cond-lvalue = phi [0 x i8]* [ bitcast ([1 x i8]* @_ZN6Common1A1bE to [0 x i8]*), %cond.true ], [ %_highlightColorTableVGA, %cond.false ]
+}
+const unsigned char A::b[] = { 0 };
+}
More information about the cfe-commits
mailing list