diff options
author | Robert Lytton <robert@xmos.com> | 2014-05-02 09:33:30 +0000 |
---|---|---|
committer | Robert Lytton <robert@xmos.com> | 2014-05-02 09:33:30 +0000 |
commit | b7993571cab59ac03f5f786d778819d0b7a47b6d (patch) | |
tree | b92bc2577a5c8c752879b8041618f234762e5bb8 | |
parent | 6f10763ffb8f8b786595a3352722adfb8b5555f9 (diff) | |
download | clang-b7993571cab59ac03f5f786d778819d0b7a47b6d.tar.gz clang-b7993571cab59ac03f5f786d778819d0b7a47b6d.tar.bz2 clang-b7993571cab59ac03f5f786d778819d0b7a47b6d.tar.xz |
XCore target: fix bug in dereferencing null pointer.
Also add basic cpp ABI tests where they differ from C ABI output.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207834 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 13 | ||||
-rw-r--r-- | test/CodeGen/xcore-abi.cpp | 27 |
2 files changed, 34 insertions, 6 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 11f69cc0fc..785c04cb39 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1607,17 +1607,18 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, if (getCXXABI().isInlineInitializedStaticDataMemberLinkOnce() && isVarDeclInlineInitializedStaticDataMember(D)) EmitGlobalVarDefinition(D); + + // Handle XCore specific ABI requirements. + if (getTarget().getTriple().getArch() == llvm::Triple::xcore && + D->getLanguageLinkage() == CLanguageLinkage && + D->getType().isConstant(Context) && + isExternallyVisible(D->getLinkageAndVisibility().getLinkage())) + GV->setSection(".cp.rodata"); } 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"); - getTargetCodeGenInfo().emitTargetMD(D, GV, *this); return GV; diff --git a/test/CodeGen/xcore-abi.cpp b/test/CodeGen/xcore-abi.cpp new file mode 100644 index 0000000000..fbf31ff50a --- /dev/null +++ b/test/CodeGen/xcore-abi.cpp @@ -0,0 +1,27 @@ +// REQUIRES: xcore-registered-target + +// RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - -x c++ %s | FileCheck %s + +// CHECK: target triple = "xcore-unknown-unknown" + + +// C++ constants are not placed into the ".cp.rodata" section. +// CHECK: @cgx = external constant i32 +extern const int cgx; +int fcgx() { return cgx;} +// CHECK: @g1 = global i32 0, align 4 +int g1; +// CHECK: @cg1 = constant i32 0, align 4 +extern const int cg1 = 0; + +// Regression test for a bug in lib/CodeGen/CodeGenModule.cpp which called +// getLanguageLinkage() via a null 'VarDecl*'. This was an XCore specific +// conditional call to GV->setSection(".cp.rodata"). +class C { +public: + ~C(){}; +}; +C c; + +// CHECK: "no-frame-pointer-elim"="false" +// CHECK-NOT: "no-frame-pointer-elim-non-leaf" |