Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -1631,17 +1631,18 @@ D->isStaticDataMember() && D->hasInit() && !D->isThisDeclarationADefinition()) EmitGlobalVarDefinition(D); + + // Handle XCore specific ABI requirements. + if (getTarget().getTriple().getArch() == llvm::Triple::xcore && + D->getLanguageLinkage() == CLanguageLinkage && + D->getType().isConstant(Context) && + isExternallyVisible(LV.getLinkage())) + GV->setSection(".cp.rodata"); } if (AddrSpace != Ty->getAddressSpace()) return llvm::ConstantExpr::getAddrSpaceCast(GV, Ty); - if (getTarget().getTriple().getArch() == llvm::Triple::xcore && - D->getLanguageLinkage() == CLanguageLinkage && - D->getType().isConstant(Context) && - isExternallyVisible(D->getLinkageAndVisibility().getLinkage())) - GV->setSection(".cp.rodata"); - getTargetCodeGenInfo().emitTargetMD(D, GV, *this); return GV; Index: test/CodeGen/xcore-abi.cpp =================================================================== --- /dev/null +++ test/CodeGen/xcore-abi.cpp @@ -0,0 +1,25 @@ +// REQUIRES: xcore-registered-target + +// RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - -x c++ %s | FileCheck %s + +// CHECK: target triple = "xcore-unknown-unknown" + + +// C++ constants are not placed into the ".cp.rodata" section. +// CHECK: @cgx = external constant i32 +extern const int cgx; +int fcgx() { return cgx;} +// CHECK: @g1 = global i32 0, align 4 +int g1; +// CHECK: @cg1 = constant i32 0, align 4 +extern const int cg1 = 0; + +// Make sure null 'VarDecl*' are not indirected. +class C { +public: + ~C(){}; +}; +C c; + +// CHECK: "no-frame-pointer-elim"="false" +// CHECK-NOT: "no-frame-pointer-elim-non-leaf"