use ArgOperand accessors

and CallInst for getting hold
of the intrinsic's arguments

simplify along the way (at least for me this is much more legible now)
Bill, Baldrick or Anton, please review\!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106838 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Gabor Greif 2010-06-25 11:25:30 +00:00
parent c13055db26
commit 2bf4b3be5c

View File

@ -22,6 +22,7 @@
#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/Dominators.h"
#include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/Passes.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLowering.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/PromoteMemToReg.h" #include "llvm/Transforms/Utils/PromoteMemToReg.h"
@ -193,8 +194,8 @@ FunctionPass *llvm::createDwarfEHPass(const TargetMachine *tm, bool fast) {
bool DwarfEHPrepare::HasCatchAllInSelector(IntrinsicInst *II) { bool DwarfEHPrepare::HasCatchAllInSelector(IntrinsicInst *II) {
if (!EHCatchAllValue) return false; if (!EHCatchAllValue) return false;
unsigned OpIdx = II->getNumOperands() - 1; unsigned ArgIdx = II->getNumArgOperands() - 1;
GlobalVariable *GV = dyn_cast<GlobalVariable>(II->getOperand(OpIdx)); GlobalVariable *GV = dyn_cast<GlobalVariable>(II->getArgOperand(ArgIdx));
return GV == EHCatchAllValue; return GV == EHCatchAllValue;
} }
@ -386,16 +387,20 @@ bool DwarfEHPrepare::HandleURoRInvokes() {
// Use the exception object pointer and the personality function // Use the exception object pointer and the personality function
// from the original selector. // from the original selector.
Args.push_back(II->getArgOperand(0)); // Exception object pointer. CallSite CS(II);
Args.push_back(II->getArgOperand(1)); // Personality function. IntrinsicInst::op_iterator I = CS.arg_begin();
Args.push_back(*I++); // Exception object pointer.
Args.push_back(*I++); // Personality function.
unsigned I = 3; IntrinsicInst::op_iterator E = CS.arg_end();
unsigned E = II->getNumOperands() - IntrinsicInst::op_iterator B = prior(E);
(isa<ConstantInt>(II->getOperand(II->getNumOperands() - 1)) ? 1 : 0);
// Exclude last argument if it is an integer.
if (isa<ConstantInt>(B)) E = B;
// Add in any filter IDs. // Add in any filter IDs.
for (; I < E; ++I) for (; I != E; ++I)
Args.push_back(II->getOperand(I)); Args.push_back(*I);
Args.push_back(EHCatchAllValue->getInitializer()); // Catch-all indicator. Args.push_back(EHCatchAllValue->getInitializer()); // Catch-all indicator.