[llvm] r192434 - XCore target fix bug in emitArrayBound() causing segmentation fault

Robert Lytton robert at xmos.com
Fri Oct 11 03:27:13 PDT 2013


Author: rlytton
Date: Fri Oct 11 05:27:13 2013
New Revision: 192434

URL: http://llvm.org/viewvc/llvm-project?rev=192434&view=rev
Log:
XCore target fix bug in emitArrayBound() causing segmentation fault

Modified:
    llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
    llvm/trunk/test/CodeGen/XCore/globals.ll
    llvm/trunk/test/CodeGen/XCore/linkage.ll

Modified: llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp?rev=192434&r1=192433&r2=192434&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp Fri Oct 11 05:27:13 2013
@@ -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(MCS
     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);
     }
   }
 }

Modified: llvm/trunk/test/CodeGen/XCore/globals.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/globals.ll?rev=192434&r1=192433&r2=192434&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/XCore/globals.ll (original)
+++ llvm/trunk/test/CodeGen/XCore/globals.ll Fri Oct 11 05:27:13 2013
@@ -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

Modified: llvm/trunk/test/CodeGen/XCore/linkage.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/linkage.ll?rev=192434&r1=192433&r2=192434&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/XCore/linkage.ll (original)
+++ llvm/trunk/test/CodeGen/XCore/linkage.ll Fri Oct 11 05:27:13 2013
@@ -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
+ at array = weak global [2 x i32] zeroinitializer
+
 ; CHECK: .weak gd
 @gd = weak global i32 0
 





More information about the llvm-commits mailing list