R600: Fix assert on empty function
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 13 Nov 2014 20:07:40 +0000 (20:07 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 13 Nov 2014 20:07:40 +0000 (20:07 +0000)
If a function is just an unreachable, this would hit a
"this is not a MachO target" assertion because of setting
HasSubsectionViaSymbols.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221920 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/MCTargetDesc/AMDGPUMCAsmInfo.cpp
test/CodeGen/R600/empty-function.ll [new file with mode: 0644]

index 5393504707c4ad67f92be2c1ee0e9d2ce8f0c89d..3c2b889598a768cf3e23daf2c14ad8d37087522d 100644 (file)
@@ -14,7 +14,6 @@ using namespace llvm;
 AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(StringRef &TT) : MCAsmInfoELF() {
   HasSingleParameterDotFile = false;
   //===------------------------------------------------------------------===//
-  HasSubsectionsViaSymbols = true;
   MaxInstLength = 16;
   SeparatorString = "\n";
   CommentString = ";";
diff --git a/test/CodeGen/R600/empty-function.ll b/test/CodeGen/R600/empty-function.ll
new file mode 100644 (file)
index 0000000..d4ff803
--- /dev/null
@@ -0,0 +1,20 @@
+; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
+
+; Make sure we don't assert on empty functions
+
+; SI-LABEL: {{^}}empty_function_ret:
+; SI: .text
+; SI: s_endpgm
+; SI: codeLenInByte = 4
+define void @empty_function_ret() #0 {
+  ret void
+}
+
+; SI-LABEL: {{^}}empty_function_unreachable:
+; SI: .text
+; SI: codeLenInByte = 0
+define void @empty_function_unreachable() #0 {
+  unreachable
+}
+
+attributes #0 = { nounwind }