From: Robert Lytton Date: Tue, 11 Feb 2014 10:34:51 +0000 (+0000) Subject: XCore target: add section information. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db3db1b0869cbff787e5f6b21b11343e28e7d4da;p=clang XCore target: add section information. Xcore target ABI requires const data that is externally visible to be handled differently if it has C-language linkage rather than C++ language linkage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201142 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 7b1eab9721..7392ec6e87 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1578,6 +1578,12 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, 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"); + return GV; } diff --git a/test/CodeGen/xcore-abi.c b/test/CodeGen/xcore-abi.c index f92f52e2c1..6dbc44b559 100644 --- a/test/CodeGen/xcore-abi.c +++ b/test/CodeGen/xcore-abi.c @@ -10,8 +10,13 @@ _Static_assert(_Alignof(double) == 4, "alignof double is wrong"); // CHECK: target triple = "xcore-unknown-unknown" +// CHECK: @cgx = external constant i32, section ".cp.rodata" +extern const int cgx; +int fcgx() { return cgx;} // CHECK: @g1 = global i32 0, align 4 int g1; +// CHECK: @cg1 = constant i32 0, section ".cp.rodata", align 4 +const int cg1; #include struct x { int a[5]; };