mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-10 16:24:04 +00:00
Have IRBuilder take a template argument on whether or not to preserve
names. This can save a lot of allocations if you aren't going to be looking at the output. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54546 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d9cc749318
commit
7a61d701c0
@ -71,7 +71,7 @@ void BrainF::header() {
|
|||||||
brainf_func = cast<Function>(module->
|
brainf_func = cast<Function>(module->
|
||||||
getOrInsertFunction("brainf", Type::VoidTy, NULL));
|
getOrInsertFunction("brainf", Type::VoidTy, NULL));
|
||||||
|
|
||||||
builder = new IRBuilder(BasicBlock::Create(label, brainf_func));
|
builder = new IRBuilder<>(BasicBlock::Create(label, brainf_func));
|
||||||
|
|
||||||
//%arr = malloc i8, i32 %d
|
//%arr = malloc i8, i32 %d
|
||||||
ConstantInt *val_mem = ConstantInt::get(APInt(32, memtotal));
|
ConstantInt *val_mem = ConstantInt::get(APInt(32, memtotal));
|
||||||
|
@ -84,7 +84,7 @@ class BrainF {
|
|||||||
BasicBlock *aberrorbb;
|
BasicBlock *aberrorbb;
|
||||||
|
|
||||||
/// Variables
|
/// Variables
|
||||||
IRBuilder *builder;
|
IRBuilder<> *builder;
|
||||||
Value *curhead;
|
Value *curhead;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -708,7 +708,7 @@ namespace llvm {
|
|||||||
DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef )
|
DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef )
|
||||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef )
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef )
|
||||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef )
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef )
|
||||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder, LLVMBuilderRef )
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef )
|
||||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef )
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef )
|
||||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ModuleProvider, LLVMModuleProviderRef)
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ModuleProvider, LLVMModuleProviderRef)
|
||||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef )
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef )
|
||||||
|
@ -33,7 +33,9 @@ namespace llvm {
|
|||||||
/// supports nul-terminated C strings. For fully generic names, use
|
/// supports nul-terminated C strings. For fully generic names, use
|
||||||
/// I->setName(). For access to extra instruction properties, use the mutators
|
/// I->setName(). For access to extra instruction properties, use the mutators
|
||||||
/// (e.g. setVolatile) on the instructions after they have been created.
|
/// (e.g. setVolatile) on the instructions after they have been created.
|
||||||
class IRBuilder {
|
/// The template argument handles whether or not to preserve names in the final
|
||||||
|
/// instruction output. This defaults to on.
|
||||||
|
template <bool preserveNames=true> class IRBuilder {
|
||||||
BasicBlock *BB;
|
BasicBlock *BB;
|
||||||
BasicBlock::iterator InsertPt;
|
BasicBlock::iterator InsertPt;
|
||||||
public:
|
public:
|
||||||
@ -81,7 +83,7 @@ public:
|
|||||||
/// template instantiation.
|
/// template instantiation.
|
||||||
void InsertHelper(Instruction *I, const char *Name) const {
|
void InsertHelper(Instruction *I, const char *Name) const {
|
||||||
if (BB) BB->getInstList().insert(InsertPt, I);
|
if (BB) BB->getInstList().insert(InsertPt, I);
|
||||||
if (Name[0])
|
if (preserveNames && Name[0])
|
||||||
I->setName(Name);
|
I->setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +61,9 @@ namespace {
|
|||||||
Constant *GetFrameMap(Function &F);
|
Constant *GetFrameMap(Function &F);
|
||||||
const Type* GetConcreteStackEntryType(Function &F);
|
const Type* GetConcreteStackEntryType(Function &F);
|
||||||
void CollectRoots(Function &F);
|
void CollectRoots(Function &F);
|
||||||
static GetElementPtrInst *CreateGEP(IRBuilder &B, Value *BasePtr,
|
static GetElementPtrInst *CreateGEP(IRBuilder<> &B, Value *BasePtr,
|
||||||
int Idx1, const char *Name);
|
int Idx1, const char *Name);
|
||||||
static GetElementPtrInst *CreateGEP(IRBuilder &B, Value *BasePtr,
|
static GetElementPtrInst *CreateGEP(IRBuilder<> &B, Value *BasePtr,
|
||||||
int Idx1, int Idx2, const char *Name);
|
int Idx1, int Idx2, const char *Name);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,13 +89,13 @@ namespace {
|
|||||||
// State.
|
// State.
|
||||||
int State;
|
int State;
|
||||||
Function::iterator StateBB, StateE;
|
Function::iterator StateBB, StateE;
|
||||||
IRBuilder Builder;
|
IRBuilder<> Builder;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EscapeEnumerator(Function &F, const char *N = "cleanup")
|
EscapeEnumerator(Function &F, const char *N = "cleanup")
|
||||||
: F(F), CleanupBBName(N), State(0) {}
|
: F(F), CleanupBBName(N), State(0) {}
|
||||||
|
|
||||||
IRBuilder *Next() {
|
IRBuilder<> *Next() {
|
||||||
switch (State) {
|
switch (State) {
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
@ -341,7 +341,7 @@ void ShadowStackCollector::CollectRoots(Function &F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GetElementPtrInst *
|
GetElementPtrInst *
|
||||||
ShadowStackCollector::CreateGEP(IRBuilder &B, Value *BasePtr,
|
ShadowStackCollector::CreateGEP(IRBuilder<> &B, Value *BasePtr,
|
||||||
int Idx, int Idx2, const char *Name) {
|
int Idx, int Idx2, const char *Name) {
|
||||||
Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0),
|
Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0),
|
||||||
ConstantInt::get(Type::Int32Ty, Idx),
|
ConstantInt::get(Type::Int32Ty, Idx),
|
||||||
@ -354,7 +354,7 @@ ShadowStackCollector::CreateGEP(IRBuilder &B, Value *BasePtr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GetElementPtrInst *
|
GetElementPtrInst *
|
||||||
ShadowStackCollector::CreateGEP(IRBuilder &B, Value *BasePtr,
|
ShadowStackCollector::CreateGEP(IRBuilder<> &B, Value *BasePtr,
|
||||||
int Idx, const char *Name) {
|
int Idx, const char *Name) {
|
||||||
Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0),
|
Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0),
|
||||||
ConstantInt::get(Type::Int32Ty, Idx) };
|
ConstantInt::get(Type::Int32Ty, Idx) };
|
||||||
@ -381,7 +381,7 @@ bool ShadowStackCollector::performCustomLowering(Function &F) {
|
|||||||
|
|
||||||
// Build the shadow stack entry at the very start of the function.
|
// Build the shadow stack entry at the very start of the function.
|
||||||
BasicBlock::iterator IP = F.getEntryBlock().begin();
|
BasicBlock::iterator IP = F.getEntryBlock().begin();
|
||||||
IRBuilder AtEntry(IP->getParent(), IP);
|
IRBuilder<> AtEntry(IP->getParent(), IP);
|
||||||
|
|
||||||
Instruction *StackEntry = AtEntry.CreateAlloca(ConcreteStackEntryTy, 0,
|
Instruction *StackEntry = AtEntry.CreateAlloca(ConcreteStackEntryTy, 0,
|
||||||
"gc_frame");
|
"gc_frame");
|
||||||
@ -419,7 +419,7 @@ bool ShadowStackCollector::performCustomLowering(Function &F) {
|
|||||||
|
|
||||||
// For each instruction that escapes...
|
// For each instruction that escapes...
|
||||||
EscapeEnumerator EE(F, "gc_cleanup");
|
EscapeEnumerator EE(F, "gc_cleanup");
|
||||||
while (IRBuilder *AtExit = EE.Next()) {
|
while (IRBuilder<> *AtExit = EE.Next()) {
|
||||||
// Pop the entry from the shadow stack. Don't reuse CurrentHead from
|
// Pop the entry from the shadow stack. Don't reuse CurrentHead from
|
||||||
// AtEntry, since that would make the value live for the entire function.
|
// AtEntry, since that would make the value live for the entire function.
|
||||||
Instruction *EntryNextPtr2 = CreateGEP(*AtExit, StackEntry, 0, 0,
|
Instruction *EntryNextPtr2 = CreateGEP(*AtExit, StackEntry, 0, 0,
|
||||||
|
@ -55,68 +55,69 @@ public:
|
|||||||
/// performed. If it returns CI, then it transformed the call and CI is to be
|
/// performed. If it returns CI, then it transformed the call and CI is to be
|
||||||
/// deleted. If it returns something else, replace CI with the new value and
|
/// deleted. If it returns something else, replace CI with the new value and
|
||||||
/// delete CI.
|
/// delete CI.
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) =0;
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B)
|
||||||
|
=0;
|
||||||
|
|
||||||
Value *OptimizeCall(CallInst *CI, const TargetData &TD, IRBuilder &B) {
|
Value *OptimizeCall(CallInst *CI, const TargetData &TD, IRBuilder<> &B) {
|
||||||
Caller = CI->getParent()->getParent();
|
Caller = CI->getParent()->getParent();
|
||||||
this->TD = &TD;
|
this->TD = &TD;
|
||||||
return CallOptimizer(CI->getCalledFunction(), CI, B);
|
return CallOptimizer(CI->getCalledFunction(), CI, B);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
|
/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
|
||||||
Value *CastToCStr(Value *V, IRBuilder &B);
|
Value *CastToCStr(Value *V, IRBuilder<> &B);
|
||||||
|
|
||||||
/// EmitStrLen - Emit a call to the strlen function to the builder, for the
|
/// EmitStrLen - Emit a call to the strlen function to the builder, for the
|
||||||
/// specified pointer. Ptr is required to be some pointer type, and the
|
/// specified pointer. Ptr is required to be some pointer type, and the
|
||||||
/// return value has 'intptr_t' type.
|
/// return value has 'intptr_t' type.
|
||||||
Value *EmitStrLen(Value *Ptr, IRBuilder &B);
|
Value *EmitStrLen(Value *Ptr, IRBuilder<> &B);
|
||||||
|
|
||||||
/// EmitMemCpy - Emit a call to the memcpy function to the builder. This
|
/// EmitMemCpy - Emit a call to the memcpy function to the builder. This
|
||||||
/// always expects that the size has type 'intptr_t' and Dst/Src are pointers.
|
/// always expects that the size has type 'intptr_t' and Dst/Src are pointers.
|
||||||
Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len,
|
Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len,
|
||||||
unsigned Align, IRBuilder &B);
|
unsigned Align, IRBuilder<> &B);
|
||||||
|
|
||||||
/// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is
|
/// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is
|
||||||
/// a pointer, Val is an i32 value, and Len is an 'intptr_t' value.
|
/// a pointer, Val is an i32 value, and Len is an 'intptr_t' value.
|
||||||
Value *EmitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder &B);
|
Value *EmitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B);
|
||||||
|
|
||||||
/// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g.
|
/// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g.
|
||||||
/// 'floor'). This function is known to take a single of type matching 'Op'
|
/// 'floor'). This function is known to take a single of type matching 'Op'
|
||||||
/// and returns one value with the same type. If 'Op' is a long double, 'l'
|
/// and returns one value with the same type. If 'Op' is a long double, 'l'
|
||||||
/// is added as the suffix of name, if 'Op' is a float, we add a 'f' suffix.
|
/// is added as the suffix of name, if 'Op' is a float, we add a 'f' suffix.
|
||||||
Value *EmitUnaryFloatFnCall(Value *Op, const char *Name, IRBuilder &B);
|
Value *EmitUnaryFloatFnCall(Value *Op, const char *Name, IRBuilder<> &B);
|
||||||
|
|
||||||
/// EmitPutChar - Emit a call to the putchar function. This assumes that Char
|
/// EmitPutChar - Emit a call to the putchar function. This assumes that Char
|
||||||
/// is an integer.
|
/// is an integer.
|
||||||
void EmitPutChar(Value *Char, IRBuilder &B);
|
void EmitPutChar(Value *Char, IRBuilder<> &B);
|
||||||
|
|
||||||
/// EmitPutS - Emit a call to the puts function. This assumes that Str is
|
/// EmitPutS - Emit a call to the puts function. This assumes that Str is
|
||||||
/// some pointer.
|
/// some pointer.
|
||||||
void EmitPutS(Value *Str, IRBuilder &B);
|
void EmitPutS(Value *Str, IRBuilder<> &B);
|
||||||
|
|
||||||
/// EmitFPutC - Emit a call to the fputc function. This assumes that Char is
|
/// EmitFPutC - Emit a call to the fputc function. This assumes that Char is
|
||||||
/// an i32, and File is a pointer to FILE.
|
/// an i32, and File is a pointer to FILE.
|
||||||
void EmitFPutC(Value *Char, Value *File, IRBuilder &B);
|
void EmitFPutC(Value *Char, Value *File, IRBuilder<> &B);
|
||||||
|
|
||||||
/// EmitFPutS - Emit a call to the puts function. Str is required to be a
|
/// EmitFPutS - Emit a call to the puts function. Str is required to be a
|
||||||
/// pointer and File is a pointer to FILE.
|
/// pointer and File is a pointer to FILE.
|
||||||
void EmitFPutS(Value *Str, Value *File, IRBuilder &B);
|
void EmitFPutS(Value *Str, Value *File, IRBuilder<> &B);
|
||||||
|
|
||||||
/// EmitFWrite - Emit a call to the fwrite function. This assumes that Ptr is
|
/// EmitFWrite - Emit a call to the fwrite function. This assumes that Ptr is
|
||||||
/// a pointer, Size is an 'intptr_t', and File is a pointer to FILE.
|
/// a pointer, Size is an 'intptr_t', and File is a pointer to FILE.
|
||||||
void EmitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder &B);
|
void EmitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder<> &B);
|
||||||
|
|
||||||
};
|
};
|
||||||
} // End anonymous namespace.
|
} // End anonymous namespace.
|
||||||
|
|
||||||
/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
|
/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
|
||||||
Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder &B) {
|
Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) {
|
||||||
return B.CreateBitCast(V, PointerType::getUnqual(Type::Int8Ty), "cstr");
|
return B.CreateBitCast(V, PointerType::getUnqual(Type::Int8Ty), "cstr");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitStrLen - Emit a call to the strlen function to the builder, for the
|
/// EmitStrLen - Emit a call to the strlen function to the builder, for the
|
||||||
/// specified pointer. This always returns an integer value of size intptr_t.
|
/// specified pointer. This always returns an integer value of size intptr_t.
|
||||||
Value *LibCallOptimization::EmitStrLen(Value *Ptr, IRBuilder &B) {
|
Value *LibCallOptimization::EmitStrLen(Value *Ptr, IRBuilder<> &B) {
|
||||||
Module *M = Caller->getParent();
|
Module *M = Caller->getParent();
|
||||||
Constant *StrLen =M->getOrInsertFunction("strlen", TD->getIntPtrType(),
|
Constant *StrLen =M->getOrInsertFunction("strlen", TD->getIntPtrType(),
|
||||||
PointerType::getUnqual(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
@ -127,7 +128,7 @@ Value *LibCallOptimization::EmitStrLen(Value *Ptr, IRBuilder &B) {
|
|||||||
/// EmitMemCpy - Emit a call to the memcpy function to the builder. This always
|
/// EmitMemCpy - Emit a call to the memcpy function to the builder. This always
|
||||||
/// expects that the size has type 'intptr_t' and Dst/Src are pointers.
|
/// expects that the size has type 'intptr_t' and Dst/Src are pointers.
|
||||||
Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len,
|
Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len,
|
||||||
unsigned Align, IRBuilder &B) {
|
unsigned Align, IRBuilder<> &B) {
|
||||||
Module *M = Caller->getParent();
|
Module *M = Caller->getParent();
|
||||||
Intrinsic::ID IID = Len->getType() == Type::Int32Ty ?
|
Intrinsic::ID IID = Len->getType() == Type::Int32Ty ?
|
||||||
Intrinsic::memcpy_i32 : Intrinsic::memcpy_i64;
|
Intrinsic::memcpy_i32 : Intrinsic::memcpy_i64;
|
||||||
@ -139,7 +140,7 @@ Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len,
|
|||||||
/// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is
|
/// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is
|
||||||
/// a pointer, Val is an i32 value, and Len is an 'intptr_t' value.
|
/// a pointer, Val is an i32 value, and Len is an 'intptr_t' value.
|
||||||
Value *LibCallOptimization::EmitMemChr(Value *Ptr, Value *Val,
|
Value *LibCallOptimization::EmitMemChr(Value *Ptr, Value *Val,
|
||||||
Value *Len, IRBuilder &B) {
|
Value *Len, IRBuilder<> &B) {
|
||||||
Module *M = Caller->getParent();
|
Module *M = Caller->getParent();
|
||||||
Value *MemChr = M->getOrInsertFunction("memchr",
|
Value *MemChr = M->getOrInsertFunction("memchr",
|
||||||
PointerType::getUnqual(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
@ -154,7 +155,7 @@ Value *LibCallOptimization::EmitMemChr(Value *Ptr, Value *Val,
|
|||||||
/// returns one value with the same type. If 'Op' is a long double, 'l' is
|
/// returns one value with the same type. If 'Op' is a long double, 'l' is
|
||||||
/// added as the suffix of name, if 'Op' is a float, we add a 'f' suffix.
|
/// added as the suffix of name, if 'Op' is a float, we add a 'f' suffix.
|
||||||
Value *LibCallOptimization::EmitUnaryFloatFnCall(Value *Op, const char *Name,
|
Value *LibCallOptimization::EmitUnaryFloatFnCall(Value *Op, const char *Name,
|
||||||
IRBuilder &B) {
|
IRBuilder<> &B) {
|
||||||
char NameBuffer[20];
|
char NameBuffer[20];
|
||||||
if (Op->getType() != Type::DoubleTy) {
|
if (Op->getType() != Type::DoubleTy) {
|
||||||
// If we need to add a suffix, copy into NameBuffer.
|
// If we need to add a suffix, copy into NameBuffer.
|
||||||
@ -177,7 +178,7 @@ Value *LibCallOptimization::EmitUnaryFloatFnCall(Value *Op, const char *Name,
|
|||||||
|
|
||||||
/// EmitPutChar - Emit a call to the putchar function. This assumes that Char
|
/// EmitPutChar - Emit a call to the putchar function. This assumes that Char
|
||||||
/// is an integer.
|
/// is an integer.
|
||||||
void LibCallOptimization::EmitPutChar(Value *Char, IRBuilder &B) {
|
void LibCallOptimization::EmitPutChar(Value *Char, IRBuilder<> &B) {
|
||||||
Module *M = Caller->getParent();
|
Module *M = Caller->getParent();
|
||||||
Value *F = M->getOrInsertFunction("putchar", Type::Int32Ty,
|
Value *F = M->getOrInsertFunction("putchar", Type::Int32Ty,
|
||||||
Type::Int32Ty, NULL);
|
Type::Int32Ty, NULL);
|
||||||
@ -186,7 +187,7 @@ void LibCallOptimization::EmitPutChar(Value *Char, IRBuilder &B) {
|
|||||||
|
|
||||||
/// EmitPutS - Emit a call to the puts function. This assumes that Str is
|
/// EmitPutS - Emit a call to the puts function. This assumes that Str is
|
||||||
/// some pointer.
|
/// some pointer.
|
||||||
void LibCallOptimization::EmitPutS(Value *Str, IRBuilder &B) {
|
void LibCallOptimization::EmitPutS(Value *Str, IRBuilder<> &B) {
|
||||||
Module *M = Caller->getParent();
|
Module *M = Caller->getParent();
|
||||||
Value *F = M->getOrInsertFunction("puts", Type::Int32Ty,
|
Value *F = M->getOrInsertFunction("puts", Type::Int32Ty,
|
||||||
PointerType::getUnqual(Type::Int8Ty), NULL);
|
PointerType::getUnqual(Type::Int8Ty), NULL);
|
||||||
@ -195,7 +196,7 @@ void LibCallOptimization::EmitPutS(Value *Str, IRBuilder &B) {
|
|||||||
|
|
||||||
/// EmitFPutC - Emit a call to the fputc function. This assumes that Char is
|
/// EmitFPutC - Emit a call to the fputc function. This assumes that Char is
|
||||||
/// an integer and File is a pointer to FILE.
|
/// an integer and File is a pointer to FILE.
|
||||||
void LibCallOptimization::EmitFPutC(Value *Char, Value *File, IRBuilder &B) {
|
void LibCallOptimization::EmitFPutC(Value *Char, Value *File, IRBuilder<> &B) {
|
||||||
Module *M = Caller->getParent();
|
Module *M = Caller->getParent();
|
||||||
Constant *F = M->getOrInsertFunction("fputc", Type::Int32Ty, Type::Int32Ty,
|
Constant *F = M->getOrInsertFunction("fputc", Type::Int32Ty, Type::Int32Ty,
|
||||||
File->getType(), NULL);
|
File->getType(), NULL);
|
||||||
@ -205,7 +206,7 @@ void LibCallOptimization::EmitFPutC(Value *Char, Value *File, IRBuilder &B) {
|
|||||||
|
|
||||||
/// EmitFPutS - Emit a call to the puts function. Str is required to be a
|
/// EmitFPutS - Emit a call to the puts function. Str is required to be a
|
||||||
/// pointer and File is a pointer to FILE.
|
/// pointer and File is a pointer to FILE.
|
||||||
void LibCallOptimization::EmitFPutS(Value *Str, Value *File, IRBuilder &B) {
|
void LibCallOptimization::EmitFPutS(Value *Str, Value *File, IRBuilder<> &B) {
|
||||||
Module *M = Caller->getParent();
|
Module *M = Caller->getParent();
|
||||||
Constant *F = M->getOrInsertFunction("fputs", Type::Int32Ty,
|
Constant *F = M->getOrInsertFunction("fputs", Type::Int32Ty,
|
||||||
PointerType::getUnqual(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
@ -216,7 +217,7 @@ void LibCallOptimization::EmitFPutS(Value *Str, Value *File, IRBuilder &B) {
|
|||||||
/// EmitFWrite - Emit a call to the fwrite function. This assumes that Ptr is
|
/// EmitFWrite - Emit a call to the fwrite function. This assumes that Ptr is
|
||||||
/// a pointer, Size is an 'intptr_t', and File is a pointer to FILE.
|
/// a pointer, Size is an 'intptr_t', and File is a pointer to FILE.
|
||||||
void LibCallOptimization::EmitFWrite(Value *Ptr, Value *Size, Value *File,
|
void LibCallOptimization::EmitFWrite(Value *Ptr, Value *Size, Value *File,
|
||||||
IRBuilder &B) {
|
IRBuilder<> &B) {
|
||||||
Module *M = Caller->getParent();
|
Module *M = Caller->getParent();
|
||||||
Constant *F = M->getOrInsertFunction("fwrite", TD->getIntPtrType(),
|
Constant *F = M->getOrInsertFunction("fwrite", TD->getIntPtrType(),
|
||||||
PointerType::getUnqual(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
@ -379,7 +380,7 @@ namespace {
|
|||||||
|
|
||||||
/// ExitOpt - int main() { exit(4); } --> int main() { return 4; }
|
/// ExitOpt - int main() { exit(4); } --> int main() { return 4; }
|
||||||
struct VISIBILITY_HIDDEN ExitOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN ExitOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Verify we have a reasonable prototype for exit.
|
// Verify we have a reasonable prototype for exit.
|
||||||
if (Callee->arg_size() == 0 || !CI->use_empty())
|
if (Callee->arg_size() == 0 || !CI->use_empty())
|
||||||
return 0;
|
return 0;
|
||||||
@ -415,7 +416,7 @@ struct VISIBILITY_HIDDEN ExitOpt : public LibCallOptimization {
|
|||||||
// 'strcat' Optimizations
|
// 'strcat' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN StrCatOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN StrCatOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Verify the "strcat" function prototype.
|
// Verify the "strcat" function prototype.
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 2 ||
|
if (FT->getNumParams() != 2 ||
|
||||||
@ -457,7 +458,7 @@ struct VISIBILITY_HIDDEN StrCatOpt : public LibCallOptimization {
|
|||||||
// 'strchr' Optimizations
|
// 'strchr' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN StrChrOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN StrChrOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Verify the "strchr" function prototype.
|
// Verify the "strchr" function prototype.
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 2 ||
|
if (FT->getNumParams() != 2 ||
|
||||||
@ -510,7 +511,7 @@ struct VISIBILITY_HIDDEN StrChrOpt : public LibCallOptimization {
|
|||||||
// 'strcmp' Optimizations
|
// 'strcmp' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN StrCmpOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN StrCmpOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Verify the "strcmp" function prototype.
|
// Verify the "strcmp" function prototype.
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 2 || FT->getReturnType() != Type::Int32Ty ||
|
if (FT->getNumParams() != 2 || FT->getReturnType() != Type::Int32Ty ||
|
||||||
@ -543,7 +544,7 @@ struct VISIBILITY_HIDDEN StrCmpOpt : public LibCallOptimization {
|
|||||||
// 'strncmp' Optimizations
|
// 'strncmp' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN StrNCmpOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN StrNCmpOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Verify the "strncmp" function prototype.
|
// Verify the "strncmp" function prototype.
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 3 || FT->getReturnType() != Type::Int32Ty ||
|
if (FT->getNumParams() != 3 || FT->getReturnType() != Type::Int32Ty ||
|
||||||
@ -589,7 +590,7 @@ struct VISIBILITY_HIDDEN StrNCmpOpt : public LibCallOptimization {
|
|||||||
// 'strcpy' Optimizations
|
// 'strcpy' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN StrCpyOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN StrCpyOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Verify the "strcpy" function prototype.
|
// Verify the "strcpy" function prototype.
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) ||
|
if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) ||
|
||||||
@ -618,7 +619,7 @@ struct VISIBILITY_HIDDEN StrCpyOpt : public LibCallOptimization {
|
|||||||
// 'strlen' Optimizations
|
// 'strlen' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN StrLenOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN StrLenOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 1 ||
|
if (FT->getNumParams() != 1 ||
|
||||||
FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
|
FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
|
||||||
@ -644,7 +645,7 @@ struct VISIBILITY_HIDDEN StrLenOpt : public LibCallOptimization {
|
|||||||
// 'memcmp' Optimizations
|
// 'memcmp' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN MemCmpOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN MemCmpOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 3 || !isa<PointerType>(FT->getParamType(0)) ||
|
if (FT->getNumParams() != 3 || !isa<PointerType>(FT->getParamType(0)) ||
|
||||||
!isa<PointerType>(FT->getParamType(1)) ||
|
!isa<PointerType>(FT->getParamType(1)) ||
|
||||||
@ -691,7 +692,7 @@ struct VISIBILITY_HIDDEN MemCmpOpt : public LibCallOptimization {
|
|||||||
// 'memcpy' Optimizations
|
// 'memcpy' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN MemCpyOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN MemCpyOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) ||
|
if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) ||
|
||||||
!isa<PointerType>(FT->getParamType(0)) ||
|
!isa<PointerType>(FT->getParamType(0)) ||
|
||||||
@ -713,7 +714,7 @@ struct VISIBILITY_HIDDEN MemCpyOpt : public LibCallOptimization {
|
|||||||
// 'pow*' Optimizations
|
// 'pow*' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN PowOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN PowOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
// Just make sure this has 2 arguments of the same FP type, which match the
|
// Just make sure this has 2 arguments of the same FP type, which match the
|
||||||
// result type.
|
// result type.
|
||||||
@ -763,7 +764,7 @@ struct VISIBILITY_HIDDEN PowOpt : public LibCallOptimization {
|
|||||||
// 'exp2' Optimizations
|
// 'exp2' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN Exp2Opt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN Exp2Opt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
// Just make sure this has 1 argument of FP type, which matches the
|
// Just make sure this has 1 argument of FP type, which matches the
|
||||||
// result type.
|
// result type.
|
||||||
@ -810,7 +811,7 @@ struct VISIBILITY_HIDDEN Exp2Opt : public LibCallOptimization {
|
|||||||
// Double -> Float Shrinking Optimizations for Unary Functions like 'floor'
|
// Double -> Float Shrinking Optimizations for Unary Functions like 'floor'
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN UnaryDoubleFPOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN UnaryDoubleFPOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 1 || FT->getReturnType() != Type::DoubleTy ||
|
if (FT->getNumParams() != 1 || FT->getReturnType() != Type::DoubleTy ||
|
||||||
FT->getParamType(0) != Type::DoubleTy)
|
FT->getParamType(0) != Type::DoubleTy)
|
||||||
@ -836,7 +837,7 @@ struct VISIBILITY_HIDDEN UnaryDoubleFPOpt : public LibCallOptimization {
|
|||||||
// 'ffs*' Optimizations
|
// 'ffs*' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN FFSOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN FFSOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
// Just make sure this has 2 arguments of the same FP type, which match the
|
// Just make sure this has 2 arguments of the same FP type, which match the
|
||||||
// result type.
|
// result type.
|
||||||
@ -871,7 +872,7 @@ struct VISIBILITY_HIDDEN FFSOpt : public LibCallOptimization {
|
|||||||
// 'isdigit' Optimizations
|
// 'isdigit' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN IsDigitOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN IsDigitOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
// We require integer(i32)
|
// We require integer(i32)
|
||||||
if (FT->getNumParams() != 1 || !isa<IntegerType>(FT->getReturnType()) ||
|
if (FT->getNumParams() != 1 || !isa<IntegerType>(FT->getReturnType()) ||
|
||||||
@ -890,7 +891,7 @@ struct VISIBILITY_HIDDEN IsDigitOpt : public LibCallOptimization {
|
|||||||
// 'isascii' Optimizations
|
// 'isascii' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN IsAsciiOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN IsAsciiOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
// We require integer(i32)
|
// We require integer(i32)
|
||||||
if (FT->getNumParams() != 1 || !isa<IntegerType>(FT->getReturnType()) ||
|
if (FT->getNumParams() != 1 || !isa<IntegerType>(FT->getReturnType()) ||
|
||||||
@ -908,7 +909,7 @@ struct VISIBILITY_HIDDEN IsAsciiOpt : public LibCallOptimization {
|
|||||||
// 'abs', 'labs', 'llabs' Optimizations
|
// 'abs', 'labs', 'llabs' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN AbsOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN AbsOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
// We require integer(integer) where the types agree.
|
// We require integer(integer) where the types agree.
|
||||||
if (FT->getNumParams() != 1 || !isa<IntegerType>(FT->getReturnType()) ||
|
if (FT->getNumParams() != 1 || !isa<IntegerType>(FT->getReturnType()) ||
|
||||||
@ -929,7 +930,7 @@ struct VISIBILITY_HIDDEN AbsOpt : public LibCallOptimization {
|
|||||||
// 'toascii' Optimizations
|
// 'toascii' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN ToAsciiOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN ToAsciiOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
// We require i32(i32)
|
// We require i32(i32)
|
||||||
if (FT->getNumParams() != 1 || FT->getReturnType() != FT->getParamType(0) ||
|
if (FT->getNumParams() != 1 || FT->getReturnType() != FT->getParamType(0) ||
|
||||||
@ -949,7 +950,7 @@ struct VISIBILITY_HIDDEN ToAsciiOpt : public LibCallOptimization {
|
|||||||
// 'printf' Optimizations
|
// 'printf' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN PrintFOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN PrintFOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Require one fixed pointer argument and an integer/void result.
|
// Require one fixed pointer argument and an integer/void result.
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() < 1 || !isa<PointerType>(FT->getParamType(0)) ||
|
if (FT->getNumParams() < 1 || !isa<PointerType>(FT->getParamType(0)) ||
|
||||||
@ -1009,7 +1010,7 @@ struct VISIBILITY_HIDDEN PrintFOpt : public LibCallOptimization {
|
|||||||
// 'sprintf' Optimizations
|
// 'sprintf' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN SPrintFOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN SPrintFOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Require two fixed pointer arguments and an integer result.
|
// Require two fixed pointer arguments and an integer result.
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 2 || !isa<PointerType>(FT->getParamType(0)) ||
|
if (FT->getNumParams() != 2 || !isa<PointerType>(FT->getParamType(0)) ||
|
||||||
@ -1074,7 +1075,7 @@ struct VISIBILITY_HIDDEN SPrintFOpt : public LibCallOptimization {
|
|||||||
// 'fwrite' Optimizations
|
// 'fwrite' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN FWriteOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN FWriteOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Require a pointer, an integer, an integer, a pointer, returning integer.
|
// Require a pointer, an integer, an integer, a pointer, returning integer.
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 4 || !isa<PointerType>(FT->getParamType(0)) ||
|
if (FT->getNumParams() != 4 || !isa<PointerType>(FT->getParamType(0)) ||
|
||||||
@ -1109,7 +1110,7 @@ struct VISIBILITY_HIDDEN FWriteOpt : public LibCallOptimization {
|
|||||||
// 'fputs' Optimizations
|
// 'fputs' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN FPutsOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN FPutsOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Require two pointers. Also, we can't optimize if return value is used.
|
// Require two pointers. Also, we can't optimize if return value is used.
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 2 || !isa<PointerType>(FT->getParamType(0)) ||
|
if (FT->getNumParams() != 2 || !isa<PointerType>(FT->getParamType(0)) ||
|
||||||
@ -1130,7 +1131,7 @@ struct VISIBILITY_HIDDEN FPutsOpt : public LibCallOptimization {
|
|||||||
// 'fprintf' Optimizations
|
// 'fprintf' Optimizations
|
||||||
|
|
||||||
struct VISIBILITY_HIDDEN FPrintFOpt : public LibCallOptimization {
|
struct VISIBILITY_HIDDEN FPrintFOpt : public LibCallOptimization {
|
||||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder &B) {
|
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||||
// Require two fixed paramters as pointers and integer result.
|
// Require two fixed paramters as pointers and integer result.
|
||||||
const FunctionType *FT = Callee->getFunctionType();
|
const FunctionType *FT = Callee->getFunctionType();
|
||||||
if (FT->getNumParams() != 2 || !isa<PointerType>(FT->getParamType(0)) ||
|
if (FT->getNumParams() != 2 || !isa<PointerType>(FT->getParamType(0)) ||
|
||||||
@ -1293,7 +1294,7 @@ bool SimplifyLibCalls::runOnFunction(Function &F) {
|
|||||||
|
|
||||||
const TargetData &TD = getAnalysis<TargetData>();
|
const TargetData &TD = getAnalysis<TargetData>();
|
||||||
|
|
||||||
IRBuilder Builder;
|
IRBuilder<> Builder;
|
||||||
|
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
|
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
|
||||||
|
@ -992,7 +992,7 @@ LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index) {
|
|||||||
/*===-- Instruction builders ----------------------------------------------===*/
|
/*===-- Instruction builders ----------------------------------------------===*/
|
||||||
|
|
||||||
LLVMBuilderRef LLVMCreateBuilder(void) {
|
LLVMBuilderRef LLVMCreateBuilder(void) {
|
||||||
return wrap(new IRBuilder());
|
return wrap(new IRBuilder<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
|
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
|
||||||
|
Loading…
Reference in New Issue
Block a user