summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/AutoUpgrade.cpp
diff options
context:
space:
mode:
authorJim Laskey <jlaskey@mac.com>2006-03-23 20:13:25 +0000
committerJim Laskey <jlaskey@mac.com>2006-03-23 20:13:25 +0000
commitb11999028996f6adf2b4ec9332f3f934b3e0294d (patch)
treeb52d6f050c8f43bae3c9500953b38feb711f9567 /llvm/lib/VMCore/AutoUpgrade.cpp
parent81137629e076bf1d0eeed550c2184c6d2be09901 (diff)
downloadbcm5719-llvm-b11999028996f6adf2b4ec9332f3f934b3e0294d.tar.gz
bcm5719-llvm-b11999028996f6adf2b4ec9332f3f934b3e0294d.zip
Add some more bulletproofing to auto upgrade of llvm.dbg intrinsics.
llvm-svn: 26996
Diffstat (limited to 'llvm/lib/VMCore/AutoUpgrade.cpp')
-rw-r--r--llvm/lib/VMCore/AutoUpgrade.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/llvm/lib/VMCore/AutoUpgrade.cpp b/llvm/lib/VMCore/AutoUpgrade.cpp
index 646d4ae7702..af4417e0f0b 100644
--- a/llvm/lib/VMCore/AutoUpgrade.cpp
+++ b/llvm/lib/VMCore/AutoUpgrade.cpp
@@ -153,35 +153,31 @@ static Function *getUpgradedIntrinsic(Function *F) {
// of zero in the array indicates replacing with UndefValue for the arg type.
// NULL is returned if there is no permutation. It's assumed that the function
// name is in the form "llvm.?????"
-static unsigned *getArgumentPermutation(Function* F) {
- const std::string& Name = F->getName();
- const FunctionType *FTy = F->getFunctionType();
- unsigned N = FTy->getNumParams();
+static unsigned *getArgumentPermutation(Function* Fn, Function* NewFn) {
+ const std::string& Name = Fn->getName();
+ unsigned N = Fn->getFunctionType()->getNumParams();
+ unsigned M = NewFn->getFunctionType()->getNumParams();
switch (Name[5]) {
case 'd':
if (Name == "llvm.dbg.stoppoint") {
static unsigned Permutation[] = { 2, 3, 4 };
- assert(F->getFunctionType()->getNumParams() ==
- (sizeof(Permutation) / sizeof(unsigned)) &&
+ assert(M == (sizeof(Permutation) / sizeof(unsigned)) &&
"Permutation is wrong length");
if (N == 4) return Permutation;
} else if (Name == "llvm.dbg.region.start") {
static unsigned Permutation[] = { 0 };
- assert(F->getFunctionType()->getNumParams() ==
- (sizeof(Permutation) / sizeof(unsigned)) &&
+ assert(M == (sizeof(Permutation) / sizeof(unsigned)) &&
"Permutation is wrong length");
if (N == 0) return Permutation;
} else if (Name == "llvm.dbg.region.end") {
static unsigned Permutation[] = { 0 };
- assert(F->getFunctionType()->getNumParams() ==
- (sizeof(Permutation) / sizeof(unsigned)) &&
+ assert(M == (sizeof(Permutation) / sizeof(unsigned)) &&
"Permutation is wrong length");
if (N == 0) return Permutation;
} else if (Name == "llvm.dbg.declare") {
static unsigned Permutation[] = { 0, 0 };
- assert(F->getFunctionType()->getNumParams() ==
- (sizeof(Permutation) / sizeof(unsigned)) &&
+ assert(M == (sizeof(Permutation) / sizeof(unsigned)) &&
"Permutation is wrong length");
if (N == 0) return Permutation;
}
@@ -259,7 +255,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
const FunctionType *NewFnTy = NewFn->getFunctionType();
std::vector<Value*> Oprnds;
- unsigned *Permutation = getArgumentPermutation(F);
+ unsigned *Permutation = getArgumentPermutation(F, NewFn);
unsigned N = NewFnTy->getNumParams();
if (Permutation) {
OpenPOWER on IntegriCloud