aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/AutoUpgrade.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-01-23 07:42:30 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-01-23 07:42:30 +0000
commitc79925a395b769cdb582518f90b47ecbc513b702 (patch)
treecf621b854a58b257506bee131a03bc9584301c44 /lib/VMCore/AutoUpgrade.cpp
parent9629efde7ef8e287f16a76d71ada827efe03983f (diff)
downloadexternal_llvm-c79925a395b769cdb582518f90b47ecbc513b702.zip
external_llvm-c79925a395b769cdb582518f90b47ecbc513b702.tar.gz
external_llvm-c79925a395b769cdb582518f90b47ecbc513b702.tar.bz2
For PR411:
No functionality changes, just improve the code by a) providing better function names, b) eliminating a call to get_suffix and c) tightening up a function elimination test to reduce further checking. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25540 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/AutoUpgrade.cpp')
-rw-r--r--lib/VMCore/AutoUpgrade.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp
index 4f0f620..b68b8b7 100644
--- a/lib/VMCore/AutoUpgrade.cpp
+++ b/lib/VMCore/AutoUpgrade.cpp
@@ -36,7 +36,7 @@ static inline const char* get_suffix(const Type* Ty) {
return 0;
}
-static inline const Type* get_type(Function* F) {
+static inline const Type* getTypeFromFunctionName(Function* F) {
// If there's no function, we can't get the argument type.
if (!F)
return 0;
@@ -45,7 +45,7 @@ static inline const Type* get_type(Function* F) {
const std::string& Name = F->getName();
// Quickly eliminate it, if it's not a candidate.
- if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' || Name[2] !=
+ if (Name.length() <= 8 || Name[0] != 'l' || Name[1] != 'l' || Name[2] !=
'v' || Name[3] != 'm' || Name[4] != '.')
return 0;
@@ -109,10 +109,9 @@ bool llvm::IsUpgradeableIntrinsicName(const std::string& Name) {
// the argument types.
Function* llvm::UpgradeIntrinsicFunction(Function* F) {
// See if its one of the name's we're interested in.
- if (const Type* Ty = get_type(F)) {
- const char* suffix = get_suffix(Ty);
- if (Ty->isSigned())
- suffix = get_suffix(Ty->getUnsignedVersion());
+ if (const Type* Ty = getTypeFromFunctionName(F)) {
+ const char* suffix =
+ get_suffix((Ty->isSigned() ? Ty->getUnsignedVersion() : Ty));
assert(suffix && "Intrinsic parameter type not recognized");
const std::string& Name = F->getName();
std::string new_name = Name + suffix;
@@ -143,7 +142,7 @@ Function* llvm::UpgradeIntrinsicFunction(Function* F) {
Instruction* llvm::UpgradeIntrinsicCall(CallInst *CI) {
Function *F = CI->getCalledFunction();
- if (const Type* Ty = get_type(F)) {
+ if (const Type* Ty = getTypeFromFunctionName(F)) {
Function* newF = UpgradeIntrinsicFunction(F);
std::vector<Value*> Oprnds;
for (User::op_iterator OI = CI->op_begin(), OE = CI->op_end();