[PATCH] D98181: [CodeGen] Report a normal instead of fatal error for label redefinition
John Brawn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 8 07:59:32 PST 2021
john.brawn created this revision.
john.brawn added reviewers: MaskRay, tmsriram, shchenz.
Herald added subscribers: pengfei, hiraditya, emaste.
john.brawn requested review of this revision.
Herald added a project: LLVM.
A symbol being redefined as a label is something that can happen as a result of ordinary input, so it shouldn't cause a fatal error. Also adjust the error message to match the one you get when a symbol is redefined as a variable.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98181
Files:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/test/CodeGen/X86/equiv_with_vardef.ll
llvm/test/CodeGen/X86/label-redefinition.ll
llvm/test/CodeGen/X86/symbol-redefinition.ll
llvm/test/CodeGen/XCore/section-name.ll
llvm/test/MC/ELF/section-sym-err.s
Index: llvm/test/MC/ELF/section-sym-err.s
===================================================================
--- llvm/test/MC/ELF/section-sym-err.s
+++ llvm/test/MC/ELF/section-sym-err.s
@@ -3,4 +3,4 @@
.section foo
foo:
-// CHECK: error: invalid symbol redefinition
+// CHECK: error: symbol 'foo' is already defined
Index: llvm/test/CodeGen/XCore/section-name.ll
===================================================================
--- llvm/test/CodeGen/XCore/section-name.ll
+++ llvm/test/CodeGen/XCore/section-name.ll
@@ -6,4 +6,4 @@
ret void
}
-; CHECK: <unknown>:0: error: invalid symbol redefinition
+; CHECK: <unknown>:0: error: symbol '.dp.bss' is already defined
Index: llvm/test/CodeGen/X86/symbol-redefinition.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/symbol-redefinition.ll
@@ -0,0 +1,9 @@
+; RUN: not llc -mtriple=x86_64-unknown-unknown %s -o - 2>&1 | FileCheck %s
+
+; CHECK: <unknown>:0: error: symbol 'fn' is already defined
+define void @fn() section "fn" {
+ ret void
+}
+
+; CHECK: <unknown>:0: error: symbol 'var' is already defined
+ at var = global i32 0, section "var", align 4
Index: llvm/test/CodeGen/X86/label-redefinition.ll
===================================================================
--- llvm/test/CodeGen/X86/label-redefinition.ll
+++ llvm/test/CodeGen/X86/label-redefinition.ll
@@ -1,5 +1,5 @@
; PR7054
-; RUN: not --crash llc %s -o - 2>&1 | grep "'_foo' label emitted multiple times to assembly"
+; RUN: not llc %s -o - 2>&1 | FileCheck %s
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
target triple = "i386-apple-darwin10.0.0"
@@ -7,6 +7,7 @@
unreachable
}
+; CHECK: <unknown>:0: error: symbol '_foo' is already defined
define i32 @foo() {
entry:
unreachable
Index: llvm/test/CodeGen/X86/equiv_with_vardef.ll
===================================================================
--- llvm/test/CodeGen/X86/equiv_with_vardef.ll
+++ llvm/test/CodeGen/X86/equiv_with_vardef.ll
@@ -6,4 +6,4 @@
@var = global i32 0
; CHECK: <unknown>:0: error: symbol 'var' is already defined
-; CHECK: <unknown>:0: error: invalid symbol redefinition
+; CHECK: <unknown>:0: error: symbol 'var' is already defined
Index: llvm/lib/MC/MCStreamer.cpp
===================================================================
--- llvm/lib/MC/MCStreamer.cpp
+++ llvm/lib/MC/MCStreamer.cpp
@@ -415,7 +415,8 @@
Symbol->redefineIfPossible();
if (!Symbol->isUndefined() || Symbol->isVariable())
- return getContext().reportError(Loc, "invalid symbol redefinition");
+ return getContext().reportError(Loc, "symbol '" + Twine(Symbol->getName()) +
+ "' is already defined");
assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
assert(getCurrentSectionOnly() && "Cannot emit before setting section!");
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -824,9 +824,6 @@
if (CurrentFnSym->isVariable())
report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
"' is a protected alias");
- if (CurrentFnSym->isDefined())
- report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
- "' label emitted multiple times to assembly file");
OutStreamer->emitLabel(CurrentFnSym);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98181.329010.patch
Type: text/x-patch
Size: 3579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210308/f3346bc5/attachment.bin>
More information about the llvm-commits
mailing list