mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-01 00:33:09 +00:00
CodeGen: Error on redefinitions instead of asserting
It's possible to have a prior definition of a symbol in module asm. Raise an error instead of crashing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224828 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d36cad9914
commit
e277a13a71
@ -338,6 +338,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
||||
return;
|
||||
|
||||
GVSym->redefineIfPossible();
|
||||
if (GVSym->isDefined() || GVSym->isVariable())
|
||||
report_fatal_error("symbol '" + Twine(GVSym->getName()) +
|
||||
"' is already defined");
|
||||
|
||||
if (MAI->hasDotTypeDotSizeDirective())
|
||||
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject);
|
||||
@ -547,11 +550,14 @@ void AsmPrinter::EmitFunctionEntryLabel() {
|
||||
|
||||
// The function label could have already been emitted if two symbols end up
|
||||
// conflicting due to asm renaming. Detect this and emit an error.
|
||||
if (CurrentFnSym->isUndefined())
|
||||
return OutStreamer.EmitLabel(CurrentFnSym);
|
||||
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");
|
||||
|
||||
report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
|
||||
"' label emitted multiple times to assembly file");
|
||||
return OutStreamer.EmitLabel(CurrentFnSym);
|
||||
}
|
||||
|
||||
/// emitComments - Pretty-print comments for instructions.
|
||||
|
10
test/CodeGen/X86/equiv_with_fndef.ll
Normal file
10
test/CodeGen/X86/equiv_with_fndef.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; RUN: not llc < %s 2>&1 | FileCheck %s
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
module asm ".equiv pselect, __pselect"
|
||||
|
||||
define void @pselect() {
|
||||
ret void
|
||||
}
|
||||
; CHECK: 'pselect' is a protected alias
|
8
test/CodeGen/X86/equiv_with_vardef.ll
Normal file
8
test/CodeGen/X86/equiv_with_vardef.ll
Normal file
@ -0,0 +1,8 @@
|
||||
; RUN: not llc < %s 2>&1 | FileCheck %s
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
module asm ".equiv var, __var"
|
||||
|
||||
@var = global i32 0
|
||||
; CHECK: symbol 'var' is already defined
|
Loading…
Reference in New Issue
Block a user