[llvm-commits] CVS: llvm/lib/Target/X86/Printer.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Fri Jul 11 16:58:06 PDT 2003


Changes in directory llvm/lib/Target/X86:

Printer.cpp updated: 1.43 -> 1.44

---
Log message:

If we have a constant pointer reference to a function, we were printing
out the entire llvm disassembly for the function at global constant-output
time, which caused the assembler to barf in 164.gzip. This fixes that
particular problem (though 164.gzip has other problems with X86 llc.)


---
Diffs of the changes:

Index: llvm/lib/Target/X86/Printer.cpp
diff -u llvm/lib/Target/X86/Printer.cpp:1.43 llvm/lib/Target/X86/Printer.cpp:1.44
--- llvm/lib/Target/X86/Printer.cpp:1.43	Fri Jul 11 13:18:35 2003
+++ llvm/lib/Target/X86/Printer.cpp	Fri Jul 11 16:57:01 2003
@@ -943,6 +943,17 @@
   return false; // success
 }
 
+static const Function *isConstantFunctionPointerRef (const Constant *C) {
+  const ConstantPointerRef *R = dyn_cast<ConstantPointerRef>(C);
+  if (R) {
+    const Function *F = dyn_cast<Function>(R->getValue());
+    if (F) {
+      return F;
+    }
+  }
+  return NULL;
+}
+
 bool Printer::doFinalization(Module &M)
 {
   // Print out module-level global variables here.
@@ -956,7 +967,17 @@
       O << "\t.size " << name << ","
 	<< (unsigned)TD->getTypeSize(I->getType()) << "\n";
       O << "\t.align " << (unsigned)TD->getTypeAlignment(C->getType()) << "\n";
-      O << name << ":\t\t\t\t\t#" << *C << "\n";
+      O << name << ":\t\t\t\t\t#";
+      // If this is a constant function pointer, we only print out the
+      // name of the function in the comment (because printing the
+      // function means calling AsmWriter to print the whole LLVM
+      // assembly, which would corrupt the X86 assembly output.)
+      // Otherwise we print out the whole llvm value as a comment.
+      if (const Function *F = isConstantFunctionPointerRef (C)) {
+	O << " %" << F->getName() << "()\n";
+      } else {
+	O << *C << "\n";
+      }
       printConstantValueOnly (C);
     } else {
       O << "\t.globl " << name << "\n";





More information about the llvm-commits mailing list