diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 93445a8c84f..80221d7feb6 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -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. diff --git a/test/CodeGen/X86/equiv_with_fndef.ll b/test/CodeGen/X86/equiv_with_fndef.ll new file mode 100644 index 00000000000..efbb8ab3da6 --- /dev/null +++ b/test/CodeGen/X86/equiv_with_fndef.ll @@ -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 diff --git a/test/CodeGen/X86/equiv_with_vardef.ll b/test/CodeGen/X86/equiv_with_vardef.ll new file mode 100644 index 00000000000..29c19a107ec --- /dev/null +++ b/test/CodeGen/X86/equiv_with_vardef.ll @@ -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