[llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalOpt.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Sep 25 19:19:39 PDT 2005
Changes in directory llvm/lib/Transforms/IPO:
GlobalOpt.cpp updated: 1.42 -> 1.43
---
Log message:
Make the global opt optimizer work on modules with a null terminator, by
accepting the null even with a non-65535 init prio
---
Diffs of the changes: (+13 -8)
GlobalOpt.cpp | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.42 llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.43
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.42 Sun Sep 25 20:43:45 2005
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp Sun Sep 25 21:19:27 2005
@@ -1144,15 +1144,17 @@
if (!CA) return 0;
for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i)
if (ConstantStruct *CS = dyn_cast<ConstantStruct>(CA->getOperand(i))) {
+ if (isa<ConstantPointerNull>(CS->getOperand(1)))
+ continue;
+
+ // Must have a function or null ptr.
+ if (!isa<Function>(CS->getOperand(1)))
+ return 0;
+
// Init priority must be standard.
ConstantInt *CI = dyn_cast<ConstantInt>(CS->getOperand(0));
if (!CI || CI->getRawValue() != 65535)
return 0;
-
- // Must have a function or null ptr.
- if (!isa<Function>(CS->getOperand(1)) &&
- !isa<ConstantPointerNull>(CS->getOperand(1)))
- return 0;
} else {
return 0;
}
@@ -1185,9 +1187,11 @@
Function *F = Ctors[i];
// Found a null terminator in the middle of the list, prune off the rest of
// the list.
- if (F == 0 && i != Ctors.size()-1) {
- Ctors.resize(i+1);
- MadeChange = true;
+ if (F == 0) {
+ if (i != Ctors.size()-1) {
+ Ctors.resize(i+1);
+ MadeChange = true;
+ }
break;
}
@@ -1217,6 +1221,7 @@
std::vector<const Type*>(), false);
const PointerType *PFTy = PointerType::get(FTy);
CSVals[1] = Constant::getNullValue(PFTy);
+ CSVals[0] = ConstantSInt::get(Type::IntTy, 2147483647);
}
CAList.push_back(ConstantStruct::get(CSVals));
}
More information about the llvm-commits
mailing list