[llvm] r224828 - CodeGen: Error on redefinitions instead of asserting
David Majnemer
david.majnemer at gmail.com
Wed Dec 24 15:06:55 PST 2014
Author: majnemer
Date: Wed Dec 24 17:06:55 2014
New Revision: 224828
URL: http://llvm.org/viewvc/llvm-project?rev=224828&view=rev
Log:
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.
Added:
llvm/trunk/test/CodeGen/X86/equiv_with_fndef.ll
llvm/trunk/test/CodeGen/X86/equiv_with_vardef.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=224828&r1=224827&r2=224828&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Dec 24 17:06:55 2014
@@ -338,6 +338,9 @@ void AsmPrinter::EmitGlobalVariable(cons
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.
Added: llvm/trunk/test/CodeGen/X86/equiv_with_fndef.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/equiv_with_fndef.ll?rev=224828&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/equiv_with_fndef.ll (added)
+++ llvm/trunk/test/CodeGen/X86/equiv_with_fndef.ll Wed Dec 24 17:06:55 2014
@@ -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
Added: llvm/trunk/test/CodeGen/X86/equiv_with_vardef.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/equiv_with_vardef.ll?rev=224828&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/equiv_with_vardef.ll (added)
+++ llvm/trunk/test/CodeGen/X86/equiv_with_vardef.ll Wed Dec 24 17:06:55 2014
@@ -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"
+
+ at var = global i32 0
+; CHECK: symbol 'var' is already defined
More information about the llvm-commits
mailing list