forked from OSchip/llvm-project
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
This commit is contained in:
parent
8e95d4e075
commit
15abd1881f
|
@ -1578,6 +1578,12 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
|
||||||
if (AddrSpace != Ty->getAddressSpace())
|
if (AddrSpace != Ty->getAddressSpace())
|
||||||
return llvm::ConstantExpr::getAddrSpaceCast(GV, Ty);
|
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;
|
return GV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,13 @@ _Static_assert(_Alignof(double) == 4, "alignof double is wrong");
|
||||||
|
|
||||||
// CHECK: target triple = "xcore-unknown-unknown"
|
// 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
|
// CHECK: @g1 = global i32 0, align 4
|
||||||
int g1;
|
int g1;
|
||||||
|
// CHECK: @cg1 = constant i32 0, section ".cp.rodata", align 4
|
||||||
|
const int cg1;
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
struct x { int a[5]; };
|
struct x { int a[5]; };
|
||||||
|
|
Loading…
Reference in New Issue