Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -1655,8 +1655,10 @@ if (getTarget().getTriple().getArch() == llvm::Triple::xcore && D->getLanguageLinkage() == CLanguageLinkage && D->getType().isConstant(Context) && - isExternallyVisible(D->getLinkageAndVisibility().getLinkage())) + isExternallyVisible(D->getLinkageAndVisibility().getLinkage())) { GV->setSection(".cp.rodata"); + GV->setAlignment(4); + } } if (AddrSpace != Ty->getAddressSpace()) @@ -1902,7 +1904,9 @@ GV->setConstant(!NeedsGlobalCtor && !NeedsGlobalDtor && isTypeConstant(D->getType(), true)); - GV->setAlignment(getContext().getDeclAlign(D).getQuantity()); + // Set the alignment if it has not already been set. + if (GV->getAlignment() == 0) + GV->setAlignment(getContext().getDeclAlign(D).getQuantity()); // Set the llvm linkage type as appropriate. llvm::GlobalValue::LinkageTypes Linkage = Index: test/CodeGen/xcore-abi.c =================================================================== --- test/CodeGen/xcore-abi.c +++ test/CodeGen/xcore-abi.c @@ -17,6 +17,9 @@ int g1; // CHECK: @cg1 = constant i32 0, section ".cp.rodata", align 4 const int cg1; +// CHECK: @cg2 = constant i8 0, section ".cp.rodata", align 4 +const char cg2; + #include struct x { int a[5]; };