[llvm] AsmPrinter: Emit context error for protected aliases (PR #145271)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 22 23:01:15 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/145271.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+5-3)
- (modified) llvm/test/CodeGen/X86/equiv_with_fndef.ll (+9-2)
``````````diff
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 403963f33b65c..9c179db4496d9 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1084,9 +1084,11 @@ 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->isVariable())
- report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
- "' is a protected alias");
+ if (CurrentFnSym->isVariable()) {
+ LLVMContext &Ctx = MF->getFunction().getContext();
+ Ctx.emitError("'" + Twine(CurrentFnSym->getName()) + "' is a protected alias");
+ return;
+ }
OutStreamer->emitLabel(CurrentFnSym);
diff --git a/llvm/test/CodeGen/X86/equiv_with_fndef.ll b/llvm/test/CodeGen/X86/equiv_with_fndef.ll
index 3da0aa60250c2..e1640def9711a 100644
--- a/llvm/test/CodeGen/X86/equiv_with_fndef.ll
+++ b/llvm/test/CodeGen/X86/equiv_with_fndef.ll
@@ -1,10 +1,17 @@
-; RUN: not --crash llc < %s 2>&1 | FileCheck %s
+; RUN: not llc < %s 2> %t.err | FileCheck %s
+; RUN: FileCheck -check-prefix=ERR %s < %t.err
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"
+; ERR: error: 'pselect' is a protected alias
+
+; CHECK: .globl pselect # -- Begin function pselect
+; CHECK: .type pselect, at function
+; CHECK: .cfi_startproc # @pselect
+; CHECK: retq
+; CHECK: .size pselect, .Lfunc_end0-pselect
define void @pselect() {
ret void
}
-; CHECK: 'pselect' is a protected alias
``````````
</details>
https://github.com/llvm/llvm-project/pull/145271
More information about the llvm-commits
mailing list