Fix for PR 26378
authorNemanja Ivanovic <nemanja.i.ibm@gmail.com>
Sat, 12 Mar 2016 10:23:07 +0000 (10:23 +0000)
committerNemanja Ivanovic <nemanja.i.ibm@gmail.com>
Sat, 12 Mar 2016 10:23:07 +0000 (10:23 +0000)
This patch corresponds to review:
http://reviews.llvm.org/D17712

We were not clearing the TOC vector in PPCAsmPrinter when initializing it. This
caused duplicate definition asserts when the pass is reused on the module
(i.e. with -compile-twice or in JIT contexts).

llvm-svn: 263338

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/test/CodeGen/PowerPC/pr26378.ll [new file with mode: 0644]

index ec354c2..f206652 100644 (file)
@@ -82,6 +82,12 @@ public:
 
     MCSymbol *lookUpOrCreateTOCEntry(MCSymbol *Sym);
 
+    virtual bool doInitialization(Module &M) override {
+      if (!TOC.empty())
+        TOC.clear();
+      return AsmPrinter::doInitialization(M);
+    }
+
     void EmitInstruction(const MachineInstr *MI) override;
 
     void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);
diff --git a/llvm/test/CodeGen/PowerPC/pr26378.ll b/llvm/test/CodeGen/PowerPC/pr26378.ll
new file mode 100644 (file)
index 0000000..e5e2055
--- /dev/null
@@ -0,0 +1,6 @@
+; RUN: llc -compile-twice -filetype obj \
+; RUN:   -mtriple=powerpc64le-unknown-unknown -mcpu=pwr8 < %s
+@foo = common global i32 0, align 4
+define i8* @blah() #0 {
+  ret i8* bitcast (i32* @foo to i8*)
+}