diff --git a/llvm/lib/MC/MCSectionXCOFF.cpp b/llvm/lib/MC/MCSectionXCOFF.cpp --- a/llvm/lib/MC/MCSectionXCOFF.cpp +++ b/llvm/lib/MC/MCSectionXCOFF.cpp @@ -34,7 +34,8 @@ } if (getKind().isReadOnly()) { - if (getMappingClass() != XCOFF::XMC_RO) + if (getMappingClass() != XCOFF::XMC_RO && + getMappingClass() != XCOFF::XMC_TD) report_fatal_error("Unhandled storage-mapping class for .rodata csect."); printCsectDirective(OS); return; @@ -70,7 +71,8 @@ } if (isCsect() && getMappingClass() == XCOFF::XMC_TD) { - assert((getKind().isBSSExtern() || getKind().isBSSLocal()) && + assert((getKind().isBSSExtern() || getKind().isBSSLocal() || + getKind().isReadOnlyWithRel()) && "Unexepected section kind for toc-data"); printCsectDirective(OS); return; diff --git a/llvm/test/CodeGen/PowerPC/toc-data-const.ll b/llvm/test/CodeGen/PowerPC/toc-data-const.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/toc-data-const.ll @@ -0,0 +1,26 @@ +; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s --check-prefix CHECK +; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s --check-prefix CHECK + +@i1 = external constant i32 #0 +@i2 = constant i32* @i1 #0 + +define i32 @read() { + %1 = load i32, i32* @i1, align 4 + ret i32 %1 +} + +define i32** @retptr() { + ret i32** @i2 +} + +; CHECK: .read: +; CHECK: la 3, i1[TD](2) + +; CHECK: .retptr: +; CHECK: la 3, i2[TD](2) + +; CHECK-DAG: .toc +; CHECK: .extern i1[TD] +; CHECK: .csect i2[TD] + +attributes #0 = { "toc-data" }