r201142 - XCore target: add section information.
Robert Lytton
robert at xmos.com
Tue Feb 11 02:34:51 PST 2014
Author: rlytton
Date: Tue Feb 11 04:34:51 2014
New Revision: 201142
URL: http://llvm.org/viewvc/llvm-project?rev=201142&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/xcore-abi.c
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=201142&r1=201141&r2=201142&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Feb 11 04:34:51 2014
@@ -1578,6 +1578,12 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
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;
}
Modified: cfe/trunk/test/CodeGen/xcore-abi.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xcore-abi.c?rev=201142&r1=201141&r2=201142&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/xcore-abi.c (original)
+++ cfe/trunk/test/CodeGen/xcore-abi.c Tue Feb 11 04:34:51 2014
@@ -10,8 +10,13 @@ _Static_assert(_Alignof(double) == 4, "a
// 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]; };
More information about the cfe-commits
mailing list