summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2003-07-11 21:57:01 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2003-07-11 21:57:01 +0000
commit0517c5ac92ecb4f8a4658fd1a5f3d33bd45acbe8 (patch)
tree7cda709ce8780970aa8a1dd306a56658313eb777 /lib
parent1aa476edf028fed9b5c8ff537fcab42704037094 (diff)
downloadllvm-0517c5ac92ecb4f8a4658fd1a5f3d33bd45acbe8.tar.gz
llvm-0517c5ac92ecb4f8a4658fd1a5f3d33bd45acbe8.tar.bz2
llvm-0517c5ac92ecb4f8a4658fd1a5f3d33bd45acbe8.tar.xz
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.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/X86/Printer.cpp23
-rw-r--r--lib/Target/X86/X86AsmPrinter.cpp23
2 files changed, 44 insertions, 2 deletions
diff --git a/lib/Target/X86/Printer.cpp b/lib/Target/X86/Printer.cpp
index 164ff0d08b..c2f2bb8f79 100644
--- a/lib/Target/X86/Printer.cpp
+++ b/lib/Target/X86/Printer.cpp
@@ -943,6 +943,17 @@ bool Printer::doInitialization(Module &M)
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 @@ bool Printer::doFinalization(Module &M)
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";
diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp
index 164ff0d08b..c2f2bb8f79 100644
--- a/lib/Target/X86/X86AsmPrinter.cpp
+++ b/lib/Target/X86/X86AsmPrinter.cpp
@@ -943,6 +943,17 @@ bool Printer::doInitialization(Module &M)
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 @@ bool Printer::doFinalization(Module &M)
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";