diff options
author | Chris Lattner <sabre@nondot.org> | 2004-03-07 22:43:27 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-03-07 22:43:27 +0000 |
commit | 64b8d697ad7240aae6caee59c3d75391f4b6a0c1 (patch) | |
tree | b02978f534572652769c31a4a42063e96489ee16 /llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | |
parent | 538fee7aa228d3b1ca895e71e04c9051b7ae91e6 (diff) | |
download | bcm5719-llvm-64b8d697ad7240aae6caee59c3d75391f4b6a0c1.tar.gz bcm5719-llvm-64b8d697ad7240aae6caee59c3d75391f4b6a0c1.zip |
Fix another minor bug, exposed by perlbmk
llvm-svn: 12198
Diffstat (limited to 'llvm/lib/Transforms/IPO/ArgumentPromotion.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index 639c5180378..eb4fc463e69 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -136,10 +136,18 @@ bool ArgPromotion::PromoteArguments(Function *F) { // Second check: make sure that all callers are direct callers. We can't // transform functions that have indirect callers. for (Value::use_iterator UI = F->use_begin(), E = F->use_end(); - UI != E; ++UI) - // What about CPRs? - if (!CallSite::get(*UI).getInstruction()) + UI != E; ++UI) { + CallSite CS = CallSite::get(*UI); + if (Instruction *I = CS.getInstruction()) { + // Ensure that this call site is CALLING the function, not passing it as + // an argument. + for (CallSite::arg_iterator AI = CS.arg_begin(), E = CS.arg_end(); + AI != E; ++AI) + if (*AI == F) return false; // Passing the function address in! + } else { return false; // Cannot promote an indirect call! + } + } // Check to see which arguments are promotable. If an argument is not // promotable, remove it from the PointerArgs vector. |