diff options
author | Robert Lytton <robert@xmos.com> | 2013-10-11 10:27:13 +0000 |
---|---|---|
committer | Robert Lytton <robert@xmos.com> | 2013-10-11 10:27:13 +0000 |
commit | ed0ed946ab6b84814ba09a6224d1ec4bfb9447b1 (patch) | |
tree | cc99abfd77f6a8cc9992160717a11e7701da2739 | |
parent | 4315b2b50413da09c3ac9bce07c77842f02ac929 (diff) | |
download | external_llvm-ed0ed946ab6b84814ba09a6224d1ec4bfb9447b1.zip external_llvm-ed0ed946ab6b84814ba09a6224d1ec4bfb9447b1.tar.gz external_llvm-ed0ed946ab6b84814ba09a6224d1ec4bfb9447b1.tar.bz2 |
XCore target fix bug in emitArrayBound() causing segmentation fault
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192434 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/XCore/XCoreAsmPrinter.cpp | 11 | ||||
-rw-r--r-- | test/CodeGen/XCore/globals.ll | 2 | ||||
-rw-r--r-- | test/CodeGen/XCore/linkage.ll | 7 |
3 files changed, 13 insertions, 7 deletions
diff --git a/lib/Target/XCore/XCoreAsmPrinter.cpp b/lib/Target/XCore/XCoreAsmPrinter.cpp index 35ba299..61511cd 100644 --- a/lib/Target/XCore/XCoreAsmPrinter.cpp +++ b/lib/Target/XCore/XCoreAsmPrinter.cpp @@ -36,6 +36,7 @@ #include "llvm/MC/MCInst.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/MC/MCExpr.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/raw_ostream.h" @@ -88,14 +89,12 @@ void XCoreAsmPrinter::emitArrayBound(MCSymbol *Sym, const GlobalVariable *GV) { MCSymbol *SymGlob = OutContext.GetOrCreateSymbol( Twine(Sym->getName() + StringRef(".globound"))); OutStreamer.EmitSymbolAttribute(SymGlob, MCSA_Global); - - OutStreamer.EmitRawText("\t.set\t" + Twine(Sym->getName()) + - ".globound," + Twine(ATy->getNumElements())); - + OutStreamer.EmitAssignment(SymGlob, + MCConstantExpr::Create(ATy->getNumElements(), + OutContext)); if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) { // TODO Use COMDAT groups for LinkOnceLinkage - OutStreamer.EmitRawText(MAI->getWeakDefDirective() +Twine(Sym->getName())+ - ".globound"); + OutStreamer.EmitSymbolAttribute(SymGlob, MCSA_Weak); } } } diff --git a/test/CodeGen/XCore/globals.ll b/test/CodeGen/XCore/globals.ll index b140587..b3a872b 100644 --- a/test/CodeGen/XCore/globals.ll +++ b/test/CodeGen/XCore/globals.ll @@ -93,4 +93,4 @@ entry: @array = global [10 x i16] zeroinitializer, align 2 ; CHECK: .globl array.globound -; CHECK: .set array.globound,10 +; CHECK: array.globound = 10 diff --git a/test/CodeGen/XCore/linkage.ll b/test/CodeGen/XCore/linkage.ll index 6599951..b29b035 100644 --- a/test/CodeGen/XCore/linkage.ll +++ b/test/CodeGen/XCore/linkage.ll @@ -16,6 +16,13 @@ define protected void @test_protected() { unreachable } +; CHECK: .globl array.globound +; CHECK: array.globound = 2 +; CHECK: .weak array.globound +; CHECK: .globl array +; CHECK: .weak array +@array = weak global [2 x i32] zeroinitializer + ; CHECK: .weak gd @gd = weak global i32 0 |