[MC][PowerPC] Fix a crash when redefining a symbol after .set
authorFangrui Song <maskray@google.com>
Fri, 13 Dec 2019 00:18:57 +0000 (16:18 -0800)
committerFangrui Song <maskray@google.com>
Fri, 13 Dec 2019 17:31:54 +0000 (09:31 -0800)
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
llvm/test/MC/PowerPC/ppc64-localentry-symbols.s

index 00df9e4..5e91bdb 100644 (file)
@@ -201,7 +201,8 @@ public:
 
   void finish() override {
     for (auto *Sym : UpdateOther)
-      copyLocalEntry(Sym, Sym->getVariableValue());
+      if (Sym->isVariable())
+        copyLocalEntry(Sym, Sym->getVariableValue());
   }
 
 private:
index f1d5c5d..a663af5 100644 (file)
@@ -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: