summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Lytton <robert@xmos.com>2014-02-11 10:34:51 +0000
committerRobert Lytton <robert@xmos.com>2014-02-11 10:34:51 +0000
commit15abd1881ff232a33f98a30c0d5b7e145a83e82c (patch)
tree7a6c1cc3a8782cc3848d072d5dd117868b3b3651
parent8e95d4e0758869e3172d23153f74e351f6238057 (diff)
downloadbcm5719-llvm-15abd1881ff232a33f98a30c0d5b7e145a83e82c.tar.gz
bcm5719-llvm-15abd1881ff232a33f98a30c0d5b7e145a83e82c.zip
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. llvm-svn: 201142
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp6
-rw-r--r--clang/test/CodeGen/xcore-abi.c5
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 7b1eab9721d..7392ec6e870 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/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/clang/test/CodeGen/xcore-abi.c b/clang/test/CodeGen/xcore-abi.c
index f92f52e2c11..6dbc44b5595 100644
--- a/clang/test/CodeGen/xcore-abi.c
+++ b/clang/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 <stdarg.h>
struct x { int a[5]; };
OpenPOWER on IntegriCloud