From f99eedeb72644671cd584f48e4c136d47f6b0020 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 12 Dec 2019 16:18:57 -0800 Subject: [PATCH] [MC][PowerPC] Fix a crash when redefining a symbol after .set Fix PR44284. This is probably not valid assembly but we should not crash. Reviewed By: luporl, #powerpc, steven.zhang Differential Revision: https://reviews.llvm.org/D71443 --- llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp | 3 ++- llvm/test/MC/PowerPC/ppc64-localentry-symbols.s | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp index 00df9e41fdae..5e91bdb2f8de 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp @@ -201,7 +201,8 @@ public: void finish() override { for (auto *Sym : UpdateOther) - copyLocalEntry(Sym, Sym->getVariableValue()); + if (Sym->isVariable()) + copyLocalEntry(Sym, Sym->getVariableValue()); } private: diff --git a/llvm/test/MC/PowerPC/ppc64-localentry-symbols.s b/llvm/test/MC/PowerPC/ppc64-localentry-symbols.s index f1d5c5d0ab1a..a663af57ad45 100644 --- a/llvm/test/MC/PowerPC/ppc64-localentry-symbols.s +++ b/llvm/test/MC/PowerPC/ppc64-localentry-symbols.s @@ -32,3 +32,8 @@ func: nop nop .localentry func, 8 + +## PR44284 Don't crash if err is redefined after .set +.set err, _err +.globl err +err: