mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-01 02:29:19 +00:00
Change the PointerType api for creating pointer types. The old functionality of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45082 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
303dae993a
commit
43ad6b3e0d
@ -54,7 +54,7 @@ void BrainF::header() {
|
|||||||
//declare void @llvm.memset.i32(i8 *, i8, i32, i32)
|
//declare void @llvm.memset.i32(i8 *, i8, i32, i32)
|
||||||
Function *memset_func = cast<Function>(module->
|
Function *memset_func = cast<Function>(module->
|
||||||
getOrInsertFunction("llvm.memset.i32", Type::VoidTy,
|
getOrInsertFunction("llvm.memset.i32", Type::VoidTy,
|
||||||
PointerType::get(IntegerType::Int8Ty),
|
PointerType::getUnqual(IntegerType::Int8Ty),
|
||||||
IntegerType::Int8Ty, IntegerType::Int32Ty,
|
IntegerType::Int8Ty, IntegerType::Int32Ty,
|
||||||
IntegerType::Int32Ty, NULL));
|
IntegerType::Int32Ty, NULL));
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ void BrainF::header() {
|
|||||||
//declare i32 @puts(i8 *)
|
//declare i32 @puts(i8 *)
|
||||||
Function *puts_func = cast<Function>(module->
|
Function *puts_func = cast<Function>(module->
|
||||||
getOrInsertFunction("puts", IntegerType::Int32Ty,
|
getOrInsertFunction("puts", IntegerType::Int32Ty,
|
||||||
PointerType::get(IntegerType::Int8Ty), NULL));
|
PointerType::getUnqual(IntegerType::Int8Ty), NULL));
|
||||||
|
|
||||||
//brainf.aberror:
|
//brainf.aberror:
|
||||||
aberrorbb = new BasicBlock(label, brainf_func);
|
aberrorbb = new BasicBlock(label, brainf_func);
|
||||||
@ -282,7 +282,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
|
|||||||
builder->SetInsertPoint(bb_1);
|
builder->SetInsertPoint(bb_1);
|
||||||
|
|
||||||
//Make part of PHI instruction now, wait until end of loop to finish
|
//Make part of PHI instruction now, wait until end of loop to finish
|
||||||
PHINode *phi_0 = new PHINode(PointerType::get(IntegerType::Int8Ty),
|
PHINode *phi_0 = new PHINode(PointerType::getUnqual(IntegerType::Int8Ty),
|
||||||
headreg, testbb);
|
headreg, testbb);
|
||||||
phi_0->reserveOperandSpace(2);
|
phi_0->reserveOperandSpace(2);
|
||||||
phi_0->addIncoming(curhead, bb_0);
|
phi_0->addIncoming(curhead, bb_0);
|
||||||
@ -439,7 +439,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
|
|||||||
|
|
||||||
//%head.%d = phi i8 *[%head.%d, %main.%d]
|
//%head.%d = phi i8 *[%head.%d, %main.%d]
|
||||||
PHINode *phi_1 = builder->
|
PHINode *phi_1 = builder->
|
||||||
CreatePHI(PointerType::get(IntegerType::Int8Ty), headreg);
|
CreatePHI(PointerType::getUnqual(IntegerType::Int8Ty), headreg);
|
||||||
phi_1->reserveOperandSpace(1);
|
phi_1->reserveOperandSpace(1);
|
||||||
phi_1->addIncoming(head_0, testbb);
|
phi_1->addIncoming(head_0, testbb);
|
||||||
curhead = phi_1;
|
curhead = phi_1;
|
||||||
|
@ -59,7 +59,7 @@ void addMainFunction(Module *mod) {
|
|||||||
//define i32 @main(i32 %argc, i8 **%argv)
|
//define i32 @main(i32 %argc, i8 **%argv)
|
||||||
Function *main_func = cast<Function>(mod->
|
Function *main_func = cast<Function>(mod->
|
||||||
getOrInsertFunction("main", IntegerType::Int32Ty, IntegerType::Int32Ty,
|
getOrInsertFunction("main", IntegerType::Int32Ty, IntegerType::Int32Ty,
|
||||||
PointerType::get(PointerType::get(
|
PointerType::getUnqual(PointerType::getUnqual(
|
||||||
IntegerType::Int8Ty)), NULL));
|
IntegerType::Int8Ty)), NULL));
|
||||||
{
|
{
|
||||||
Function::arg_iterator args = main_func->arg_begin();
|
Function::arg_iterator args = main_func->arg_begin();
|
||||||
|
@ -369,8 +369,15 @@ class PointerType : public SequentialType {
|
|||||||
const PointerType &operator=(const PointerType &); // Do not implement
|
const PointerType &operator=(const PointerType &); // Do not implement
|
||||||
explicit PointerType(const Type *ElType, unsigned AddrSpace);
|
explicit PointerType(const Type *ElType, unsigned AddrSpace);
|
||||||
public:
|
public:
|
||||||
/// PointerType::get - This is the only way to construct a new pointer type.
|
/// PointerType::get - This constructs a pointer to an object of the specified
|
||||||
static PointerType *get(const Type *ElementType, unsigned AddressSpace = 0);
|
/// type in a numbered address space.
|
||||||
|
static PointerType *get(const Type *ElementType, unsigned AddressSpace);
|
||||||
|
|
||||||
|
/// PointerType::getUnqual - This constructs a pointer to an object of the
|
||||||
|
/// specified type in the generic address space (address space zero).
|
||||||
|
static PointerType *getUnqual(const Type *ElementType) {
|
||||||
|
return PointerType::get(ElementType, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Return the address space of the Pointer type.
|
/// @brief Return the address space of the Pointer type.
|
||||||
inline unsigned getAddressSpace() const { return AddressSpace; }
|
inline unsigned getAddressSpace() const { return AddressSpace; }
|
||||||
|
@ -2280,7 +2280,7 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
|
|||||||
PAL = ParamAttrsList::get(Attrs);
|
PAL = ParamAttrsList::get(Attrs);
|
||||||
|
|
||||||
FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg);
|
FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg);
|
||||||
const PointerType *PFT = PointerType::get(FT);
|
const PointerType *PFT = PointerType::getUnqual(FT);
|
||||||
delete $2;
|
delete $2;
|
||||||
|
|
||||||
ValID ID;
|
ValID ID;
|
||||||
@ -2627,7 +2627,7 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
|||||||
ParamTypes.push_back(Ty);
|
ParamTypes.push_back(Ty);
|
||||||
}
|
}
|
||||||
Ty = FunctionType::get($3->get(), ParamTypes, false);
|
Ty = FunctionType::get($3->get(), ParamTypes, false);
|
||||||
PFTy = PointerType::get(Ty);
|
PFTy = PointerType::getUnqual(Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete $3;
|
delete $3;
|
||||||
@ -2954,7 +2954,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
|||||||
ParamTypes.push_back(Ty);
|
ParamTypes.push_back(Ty);
|
||||||
}
|
}
|
||||||
Ty = FunctionType::get($3->get(), ParamTypes, false);
|
Ty = FunctionType::get($3->get(), ParamTypes, false);
|
||||||
PFTy = PointerType::get(Ty);
|
PFTy = PointerType::getUnqual(Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *V = getVal(PFTy, $4); // Get the function we're calling...
|
Value *V = getVal(PFTy, $4); // Get the function we're calling...
|
||||||
|
@ -1509,7 +1509,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
|
|||||||
unsigned OpNum = 0;
|
unsigned OpNum = 0;
|
||||||
Value *Val, *Ptr;
|
Value *Val, *Ptr;
|
||||||
if (getValueTypePair(Record, OpNum, NextValueNo, Val) ||
|
if (getValueTypePair(Record, OpNum, NextValueNo, Val) ||
|
||||||
getValue(Record, OpNum, PointerType::get(Val->getType()), Ptr) ||
|
getValue(Record, OpNum, PointerType::getUnqual(Val->getType()), Ptr)||
|
||||||
OpNum+2 != Record.size())
|
OpNum+2 != Record.size())
|
||||||
return Error("Invalid STORE record");
|
return Error("Invalid STORE record");
|
||||||
|
|
||||||
|
@ -81,22 +81,23 @@ void IntrinsicLowering::AddPrototypes(Module &M) {
|
|||||||
break;
|
break;
|
||||||
case Intrinsic::memcpy_i32:
|
case Intrinsic::memcpy_i32:
|
||||||
case Intrinsic::memcpy_i64:
|
case Intrinsic::memcpy_i64:
|
||||||
M.getOrInsertFunction("memcpy", PointerType::get(Type::Int8Ty),
|
M.getOrInsertFunction("memcpy", PointerType::getUnqual(Type::Int8Ty),
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
TD.getIntPtrType(), (Type *)0);
|
TD.getIntPtrType(), (Type *)0);
|
||||||
break;
|
break;
|
||||||
case Intrinsic::memmove_i32:
|
case Intrinsic::memmove_i32:
|
||||||
case Intrinsic::memmove_i64:
|
case Intrinsic::memmove_i64:
|
||||||
M.getOrInsertFunction("memmove", PointerType::get(Type::Int8Ty),
|
M.getOrInsertFunction("memmove", PointerType::getUnqual(Type::Int8Ty),
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
TD.getIntPtrType(), (Type *)0);
|
TD.getIntPtrType(), (Type *)0);
|
||||||
break;
|
break;
|
||||||
case Intrinsic::memset_i32:
|
case Intrinsic::memset_i32:
|
||||||
case Intrinsic::memset_i64:
|
case Intrinsic::memset_i64:
|
||||||
M.getOrInsertFunction("memset", PointerType::get(Type::Int8Ty),
|
M.getOrInsertFunction("memset", PointerType::getUnqual(Type::Int8Ty),
|
||||||
PointerType::get(Type::Int8Ty), Type::Int32Ty,
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
|
Type::Int32Ty,
|
||||||
TD.getIntPtrType(), (Type *)0);
|
TD.getIntPtrType(), (Type *)0);
|
||||||
break;
|
break;
|
||||||
case Intrinsic::sqrt:
|
case Intrinsic::sqrt:
|
||||||
|
@ -1262,7 +1262,7 @@ const PointerType *DISerializer::getStrPtrType() {
|
|||||||
// If not already defined.
|
// If not already defined.
|
||||||
if (!StrPtrTy) {
|
if (!StrPtrTy) {
|
||||||
// Construct the pointer to signed bytes.
|
// Construct the pointer to signed bytes.
|
||||||
StrPtrTy = PointerType::get(Type::Int8Ty);
|
StrPtrTy = PointerType::getUnqual(Type::Int8Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
return StrPtrTy;
|
return StrPtrTy;
|
||||||
@ -1277,7 +1277,7 @@ const PointerType *DISerializer::getEmptyStructPtrType() {
|
|||||||
const StructType *EmptyStructTy =
|
const StructType *EmptyStructTy =
|
||||||
StructType::get(std::vector<const Type*>());
|
StructType::get(std::vector<const Type*>());
|
||||||
// Construct the pointer to empty structure type.
|
// Construct the pointer to empty structure type.
|
||||||
EmptyStructPtrTy = PointerType::get(EmptyStructTy);
|
EmptyStructPtrTy = PointerType::getUnqual(EmptyStructTy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EmptyStructPtrTy;
|
return EmptyStructPtrTy;
|
||||||
|
@ -170,7 +170,7 @@ static void *CreateArgv(ExecutionEngine *EE,
|
|||||||
char *Result = new char[(InputArgv.size()+1)*PtrSize];
|
char *Result = new char[(InputArgv.size()+1)*PtrSize];
|
||||||
|
|
||||||
DOUT << "ARGV = " << (void*)Result << "\n";
|
DOUT << "ARGV = " << (void*)Result << "\n";
|
||||||
const Type *SBytePtr = PointerType::get(Type::Int8Ty);
|
const Type *SBytePtr = PointerType::getUnqual(Type::Int8Ty);
|
||||||
|
|
||||||
for (unsigned i = 0; i != InputArgv.size(); ++i) {
|
for (unsigned i = 0; i != InputArgv.size(); ++i) {
|
||||||
unsigned Size = InputArgv[i].size()+1;
|
unsigned Size = InputArgv[i].size()+1;
|
||||||
@ -255,7 +255,8 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn,
|
|||||||
// Check main() type
|
// Check main() type
|
||||||
unsigned NumArgs = Fn->getFunctionType()->getNumParams();
|
unsigned NumArgs = Fn->getFunctionType()->getNumParams();
|
||||||
const FunctionType *FTy = Fn->getFunctionType();
|
const FunctionType *FTy = Fn->getFunctionType();
|
||||||
const Type* PPInt8Ty = PointerType::get(PointerType::get(Type::Int8Ty));
|
const Type* PPInt8Ty =
|
||||||
|
PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty));
|
||||||
switch (NumArgs) {
|
switch (NumArgs) {
|
||||||
case 3:
|
case 3:
|
||||||
if (FTy->getParamType(2) != PPInt8Ty) {
|
if (FTy->getParamType(2) != PPInt8Ty) {
|
||||||
|
@ -783,7 +783,7 @@ void MSILWriter::printIntrinsicCall(const IntrinsicInst* Inst) {
|
|||||||
// Save as pointer type "void*"
|
// Save as pointer type "void*"
|
||||||
printValueLoad(Inst->getOperand(1));
|
printValueLoad(Inst->getOperand(1));
|
||||||
printSimpleInstruction("ldloca",Name.c_str());
|
printSimpleInstruction("ldloca",Name.c_str());
|
||||||
printIndirectSave(PointerType::get(IntegerType::get(8)));
|
printIndirectSave(PointerType::getUnqual(IntegerType::get(8)));
|
||||||
break;
|
break;
|
||||||
case Intrinsic::vaend:
|
case Intrinsic::vaend:
|
||||||
// Close argument list handle.
|
// Close argument list handle.
|
||||||
@ -1002,7 +1002,8 @@ void MSILWriter::printVAArgInstruction(const VAArgInst* Inst) {
|
|||||||
printSimpleInstruction("call",
|
printSimpleInstruction("call",
|
||||||
"instance typedref [mscorlib]System.ArgIterator::GetNextArg()");
|
"instance typedref [mscorlib]System.ArgIterator::GetNextArg()");
|
||||||
printSimpleInstruction("refanyval","void*");
|
printSimpleInstruction("refanyval","void*");
|
||||||
std::string Name = "ldind."+getTypePostfix(PointerType::get(IntegerType::get(8)),false);
|
std::string Name =
|
||||||
|
"ldind."+getTypePostfix(PointerType::getUnqual(IntegerType::get(8)),false);
|
||||||
printSimpleInstruction(Name.c_str());
|
printSimpleInstruction(Name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1217,7 +1218,7 @@ void MSILWriter::printLocalVariables(const Function& F) {
|
|||||||
const AllocaInst* AI = dyn_cast<AllocaInst>(&*I);
|
const AllocaInst* AI = dyn_cast<AllocaInst>(&*I);
|
||||||
if (AI && !isa<GlobalVariable>(AI)) {
|
if (AI && !isa<GlobalVariable>(AI)) {
|
||||||
// Local variable allocation.
|
// Local variable allocation.
|
||||||
Ty = PointerType::get(AI->getAllocatedType());
|
Ty = PointerType::getUnqual(AI->getAllocatedType());
|
||||||
Name = getValueName(AI);
|
Name = getValueName(AI);
|
||||||
Out << "\t.locals (" << getTypeName(Ty) << Name << ")\n";
|
Out << "\t.locals (" << getTypeName(Ty) << Name << ")\n";
|
||||||
} else if (I->getType()!=Type::VoidTy) {
|
} else if (I->getType()!=Type::VoidTy) {
|
||||||
|
@ -1052,7 +1052,7 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI){
|
|||||||
|
|
||||||
for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){
|
for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){
|
||||||
const Type *FieldTy = STy->getElementType(FieldNo);
|
const Type *FieldTy = STy->getElementType(FieldNo);
|
||||||
const Type *PFieldTy = PointerType::get(FieldTy);
|
const Type *PFieldTy = PointerType::getUnqual(FieldTy);
|
||||||
|
|
||||||
GlobalVariable *NGV =
|
GlobalVariable *NGV =
|
||||||
new GlobalVariable(PFieldTy, false, GlobalValue::InternalLinkage,
|
new GlobalVariable(PFieldTy, false, GlobalValue::InternalLinkage,
|
||||||
@ -1618,7 +1618,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
|
|||||||
} else {
|
} else {
|
||||||
const Type *FTy = FunctionType::get(Type::VoidTy,
|
const Type *FTy = FunctionType::get(Type::VoidTy,
|
||||||
std::vector<const Type*>(), false);
|
std::vector<const Type*>(), false);
|
||||||
const PointerType *PFTy = PointerType::get(FTy);
|
const PointerType *PFTy = PointerType::getUnqual(FTy);
|
||||||
CSVals[1] = Constant::getNullValue(PFTy);
|
CSVals[1] = Constant::getNullValue(PFTy);
|
||||||
CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
|
CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
|
||||||
}
|
}
|
||||||
|
@ -199,8 +199,8 @@ bool LowerSetJmp::runOnModule(Module& M) {
|
|||||||
// This function is always successful, unless it isn't.
|
// This function is always successful, unless it isn't.
|
||||||
bool LowerSetJmp::doInitialization(Module& M)
|
bool LowerSetJmp::doInitialization(Module& M)
|
||||||
{
|
{
|
||||||
const Type *SBPTy = PointerType::get(Type::Int8Ty);
|
const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
|
||||||
const Type *SBPPTy = PointerType::get(SBPTy);
|
const Type *SBPPTy = PointerType::getUnqual(SBPTy);
|
||||||
|
|
||||||
// N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for
|
// N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for
|
||||||
// a description of the following library functions.
|
// a description of the following library functions.
|
||||||
@ -256,7 +256,7 @@ bool LowerSetJmp::IsTransformableFunction(const std::string& Name) {
|
|||||||
// throwing the exception for us.
|
// throwing the exception for us.
|
||||||
void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
|
void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
|
||||||
{
|
{
|
||||||
const Type* SBPTy = PointerType::get(Type::Int8Ty);
|
const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
|
||||||
|
|
||||||
// Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
|
// Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
|
||||||
// same parameters as "longjmp", except that the buffer is cast to a
|
// same parameters as "longjmp", except that the buffer is cast to a
|
||||||
@ -308,7 +308,7 @@ AllocaInst* LowerSetJmp::GetSetJmpMap(Function* Func)
|
|||||||
assert(Inst && "Couldn't find even ONE instruction in entry block!");
|
assert(Inst && "Couldn't find even ONE instruction in entry block!");
|
||||||
|
|
||||||
// Fill in the alloca and call to initialize the SJ map.
|
// Fill in the alloca and call to initialize the SJ map.
|
||||||
const Type *SBPTy = PointerType::get(Type::Int8Ty);
|
const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
|
||||||
AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
|
AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
|
||||||
new CallInst(InitSJMap, Map, "", Inst);
|
new CallInst(InitSJMap, Map, "", Inst);
|
||||||
return SJMap[Func] = Map;
|
return SJMap[Func] = Map;
|
||||||
@ -378,7 +378,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
|
|||||||
Function* Func = ABlock->getParent();
|
Function* Func = ABlock->getParent();
|
||||||
|
|
||||||
// Add this setjmp to the setjmp map.
|
// Add this setjmp to the setjmp map.
|
||||||
const Type* SBPTy = PointerType::get(Type::Int8Ty);
|
const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
|
||||||
CastInst* BufPtr =
|
CastInst* BufPtr =
|
||||||
new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
|
new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
|
||||||
std::vector<Value*> Args =
|
std::vector<Value*> Args =
|
||||||
|
@ -78,7 +78,7 @@ void RaiseAllocations::doInitialization(Module &M) {
|
|||||||
|
|
||||||
// Get the expected prototype for malloc
|
// Get the expected prototype for malloc
|
||||||
const FunctionType *Malloc1Type =
|
const FunctionType *Malloc1Type =
|
||||||
FunctionType::get(PointerType::get(Type::Int8Ty),
|
FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
|
||||||
std::vector<const Type*>(1, Type::Int64Ty), false);
|
std::vector<const Type*>(1, Type::Int64Ty), false);
|
||||||
|
|
||||||
// Chck to see if we got the expected malloc
|
// Chck to see if we got the expected malloc
|
||||||
@ -86,14 +86,14 @@ void RaiseAllocations::doInitialization(Module &M) {
|
|||||||
// Check to see if the prototype is wrong, giving us sbyte*(uint) * malloc
|
// Check to see if the prototype is wrong, giving us sbyte*(uint) * malloc
|
||||||
// This handles the common declaration of: 'void *malloc(unsigned);'
|
// This handles the common declaration of: 'void *malloc(unsigned);'
|
||||||
const FunctionType *Malloc2Type =
|
const FunctionType *Malloc2Type =
|
||||||
FunctionType::get(PointerType::get(Type::Int8Ty),
|
FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
|
||||||
std::vector<const Type*>(1, Type::Int32Ty), false);
|
std::vector<const Type*>(1, Type::Int32Ty), false);
|
||||||
if (TyWeHave != Malloc2Type) {
|
if (TyWeHave != Malloc2Type) {
|
||||||
// Check to see if the prototype is missing, giving us
|
// Check to see if the prototype is missing, giving us
|
||||||
// sbyte*(...) * malloc
|
// sbyte*(...) * malloc
|
||||||
// This handles the common declaration of: 'void *malloc();'
|
// This handles the common declaration of: 'void *malloc();'
|
||||||
const FunctionType *Malloc3Type =
|
const FunctionType *Malloc3Type =
|
||||||
FunctionType::get(PointerType::get(Type::Int8Ty),
|
FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
|
||||||
std::vector<const Type*>(), true);
|
std::vector<const Type*>(), true);
|
||||||
if (TyWeHave != Malloc3Type)
|
if (TyWeHave != Malloc3Type)
|
||||||
// Give up
|
// Give up
|
||||||
@ -108,7 +108,7 @@ void RaiseAllocations::doInitialization(Module &M) {
|
|||||||
|
|
||||||
// Get the expected prototype for void free(i8*)
|
// Get the expected prototype for void free(i8*)
|
||||||
const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
|
const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
|
||||||
std::vector<const Type*>(1, PointerType::get(Type::Int8Ty)), false);
|
std::vector<const Type*>(1, PointerType::getUnqual(Type::Int8Ty)), false);
|
||||||
|
|
||||||
if (TyWeHave != Free1Type) {
|
if (TyWeHave != Free1Type) {
|
||||||
// Check to see if the prototype was forgotten, giving us
|
// Check to see if the prototype was forgotten, giving us
|
||||||
@ -219,7 +219,8 @@ bool RaiseAllocations::runOnModule(Module &M) {
|
|||||||
//
|
//
|
||||||
Value *Source = *CS.arg_begin();
|
Value *Source = *CS.arg_begin();
|
||||||
if (!isa<PointerType>(Source->getType()))
|
if (!isa<PointerType>(Source->getType()))
|
||||||
Source = new IntToPtrInst(Source, PointerType::get(Type::Int8Ty),
|
Source = new IntToPtrInst(Source,
|
||||||
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
"FreePtrCast", I);
|
"FreePtrCast", I);
|
||||||
new FreeInst(Source, I);
|
new FreeInst(Source, I);
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ public:
|
|||||||
Constant *get_puts() {
|
Constant *get_puts() {
|
||||||
if (!puts_func)
|
if (!puts_func)
|
||||||
puts_func = M->getOrInsertFunction("puts", Type::Int32Ty,
|
puts_func = M->getOrInsertFunction("puts", Type::Int32Ty,
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
NULL);
|
NULL);
|
||||||
return puts_func;
|
return puts_func;
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ public:
|
|||||||
Constant *get_fputs(const Type* FILEptr_type) {
|
Constant *get_fputs(const Type* FILEptr_type) {
|
||||||
if (!fputs_func)
|
if (!fputs_func)
|
||||||
fputs_func = M->getOrInsertFunction("fputs", Type::Int32Ty,
|
fputs_func = M->getOrInsertFunction("fputs", Type::Int32Ty,
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
FILEptr_type, NULL);
|
FILEptr_type, NULL);
|
||||||
return fputs_func;
|
return fputs_func;
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ public:
|
|||||||
Constant *get_fwrite(const Type* FILEptr_type) {
|
Constant *get_fwrite(const Type* FILEptr_type) {
|
||||||
if (!fwrite_func)
|
if (!fwrite_func)
|
||||||
fwrite_func = M->getOrInsertFunction("fwrite", TD->getIntPtrType(),
|
fwrite_func = M->getOrInsertFunction("fwrite", TD->getIntPtrType(),
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
TD->getIntPtrType(),
|
TD->getIntPtrType(),
|
||||||
TD->getIntPtrType(),
|
TD->getIntPtrType(),
|
||||||
FILEptr_type, NULL);
|
FILEptr_type, NULL);
|
||||||
@ -289,9 +289,9 @@ public:
|
|||||||
Constant *get_strcpy() {
|
Constant *get_strcpy() {
|
||||||
if (!strcpy_func)
|
if (!strcpy_func)
|
||||||
strcpy_func = M->getOrInsertFunction("strcpy",
|
strcpy_func = M->getOrInsertFunction("strcpy",
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
NULL);
|
NULL);
|
||||||
return strcpy_func;
|
return strcpy_func;
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ public:
|
|||||||
Constant *get_strlen() {
|
Constant *get_strlen() {
|
||||||
if (!strlen_func)
|
if (!strlen_func)
|
||||||
strlen_func = M->getOrInsertFunction("strlen", TD->getIntPtrType(),
|
strlen_func = M->getOrInsertFunction("strlen", TD->getIntPtrType(),
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
NULL);
|
NULL);
|
||||||
return strlen_func;
|
return strlen_func;
|
||||||
}
|
}
|
||||||
@ -309,8 +309,8 @@ public:
|
|||||||
Constant *get_memchr() {
|
Constant *get_memchr() {
|
||||||
if (!memchr_func)
|
if (!memchr_func)
|
||||||
memchr_func = M->getOrInsertFunction("memchr",
|
memchr_func = M->getOrInsertFunction("memchr",
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
Type::Int32Ty, TD->getIntPtrType(),
|
Type::Int32Ty, TD->getIntPtrType(),
|
||||||
NULL);
|
NULL);
|
||||||
return memchr_func;
|
return memchr_func;
|
||||||
@ -319,7 +319,7 @@ public:
|
|||||||
/// @brief Return a Function* for the memcpy libcall
|
/// @brief Return a Function* for the memcpy libcall
|
||||||
Constant *get_memcpy() {
|
Constant *get_memcpy() {
|
||||||
if (!memcpy_func) {
|
if (!memcpy_func) {
|
||||||
const Type *SBP = PointerType::get(Type::Int8Ty);
|
const Type *SBP = PointerType::getUnqual(Type::Int8Ty);
|
||||||
const char *N = TD->getIntPtrType() == Type::Int32Ty ?
|
const char *N = TD->getIntPtrType() == Type::Int32Ty ?
|
||||||
"llvm.memcpy.i32" : "llvm.memcpy.i64";
|
"llvm.memcpy.i32" : "llvm.memcpy.i64";
|
||||||
memcpy_func = M->getOrInsertFunction(N, Type::VoidTy, SBP, SBP,
|
memcpy_func = M->getOrInsertFunction(N, Type::VoidTy, SBP, SBP,
|
||||||
@ -471,7 +471,7 @@ public:
|
|||||||
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
||||||
const FunctionType *FT = F->getFunctionType();
|
const FunctionType *FT = F->getFunctionType();
|
||||||
return FT->getNumParams() == 2 &&
|
return FT->getNumParams() == 2 &&
|
||||||
FT->getReturnType() == PointerType::get(Type::Int8Ty) &&
|
FT->getReturnType() == PointerType::getUnqual(Type::Int8Ty) &&
|
||||||
FT->getParamType(0) == FT->getReturnType() &&
|
FT->getParamType(0) == FT->getReturnType() &&
|
||||||
FT->getParamType(1) == FT->getReturnType();
|
FT->getParamType(1) == FT->getReturnType();
|
||||||
}
|
}
|
||||||
@ -528,7 +528,7 @@ public:
|
|||||||
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
||||||
const FunctionType *FT = F->getFunctionType();
|
const FunctionType *FT = F->getFunctionType();
|
||||||
return FT->getNumParams() == 2 &&
|
return FT->getNumParams() == 2 &&
|
||||||
FT->getReturnType() == PointerType::get(Type::Int8Ty) &&
|
FT->getReturnType() == PointerType::getUnqual(Type::Int8Ty) &&
|
||||||
FT->getParamType(0) == FT->getReturnType() &&
|
FT->getParamType(0) == FT->getReturnType() &&
|
||||||
isa<IntegerType>(FT->getParamType(1));
|
isa<IntegerType>(FT->getParamType(1));
|
||||||
}
|
}
|
||||||
@ -594,7 +594,7 @@ public:
|
|||||||
const FunctionType *FT = F->getFunctionType();
|
const FunctionType *FT = F->getFunctionType();
|
||||||
return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 2 &&
|
return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 2 &&
|
||||||
FT->getParamType(0) == FT->getParamType(1) &&
|
FT->getParamType(0) == FT->getParamType(1) &&
|
||||||
FT->getParamType(0) == PointerType::get(Type::Int8Ty);
|
FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Perform the strcmp optimization
|
/// @brief Perform the strcmp optimization
|
||||||
@ -647,7 +647,7 @@ public:
|
|||||||
const FunctionType *FT = F->getFunctionType();
|
const FunctionType *FT = F->getFunctionType();
|
||||||
return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 3 &&
|
return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 3 &&
|
||||||
FT->getParamType(0) == FT->getParamType(1) &&
|
FT->getParamType(0) == FT->getParamType(1) &&
|
||||||
FT->getParamType(0) == PointerType::get(Type::Int8Ty) &&
|
FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) &&
|
||||||
isa<IntegerType>(FT->getParamType(2));
|
isa<IntegerType>(FT->getParamType(2));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -715,7 +715,7 @@ public:
|
|||||||
return FT->getNumParams() == 2 &&
|
return FT->getNumParams() == 2 &&
|
||||||
FT->getParamType(0) == FT->getParamType(1) &&
|
FT->getParamType(0) == FT->getParamType(1) &&
|
||||||
FT->getReturnType() == FT->getParamType(0) &&
|
FT->getReturnType() == FT->getParamType(0) &&
|
||||||
FT->getParamType(0) == PointerType::get(Type::Int8Ty);
|
FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Perform the strcpy optimization
|
/// @brief Perform the strcpy optimization
|
||||||
@ -770,7 +770,7 @@ struct VISIBILITY_HIDDEN StrLenOptimization : public LibCallOptimization {
|
|||||||
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
||||||
const FunctionType *FT = F->getFunctionType();
|
const FunctionType *FT = F->getFunctionType();
|
||||||
return FT->getNumParams() == 1 &&
|
return FT->getNumParams() == 1 &&
|
||||||
FT->getParamType(0) == PointerType::get(Type::Int8Ty) &&
|
FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) &&
|
||||||
isa<IntegerType>(FT->getReturnType());
|
isa<IntegerType>(FT->getReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,7 +870,7 @@ struct VISIBILITY_HIDDEN memcmpOptimization : public LibCallOptimization {
|
|||||||
return ReplaceCallWith(CI, Constant::getNullValue(CI->getType()));
|
return ReplaceCallWith(CI, Constant::getNullValue(CI->getType()));
|
||||||
case 1: {
|
case 1: {
|
||||||
// memcmp(S1,S2,1) -> *(ubyte*)S1 - *(ubyte*)S2
|
// memcmp(S1,S2,1) -> *(ubyte*)S1 - *(ubyte*)S2
|
||||||
const Type *UCharPtr = PointerType::get(Type::Int8Ty);
|
const Type *UCharPtr = PointerType::getUnqual(Type::Int8Ty);
|
||||||
CastInst *Op1Cast = CastInst::create(
|
CastInst *Op1Cast = CastInst::create(
|
||||||
Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI);
|
Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI);
|
||||||
CastInst *Op2Cast = CastInst::create(
|
CastInst *Op2Cast = CastInst::create(
|
||||||
@ -888,7 +888,7 @@ struct VISIBILITY_HIDDEN memcmpOptimization : public LibCallOptimization {
|
|||||||
// TODO: IF both are aligned, use a short load/compare.
|
// TODO: IF both are aligned, use a short load/compare.
|
||||||
|
|
||||||
// memcmp(S1,S2,2) -> S1[0]-S2[0] | S1[1]-S2[1] iff only ==/!= 0 matters
|
// memcmp(S1,S2,2) -> S1[0]-S2[0] | S1[1]-S2[1] iff only ==/!= 0 matters
|
||||||
const Type *UCharPtr = PointerType::get(Type::Int8Ty);
|
const Type *UCharPtr = PointerType::getUnqual(Type::Int8Ty);
|
||||||
CastInst *Op1Cast = CastInst::create(
|
CastInst *Op1Cast = CastInst::create(
|
||||||
Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI);
|
Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI);
|
||||||
CastInst *Op2Cast = CastInst::create(
|
CastInst *Op2Cast = CastInst::create(
|
||||||
@ -976,9 +976,9 @@ struct VISIBILITY_HIDDEN LLVMMemCpyMoveOptzn : public LibCallOptimization {
|
|||||||
|
|
||||||
// Cast source and dest to the right sized primitive and then load/store
|
// Cast source and dest to the right sized primitive and then load/store
|
||||||
CastInst* SrcCast = CastInst::create(Instruction::BitCast,
|
CastInst* SrcCast = CastInst::create(Instruction::BitCast,
|
||||||
src, PointerType::get(castType), src->getName()+".cast", ci);
|
src, PointerType::getUnqual(castType), src->getName()+".cast", ci);
|
||||||
CastInst* DestCast = CastInst::create(Instruction::BitCast,
|
CastInst* DestCast = CastInst::create(Instruction::BitCast,
|
||||||
dest, PointerType::get(castType),dest->getName()+".cast", ci);
|
dest, PointerType::getUnqual(castType),dest->getName()+".cast", ci);
|
||||||
LoadInst* LI = new LoadInst(SrcCast,SrcCast->getName()+".val",ci);
|
LoadInst* LI = new LoadInst(SrcCast,SrcCast->getName()+".val",ci);
|
||||||
new StoreInst(LI, DestCast, ci);
|
new StoreInst(LI, DestCast, ci);
|
||||||
return ReplaceCallWith(ci, 0);
|
return ReplaceCallWith(ci, 0);
|
||||||
@ -1085,7 +1085,7 @@ struct VISIBILITY_HIDDEN LLVMMemSetOptimization : public LibCallOptimization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cast dest to the right sized primitive and then load/store
|
// Cast dest to the right sized primitive and then load/store
|
||||||
CastInst* DestCast = new BitCastInst(dest, PointerType::get(castType),
|
CastInst* DestCast = new BitCastInst(dest, PointerType::getUnqual(castType),
|
||||||
dest->getName()+".cast", ci);
|
dest->getName()+".cast", ci);
|
||||||
new StoreInst(ConstantInt::get(castType,fill_value),DestCast, ci);
|
new StoreInst(ConstantInt::get(castType,fill_value),DestCast, ci);
|
||||||
return ReplaceCallWith(ci, 0);
|
return ReplaceCallWith(ci, 0);
|
||||||
@ -1207,7 +1207,7 @@ public:
|
|||||||
Init, "str",
|
Init, "str",
|
||||||
CI->getParent()->getParent()->getParent());
|
CI->getParent()->getParent()->getParent());
|
||||||
// Cast GV to be a pointer to char.
|
// Cast GV to be a pointer to char.
|
||||||
GV = ConstantExpr::getBitCast(GV, PointerType::get(Type::Int8Ty));
|
GV = ConstantExpr::getBitCast(GV, PointerType::getUnqual(Type::Int8Ty));
|
||||||
new CallInst(SLC.get_puts(), GV, "", CI);
|
new CallInst(SLC.get_puts(), GV, "", CI);
|
||||||
|
|
||||||
if (CI->use_empty()) return ReplaceCallWith(CI, 0);
|
if (CI->use_empty()) return ReplaceCallWith(CI, 0);
|
||||||
@ -1268,7 +1268,7 @@ public:
|
|||||||
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
||||||
const FunctionType *FT = F->getFunctionType();
|
const FunctionType *FT = F->getFunctionType();
|
||||||
return FT->getNumParams() == 2 && // two fixed arguments.
|
return FT->getNumParams() == 2 && // two fixed arguments.
|
||||||
FT->getParamType(1) == PointerType::get(Type::Int8Ty) &&
|
FT->getParamType(1) == PointerType::getUnqual(Type::Int8Ty) &&
|
||||||
isa<PointerType>(FT->getParamType(0)) &&
|
isa<PointerType>(FT->getParamType(0)) &&
|
||||||
isa<IntegerType>(FT->getReturnType());
|
isa<IntegerType>(FT->getReturnType());
|
||||||
}
|
}
|
||||||
@ -1358,7 +1358,7 @@ public:
|
|||||||
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
||||||
const FunctionType *FT = F->getFunctionType();
|
const FunctionType *FT = F->getFunctionType();
|
||||||
return FT->getNumParams() == 2 && // two fixed arguments.
|
return FT->getNumParams() == 2 && // two fixed arguments.
|
||||||
FT->getParamType(1) == PointerType::get(Type::Int8Ty) &&
|
FT->getParamType(1) == PointerType::getUnqual(Type::Int8Ty) &&
|
||||||
FT->getParamType(0) == FT->getParamType(1) &&
|
FT->getParamType(0) == FT->getParamType(1) &&
|
||||||
isa<IntegerType>(FT->getReturnType());
|
isa<IntegerType>(FT->getReturnType());
|
||||||
}
|
}
|
||||||
@ -1491,7 +1491,7 @@ public:
|
|||||||
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
|
||||||
const FunctionType *FT = F->getFunctionType();
|
const FunctionType *FT = F->getFunctionType();
|
||||||
return FT->getNumParams() == 4 &&
|
return FT->getNumParams() == 4 &&
|
||||||
FT->getParamType(0) == PointerType::get(Type::Int8Ty) &&
|
FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) &&
|
||||||
FT->getParamType(1) == FT->getParamType(2) &&
|
FT->getParamType(1) == FT->getParamType(2) &&
|
||||||
isa<IntegerType>(FT->getParamType(1)) &&
|
isa<IntegerType>(FT->getParamType(1)) &&
|
||||||
isa<PointerType>(FT->getParamType(3)) &&
|
isa<PointerType>(FT->getParamType(3)) &&
|
||||||
@ -1927,7 +1927,7 @@ static bool GetConstantStringInfo(Value *V, std::string &Str) {
|
|||||||
static Value *CastToCStr(Value *V, Instruction *IP) {
|
static Value *CastToCStr(Value *V, Instruction *IP) {
|
||||||
assert(isa<PointerType>(V->getType()) &&
|
assert(isa<PointerType>(V->getType()) &&
|
||||||
"Can't cast non-pointer type to C string type");
|
"Can't cast non-pointer type to C string type");
|
||||||
const Type *SBPTy = PointerType::get(Type::Int8Ty);
|
const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
|
||||||
if (V->getType() != SBPTy)
|
if (V->getType() != SBPTy)
|
||||||
return new BitCastInst(V, SBPTy, V->getName(), IP);
|
return new BitCastInst(V, SBPTy, V->getName(), IP);
|
||||||
return V;
|
return V;
|
||||||
|
@ -22,8 +22,9 @@
|
|||||||
|
|
||||||
void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
|
void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
|
||||||
GlobalValue *Array) {
|
GlobalValue *Array) {
|
||||||
const Type *ArgVTy = PointerType::get(PointerType::get(Type::Int8Ty));
|
const Type *ArgVTy =
|
||||||
const PointerType *UIntPtr = PointerType::get(Type::Int32Ty);
|
PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty));
|
||||||
|
const PointerType *UIntPtr = PointerType::getUnqual(Type::Int32Ty);
|
||||||
Module &M = *MainFn->getParent();
|
Module &M = *MainFn->getParent();
|
||||||
Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
|
Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
|
||||||
ArgVTy, UIntPtr, Type::Int32Ty,
|
ArgVTy, UIntPtr, Type::Int32Ty,
|
||||||
|
@ -2122,8 +2122,10 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||||||
(CI->getType()->getPrimitiveSizeInBits() ==
|
(CI->getType()->getPrimitiveSizeInBits() ==
|
||||||
TD->getIntPtrType()->getPrimitiveSizeInBits())
|
TD->getIntPtrType()->getPrimitiveSizeInBits())
|
||||||
&& isa<PointerType>(CI->getOperand(0)->getType())) {
|
&& isa<PointerType>(CI->getOperand(0)->getType())) {
|
||||||
|
unsigned AS =
|
||||||
|
cast<PointerType>(CI->getOperand(0)->getType())->getAddressSpace();
|
||||||
Value *I2 = InsertCastBefore(Instruction::BitCast, CI->getOperand(0),
|
Value *I2 = InsertCastBefore(Instruction::BitCast, CI->getOperand(0),
|
||||||
PointerType::get(Type::Int8Ty), I);
|
PointerType::get(Type::Int8Ty, AS), I);
|
||||||
I2 = InsertNewInstBefore(new GetElementPtrInst(I2, Other, "ctg2"), I);
|
I2 = InsertNewInstBefore(new GetElementPtrInst(I2, Other, "ctg2"), I);
|
||||||
return new PtrToIntInst(I2, CI->getType());
|
return new PtrToIntInst(I2, CI->getType());
|
||||||
}
|
}
|
||||||
@ -7740,7 +7742,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
|||||||
// If Size is 2 then use Int16Ty
|
// If Size is 2 then use Int16Ty
|
||||||
// If Size is 1 then use Int8Ty
|
// If Size is 1 then use Int8Ty
|
||||||
if (Size && Size <=8 && !(Size&(Size-1)))
|
if (Size && Size <=8 && !(Size&(Size-1)))
|
||||||
NewPtrTy = PointerType::get(IntegerType::get(Size<<3));
|
NewPtrTy = PointerType::getUnqual(IntegerType::get(Size<<3));
|
||||||
|
|
||||||
if (NewPtrTy) {
|
if (NewPtrTy) {
|
||||||
Value *Src = InsertCastBefore(Instruction::BitCast, CI.getOperand(2),
|
Value *Src = InsertCastBefore(Instruction::BitCast, CI.getOperand(2),
|
||||||
@ -7774,8 +7776,9 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
|||||||
// Turn PPC lvx -> load if the pointer is known aligned.
|
// Turn PPC lvx -> load if the pointer is known aligned.
|
||||||
// Turn X86 loadups -> load if the pointer is known aligned.
|
// Turn X86 loadups -> load if the pointer is known aligned.
|
||||||
if (GetOrEnforceKnownAlignment(II->getOperand(1), TD, 16) >= 16) {
|
if (GetOrEnforceKnownAlignment(II->getOperand(1), TD, 16) >= 16) {
|
||||||
Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(1),
|
Value *Ptr =
|
||||||
PointerType::get(II->getType()), CI);
|
InsertCastBefore(Instruction::BitCast, II->getOperand(1),
|
||||||
|
PointerType::getUnqual(II->getType()), CI);
|
||||||
return new LoadInst(Ptr);
|
return new LoadInst(Ptr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -7783,7 +7786,8 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
|||||||
case Intrinsic::ppc_altivec_stvxl:
|
case Intrinsic::ppc_altivec_stvxl:
|
||||||
// Turn stvx -> store if the pointer is known aligned.
|
// Turn stvx -> store if the pointer is known aligned.
|
||||||
if (GetOrEnforceKnownAlignment(II->getOperand(2), TD, 16) >= 16) {
|
if (GetOrEnforceKnownAlignment(II->getOperand(2), TD, 16) >= 16) {
|
||||||
const Type *OpPtrTy = PointerType::get(II->getOperand(1)->getType());
|
const Type *OpPtrTy =
|
||||||
|
PointerType::getUnqual(II->getOperand(1)->getType());
|
||||||
Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(2),
|
Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(2),
|
||||||
OpPtrTy, CI);
|
OpPtrTy, CI);
|
||||||
return new StoreInst(II->getOperand(1), Ptr);
|
return new StoreInst(II->getOperand(1), Ptr);
|
||||||
@ -7795,7 +7799,8 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
|||||||
case Intrinsic::x86_sse2_storel_dq:
|
case Intrinsic::x86_sse2_storel_dq:
|
||||||
// Turn X86 storeu -> store if the pointer is known aligned.
|
// Turn X86 storeu -> store if the pointer is known aligned.
|
||||||
if (GetOrEnforceKnownAlignment(II->getOperand(1), TD, 16) >= 16) {
|
if (GetOrEnforceKnownAlignment(II->getOperand(1), TD, 16) >= 16) {
|
||||||
const Type *OpPtrTy = PointerType::get(II->getOperand(2)->getType());
|
const Type *OpPtrTy =
|
||||||
|
PointerType::getUnqual(II->getOperand(2)->getType());
|
||||||
Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(1),
|
Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(1),
|
||||||
OpPtrTy, CI);
|
OpPtrTy, CI);
|
||||||
return new StoreInst(II->getOperand(2), Ptr);
|
return new StoreInst(II->getOperand(2), Ptr);
|
||||||
@ -7921,7 +7926,8 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
|
|||||||
// If the call and callee calling conventions don't match, this call must
|
// If the call and callee calling conventions don't match, this call must
|
||||||
// be unreachable, as the call is undefined.
|
// be unreachable, as the call is undefined.
|
||||||
new StoreInst(ConstantInt::getTrue(),
|
new StoreInst(ConstantInt::getTrue(),
|
||||||
UndefValue::get(PointerType::get(Type::Int1Ty)), OldCall);
|
UndefValue::get(PointerType::getUnqual(Type::Int1Ty)),
|
||||||
|
OldCall);
|
||||||
if (!OldCall->use_empty())
|
if (!OldCall->use_empty())
|
||||||
OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType()));
|
OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType()));
|
||||||
if (isa<CallInst>(OldCall)) // Not worth removing an invoke here.
|
if (isa<CallInst>(OldCall)) // Not worth removing an invoke here.
|
||||||
@ -7934,7 +7940,7 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
|
|||||||
// undef so that we know that this code is not reachable, despite the fact
|
// undef so that we know that this code is not reachable, despite the fact
|
||||||
// that we can't modify the CFG here.
|
// that we can't modify the CFG here.
|
||||||
new StoreInst(ConstantInt::getTrue(),
|
new StoreInst(ConstantInt::getTrue(),
|
||||||
UndefValue::get(PointerType::get(Type::Int1Ty)),
|
UndefValue::get(PointerType::getUnqual(Type::Int1Ty)),
|
||||||
CS.getInstruction());
|
CS.getInstruction());
|
||||||
|
|
||||||
if (!CS.getInstruction()->use_empty())
|
if (!CS.getInstruction()->use_empty())
|
||||||
@ -8299,8 +8305,8 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
|
|||||||
// code sort out any function type mismatches.
|
// code sort out any function type mismatches.
|
||||||
FunctionType *NewFTy =
|
FunctionType *NewFTy =
|
||||||
FunctionType::get(FTy->getReturnType(), NewTypes, FTy->isVarArg());
|
FunctionType::get(FTy->getReturnType(), NewTypes, FTy->isVarArg());
|
||||||
Constant *NewCallee = NestF->getType() == PointerType::get(NewFTy) ?
|
Constant *NewCallee = NestF->getType() == PointerType::getUnqual(NewFTy) ?
|
||||||
NestF : ConstantExpr::getBitCast(NestF, PointerType::get(NewFTy));
|
NestF : ConstantExpr::getBitCast(NestF, PointerType::getUnqual(NewFTy));
|
||||||
const ParamAttrsList *NewPAL = ParamAttrsList::get(NewAttrs);
|
const ParamAttrsList *NewPAL = ParamAttrsList::get(NewAttrs);
|
||||||
|
|
||||||
Instruction *NewCaller;
|
Instruction *NewCaller;
|
||||||
@ -9052,7 +9058,7 @@ Instruction *InstCombiner::visitFreeInst(FreeInst &FI) {
|
|||||||
if (isa<UndefValue>(Op)) {
|
if (isa<UndefValue>(Op)) {
|
||||||
// Insert a new store to null because we cannot modify the CFG here.
|
// Insert a new store to null because we cannot modify the CFG here.
|
||||||
new StoreInst(ConstantInt::getTrue(),
|
new StoreInst(ConstantInt::getTrue(),
|
||||||
UndefValue::get(PointerType::get(Type::Int1Ty)), &FI);
|
UndefValue::get(PointerType::getUnqual(Type::Int1Ty)), &FI);
|
||||||
return EraseInstFromFunction(FI);
|
return EraseInstFromFunction(FI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9887,8 +9893,10 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
|
|||||||
return BinaryOperator::create(BO->getOpcode(), newEI0, newEI1);
|
return BinaryOperator::create(BO->getOpcode(), newEI0, newEI1);
|
||||||
}
|
}
|
||||||
} else if (isa<LoadInst>(I)) {
|
} else if (isa<LoadInst>(I)) {
|
||||||
|
unsigned AS =
|
||||||
|
cast<PointerType>(I->getOperand(0)->getType())->getAddressSpace();
|
||||||
Value *Ptr = InsertCastBefore(Instruction::BitCast, I->getOperand(0),
|
Value *Ptr = InsertCastBefore(Instruction::BitCast, I->getOperand(0),
|
||||||
PointerType::get(EI.getType()), EI);
|
PointerType::get(EI.getType(), AS), EI);
|
||||||
GetElementPtrInst *GEP =
|
GetElementPtrInst *GEP =
|
||||||
new GetElementPtrInst(Ptr, EI.getOperand(1), I->getName() + ".gep");
|
new GetElementPtrInst(Ptr, EI.getOperand(1), I->getName() + ".gep");
|
||||||
InsertNewInstBefore(GEP, EI);
|
InsertNewInstBefore(GEP, EI);
|
||||||
|
@ -86,7 +86,7 @@ const StructType *LowerGC::getRootRecordType(unsigned NumRoots) {
|
|||||||
PATypeHolder RootListH =
|
PATypeHolder RootListH =
|
||||||
MainRootRecordType ? (Type*)MainRootRecordType : (Type*)OpaqueType::get();
|
MainRootRecordType ? (Type*)MainRootRecordType : (Type*)OpaqueType::get();
|
||||||
ST.clear();
|
ST.clear();
|
||||||
ST.push_back(PointerType::get(RootListH)); // Prev pointer
|
ST.push_back(PointerType::getUnqual(RootListH)); // Prev pointer
|
||||||
ST.push_back(Type::Int32Ty); // NumElements in array
|
ST.push_back(Type::Int32Ty); // NumElements in array
|
||||||
ST.push_back(PairArrTy); // The pairs
|
ST.push_back(PairArrTy); // The pairs
|
||||||
StructType *RootList = StructType::get(ST);
|
StructType *RootList = StructType::get(ST);
|
||||||
@ -107,8 +107,8 @@ bool LowerGC::doInitialization(Module &M) {
|
|||||||
GCWriteInt = M.getFunction("llvm.gcwrite");
|
GCWriteInt = M.getFunction("llvm.gcwrite");
|
||||||
if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
|
if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
|
||||||
|
|
||||||
PointerType *VoidPtr = PointerType::get(Type::Int8Ty);
|
PointerType *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
|
||||||
PointerType *VoidPtrPtr = PointerType::get(VoidPtr);
|
PointerType *VoidPtrPtr = PointerType::getUnqual(VoidPtr);
|
||||||
|
|
||||||
// If the program is using read/write barriers, find the implementations of
|
// If the program is using read/write barriers, find the implementations of
|
||||||
// them from the GC runtime library.
|
// them from the GC runtime library.
|
||||||
@ -122,7 +122,7 @@ bool LowerGC::doInitialization(Module &M) {
|
|||||||
// If the program has GC roots, get or create the global root list.
|
// If the program has GC roots, get or create the global root list.
|
||||||
if (GCRootInt) {
|
if (GCRootInt) {
|
||||||
const StructType *RootListTy = getRootRecordType(0);
|
const StructType *RootListTy = getRootRecordType(0);
|
||||||
const Type *PRLTy = PointerType::get(RootListTy);
|
const Type *PRLTy = PointerType::getUnqual(RootListTy);
|
||||||
M.addTypeName("llvm_gc_root_ty", RootListTy);
|
M.addTypeName("llvm_gc_root_ty", RootListTy);
|
||||||
|
|
||||||
// Get the root chain if it already exists.
|
// Get the root chain if it already exists.
|
||||||
@ -163,8 +163,8 @@ bool LowerGC::runOnFunction(Function &F) {
|
|||||||
// Quick exit for programs that are not using GC mechanisms.
|
// Quick exit for programs that are not using GC mechanisms.
|
||||||
if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
|
if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
|
||||||
|
|
||||||
PointerType *VoidPtr = PointerType::get(Type::Int8Ty);
|
PointerType *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
|
||||||
PointerType *VoidPtrPtr = PointerType::get(VoidPtr);
|
PointerType *VoidPtrPtr = PointerType::getUnqual(VoidPtr);
|
||||||
|
|
||||||
// If there are read/write barriers in the program, perform a quick pass over
|
// If there are read/write barriers in the program, perform a quick pass over
|
||||||
// the function eliminating them. While we are at it, remember where we see
|
// the function eliminating them. While we are at it, remember where we see
|
||||||
@ -290,7 +290,7 @@ bool LowerGC::runOnFunction(Function &F) {
|
|||||||
|
|
||||||
// Now that the record is all initialized, store the pointer into the global
|
// Now that the record is all initialized, store the pointer into the global
|
||||||
// pointer.
|
// pointer.
|
||||||
Value *C = new BitCastInst(AI, PointerType::get(MainRootRecordType), "", IP);
|
Value *C = new BitCastInst(AI, PointerType::getUnqual(MainRootRecordType), "", IP);
|
||||||
new StoreInst(C, RootChain, IP);
|
new StoreInst(C, RootChain, IP);
|
||||||
|
|
||||||
// Eliminate all the gcroot records now.
|
// Eliminate all the gcroot records now.
|
||||||
|
@ -263,7 +263,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
|
|||||||
if (AggregateArgs)
|
if (AggregateArgs)
|
||||||
paramTy.push_back((*I)->getType());
|
paramTy.push_back((*I)->getType());
|
||||||
else
|
else
|
||||||
paramTy.push_back(PointerType::get((*I)->getType()));
|
paramTy.push_back(PointerType::getUnqual((*I)->getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DOUT << "Function type: " << *RetTy << " f(";
|
DOUT << "Function type: " << *RetTy << " f(";
|
||||||
@ -273,7 +273,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
|
|||||||
DOUT << ")\n";
|
DOUT << ")\n";
|
||||||
|
|
||||||
if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
|
if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
|
||||||
PointerType *StructPtr = PointerType::get(StructType::get(paramTy));
|
PointerType *StructPtr = PointerType::getUnqual(StructType::get(paramTy));
|
||||||
paramTy.clear();
|
paramTy.clear();
|
||||||
paramTy.push_back(StructPtr);
|
paramTy.push_back(StructPtr);
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
|
|||||||
// code with llvm.stacksave/llvm.stackrestore intrinsics.
|
// code with llvm.stacksave/llvm.stackrestore intrinsics.
|
||||||
if (InlinedFunctionInfo.ContainsDynamicAllocas) {
|
if (InlinedFunctionInfo.ContainsDynamicAllocas) {
|
||||||
Module *M = Caller->getParent();
|
Module *M = Caller->getParent();
|
||||||
const Type *BytePtr = PointerType::get(Type::Int8Ty);
|
const Type *BytePtr = PointerType::getUnqual(Type::Int8Ty);
|
||||||
// Get the two intrinsics we care about.
|
// Get the two intrinsics we care about.
|
||||||
Constant *StackSave, *StackRestore;
|
Constant *StackSave, *StackRestore;
|
||||||
StackSave = M->getOrInsertFunction("llvm.stacksave", BytePtr, NULL);
|
StackSave = M->getOrInsertFunction("llvm.stacksave", BytePtr, NULL);
|
||||||
|
@ -87,7 +87,7 @@ Pass *llvm::createLowerAllocationsPass(bool LowerMallocArgToInteger) {
|
|||||||
// This function is always successful.
|
// This function is always successful.
|
||||||
//
|
//
|
||||||
bool LowerAllocations::doInitialization(Module &M) {
|
bool LowerAllocations::doInitialization(Module &M) {
|
||||||
const Type *BPTy = PointerType::get(Type::Int8Ty);
|
const Type *BPTy = PointerType::getUnqual(Type::Int8Ty);
|
||||||
// Prototype malloc as "char* malloc(...)", because we don't know in
|
// Prototype malloc as "char* malloc(...)", because we don't know in
|
||||||
// doInitialization whether size_t is int or long.
|
// doInitialization whether size_t is int or long.
|
||||||
FunctionType *FT = FunctionType::get(BPTy, std::vector<const Type*>(), true);
|
FunctionType *FT = FunctionType::get(BPTy, std::vector<const Type*>(), true);
|
||||||
@ -158,8 +158,9 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
|||||||
Changed = true;
|
Changed = true;
|
||||||
++NumLowered;
|
++NumLowered;
|
||||||
} else if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
|
} else if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
|
||||||
Value *PtrCast = new BitCastInst(FI->getOperand(0),
|
Value *PtrCast =
|
||||||
PointerType::get(Type::Int8Ty), "", I);
|
new BitCastInst(FI->getOperand(0),
|
||||||
|
PointerType::getUnqual(Type::Int8Ty), "", I);
|
||||||
|
|
||||||
// Insert a call to the free function...
|
// Insert a call to the free function...
|
||||||
(new CallInst(FreeFunc, PtrCast, "", I))->setTailCall();
|
(new CallInst(FreeFunc, PtrCast, "", I))->setTailCall();
|
||||||
|
@ -114,7 +114,7 @@ FunctionPass *llvm::createLowerInvokePass(const TargetLowering *TLI) {
|
|||||||
// doInitialization - Make sure that there is a prototype for abort in the
|
// doInitialization - Make sure that there is a prototype for abort in the
|
||||||
// current module.
|
// current module.
|
||||||
bool LowerInvoke::doInitialization(Module &M) {
|
bool LowerInvoke::doInitialization(Module &M) {
|
||||||
const Type *VoidPtrTy = PointerType::get(Type::Int8Ty);
|
const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
|
||||||
AbortMessage = 0;
|
AbortMessage = 0;
|
||||||
if (ExpensiveEHSupport) {
|
if (ExpensiveEHSupport) {
|
||||||
// Insert a type for the linked list of jump buffers.
|
// Insert a type for the linked list of jump buffers.
|
||||||
@ -126,14 +126,14 @@ bool LowerInvoke::doInitialization(Module &M) {
|
|||||||
std::vector<const Type*> Elements;
|
std::vector<const Type*> Elements;
|
||||||
Elements.push_back(JmpBufTy);
|
Elements.push_back(JmpBufTy);
|
||||||
OpaqueType *OT = OpaqueType::get();
|
OpaqueType *OT = OpaqueType::get();
|
||||||
Elements.push_back(PointerType::get(OT));
|
Elements.push_back(PointerType::getUnqual(OT));
|
||||||
PATypeHolder JBLType(StructType::get(Elements));
|
PATypeHolder JBLType(StructType::get(Elements));
|
||||||
OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle.
|
OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle.
|
||||||
JBLinkTy = JBLType.get();
|
JBLinkTy = JBLType.get();
|
||||||
M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy);
|
M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type *PtrJBList = PointerType::get(JBLinkTy);
|
const Type *PtrJBList = PointerType::getUnqual(JBLinkTy);
|
||||||
|
|
||||||
// Now that we've done that, insert the jmpbuf list head global, unless it
|
// Now that we've done that, insert the jmpbuf list head global, unless it
|
||||||
// already exists.
|
// already exists.
|
||||||
@ -144,9 +144,10 @@ bool LowerInvoke::doInitialization(Module &M) {
|
|||||||
"llvm.sjljeh.jblist", &M);
|
"llvm.sjljeh.jblist", &M);
|
||||||
}
|
}
|
||||||
SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty,
|
SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty,
|
||||||
PointerType::get(JmpBufTy), (Type *)0);
|
PointerType::getUnqual(JmpBufTy),
|
||||||
|
(Type *)0);
|
||||||
LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy,
|
LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy,
|
||||||
PointerType::get(JmpBufTy),
|
PointerType::getUnqual(JmpBufTy),
|
||||||
Type::Int32Ty, (Type *)0);
|
Type::Int32Ty, (Type *)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1383,12 +1383,13 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C,
|
|||||||
return const_cast<Constant*>(C);
|
return const_cast<Constant*>(C);
|
||||||
|
|
||||||
if (isa<UndefValue>(C)) {
|
if (isa<UndefValue>(C)) {
|
||||||
const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(),
|
const PointerType *Ptr = cast<PointerType>(C->getType());
|
||||||
|
const Type *Ty = GetElementPtrInst::getIndexedType(Ptr,
|
||||||
(Value **)Idxs,
|
(Value **)Idxs,
|
||||||
(Value **)Idxs+NumIdx,
|
(Value **)Idxs+NumIdx,
|
||||||
true);
|
true);
|
||||||
assert(Ty != 0 && "Invalid indices for GEP!");
|
assert(Ty != 0 && "Invalid indices for GEP!");
|
||||||
return UndefValue::get(PointerType::get(Ty));
|
return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant *Idx0 = Idxs[0];
|
Constant *Idx0 = Idxs[0];
|
||||||
@ -1400,12 +1401,14 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isNull) {
|
if (isNull) {
|
||||||
const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(),
|
const PointerType *Ptr = cast<PointerType>(C->getType());
|
||||||
|
const Type *Ty = GetElementPtrInst::getIndexedType(Ptr,
|
||||||
(Value**)Idxs,
|
(Value**)Idxs,
|
||||||
(Value**)Idxs+NumIdx,
|
(Value**)Idxs+NumIdx,
|
||||||
true);
|
true);
|
||||||
assert(Ty != 0 && "Invalid indices for GEP!");
|
assert(Ty != 0 && "Invalid indices for GEP!");
|
||||||
return ConstantPointerNull::get(PointerType::get(Ty));
|
return
|
||||||
|
ConstantPointerNull::get(PointerType::get(Ty,Ptr->getAddressSpace()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1710,7 +1710,7 @@ Constant *ConstantExpr::getSizeOf(const Type *Ty) {
|
|||||||
// sizeof is implemented as: (i64) gep (Ty*)null, 1
|
// sizeof is implemented as: (i64) gep (Ty*)null, 1
|
||||||
Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
|
Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
|
||||||
Constant *GEP =
|
Constant *GEP =
|
||||||
getGetElementPtr(getNullValue(PointerType::get(Ty)), &GEPIdx, 1);
|
getGetElementPtr(getNullValue(PointerType::getUnqual(Ty)), &GEPIdx, 1);
|
||||||
return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty);
|
return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,8 @@ LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount){
|
|||||||
}
|
}
|
||||||
|
|
||||||
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType) {
|
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType) {
|
||||||
return wrap(PointerType::get(unwrap(ElementType)));
|
// FIXME: Needst to handle address spaces
|
||||||
|
return wrap(PointerType::getUnqual(unwrap(ElementType)));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType,unsigned ElementCount){
|
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType,unsigned ElementCount){
|
||||||
|
@ -271,7 +271,8 @@ ParamAttrsList::~ParamAttrsList() {
|
|||||||
|
|
||||||
Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
|
Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
|
||||||
const std::string &name, Module *ParentModule)
|
const std::string &name, Module *ParentModule)
|
||||||
: GlobalValue(PointerType::get(Ty), Value::FunctionVal, 0, 0, Linkage, name),
|
: GlobalValue(PointerType::getUnqual(Ty),
|
||||||
|
Value::FunctionVal, 0, 0, Linkage, name),
|
||||||
ParamAttrs(0) {
|
ParamAttrs(0) {
|
||||||
SymTab = new ValueSymbolTable();
|
SymTab = new ValueSymbolTable();
|
||||||
|
|
||||||
|
@ -34,7 +34,9 @@ InlineAsm *InlineAsm::get(const FunctionType *Ty, const std::string &AsmString,
|
|||||||
|
|
||||||
InlineAsm::InlineAsm(const FunctionType *Ty, const std::string &asmString,
|
InlineAsm::InlineAsm(const FunctionType *Ty, const std::string &asmString,
|
||||||
const std::string &constraints, bool hasSideEffects)
|
const std::string &constraints, bool hasSideEffects)
|
||||||
: Value(PointerType::get(Ty), Value::InlineAsmVal), AsmString(asmString),
|
: Value(PointerType::getUnqual(Ty),
|
||||||
|
Value::InlineAsmVal),
|
||||||
|
AsmString(asmString),
|
||||||
Constraints(constraints), HasSideEffects(hasSideEffects) {
|
Constraints(constraints), HasSideEffects(hasSideEffects) {
|
||||||
|
|
||||||
// Do various checks on the constraint string and type.
|
// Do various checks on the constraint string and type.
|
||||||
|
@ -72,8 +72,6 @@ bool CallSite::isNoUnwind() const {
|
|||||||
return cast<InvokeInst>(I)->isNoUnwind();
|
return cast<InvokeInst>(I)->isNoUnwind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// TerminatorInst Class
|
// TerminatorInst Class
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -672,7 +670,7 @@ static Value *getAISize(Value *Amt) {
|
|||||||
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
||||||
unsigned Align, const std::string &Name,
|
unsigned Align, const std::string &Name,
|
||||||
Instruction *InsertBefore)
|
Instruction *InsertBefore)
|
||||||
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
: UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(ArraySize),
|
||||||
InsertBefore), Alignment(Align) {
|
InsertBefore), Alignment(Align) {
|
||||||
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
||||||
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
||||||
@ -682,7 +680,7 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
|||||||
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
||||||
unsigned Align, const std::string &Name,
|
unsigned Align, const std::string &Name,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
|
: UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(ArraySize),
|
||||||
InsertAtEnd), Alignment(Align) {
|
InsertAtEnd), Alignment(Align) {
|
||||||
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
||||||
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
assert(Ty != Type::VoidTy && "Cannot allocate void!");
|
||||||
@ -925,6 +923,10 @@ void StoreInst::setAlignment(unsigned Align) {
|
|||||||
// GetElementPtrInst Implementation
|
// GetElementPtrInst Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
static unsigned retrieveAddrSpace(const Value *Val) {
|
||||||
|
return cast<PointerType>(Val->getType())->getAddressSpace();
|
||||||
|
}
|
||||||
|
|
||||||
void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx) {
|
void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx) {
|
||||||
NumOperands = 1+NumIdx;
|
NumOperands = 1+NumIdx;
|
||||||
Use *OL = OperandList = new Use[NumOperands];
|
Use *OL = OperandList = new Use[NumOperands];
|
||||||
@ -944,7 +946,7 @@ void GetElementPtrInst::init(Value *Ptr, Value *Idx) {
|
|||||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
||||||
const std::string &Name, Instruction *InBe)
|
const std::string &Name, Instruction *InBe)
|
||||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)),
|
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)),
|
||||||
cast<PointerType>(Ptr->getType())->getAddressSpace()),
|
retrieveAddrSpace(Ptr)),
|
||||||
GetElementPtr, 0, 0, InBe) {
|
GetElementPtr, 0, 0, InBe) {
|
||||||
init(Ptr, Idx);
|
init(Ptr, Idx);
|
||||||
setName(Name);
|
setName(Name);
|
||||||
@ -953,7 +955,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
|||||||
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
|
||||||
const std::string &Name, BasicBlock *IAE)
|
const std::string &Name, BasicBlock *IAE)
|
||||||
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)),
|
: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)),
|
||||||
cast<PointerType>(Ptr->getType())->getAddressSpace()),
|
retrieveAddrSpace(Ptr)),
|
||||||
GetElementPtr, 0, 0, IAE) {
|
GetElementPtr, 0, 0, IAE) {
|
||||||
init(Ptr, Idx);
|
init(Ptr, Idx);
|
||||||
setName(Name);
|
setName(Name);
|
||||||
|
@ -164,8 +164,8 @@ Constant *Module::getOrInsertFunction(const std::string &Name,
|
|||||||
|
|
||||||
// If the function exists but has the wrong type, return a bitcast to the
|
// If the function exists but has the wrong type, return a bitcast to the
|
||||||
// right type.
|
// right type.
|
||||||
if (F->getType() != PointerType::get(Ty))
|
if (F->getType() != PointerType::getUnqual(Ty))
|
||||||
return ConstantExpr::getBitCast(F, PointerType::get(Ty));
|
return ConstantExpr::getBitCast(F, PointerType::getUnqual(Ty));
|
||||||
|
|
||||||
// Otherwise, we just found the existing function or a prototype.
|
// Otherwise, we just found the existing function or a prototype.
|
||||||
return F;
|
return F;
|
||||||
|
@ -1161,12 +1161,12 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
|
|||||||
break;
|
break;
|
||||||
case Intrinsic::gcwrite:
|
case Intrinsic::gcwrite:
|
||||||
Assert1(CI.getOperand(3)->getType()
|
Assert1(CI.getOperand(3)->getType()
|
||||||
== PointerType::get(CI.getOperand(1)->getType()),
|
== PointerType::getUnqual(CI.getOperand(1)->getType()),
|
||||||
"Call to llvm.gcwrite must be with type 'void (%ty*, %ty2*, %ty**)'.",
|
"Call to llvm.gcwrite must be with type 'void (%ty*, %ty2*, %ty**)'.",
|
||||||
&CI);
|
&CI);
|
||||||
break;
|
break;
|
||||||
case Intrinsic::gcread:
|
case Intrinsic::gcread:
|
||||||
Assert1(CI.getOperand(2)->getType() == PointerType::get(CI.getType()),
|
Assert1(CI.getOperand(2)->getType() == PointerType::getUnqual(CI.getType()),
|
||||||
"Call to llvm.gcread must be with type '%ty* (%ty2*, %ty**).'",
|
"Call to llvm.gcread must be with type '%ty* (%ty2*, %ty**).'",
|
||||||
&CI);
|
&CI);
|
||||||
break;
|
break;
|
||||||
|
@ -679,8 +679,8 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
|
|||||||
// Prototype: void *getPointerToNamedFunction(const char* Name)
|
// Prototype: void *getPointerToNamedFunction(const char* Name)
|
||||||
Constant *resolverFunc =
|
Constant *resolverFunc =
|
||||||
Safe->getOrInsertFunction("getPointerToNamedFunction",
|
Safe->getOrInsertFunction("getPointerToNamedFunction",
|
||||||
PointerType::get(Type::Int8Ty),
|
PointerType::getUnqual(Type::Int8Ty),
|
||||||
PointerType::get(Type::Int8Ty), (Type *)0);
|
PointerType::getUnqual(Type::Int8Ty), (Type *)0);
|
||||||
|
|
||||||
// Use the function we just added to get addresses of functions we need.
|
// Use the function we just added to get addresses of functions we need.
|
||||||
for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
|
for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
|
||||||
@ -739,7 +739,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
|
|||||||
"resolver", LookupBB);
|
"resolver", LookupBB);
|
||||||
// cast the result from the resolver to correctly-typed function
|
// cast the result from the resolver to correctly-typed function
|
||||||
CastInst *CastedResolver = new BitCastInst(Resolver,
|
CastInst *CastedResolver = new BitCastInst(Resolver,
|
||||||
PointerType::get(F->getFunctionType()), "resolverCast", LookupBB);
|
PointerType::getUnqual(F->getFunctionType()), "resolverCast", LookupBB);
|
||||||
|
|
||||||
// Save the value in our cache.
|
// Save the value in our cache.
|
||||||
new StoreInst(CastedResolver, Cache, LookupBB);
|
new StoreInst(CastedResolver, Cache, LookupBB);
|
||||||
|
@ -829,7 +829,7 @@ ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
|
|||||||
if (isa<FunctionType>(Ty))
|
if (isa<FunctionType>(Ty))
|
||||||
error("Cannot declare global vars of function type");
|
error("Cannot declare global vars of function type");
|
||||||
|
|
||||||
const PointerType *PTy = PointerType::get(Ty);
|
const PointerType *PTy = PointerType::getUnqual(Ty);
|
||||||
|
|
||||||
std::string Name;
|
std::string Name;
|
||||||
if (NameStr) {
|
if (NameStr) {
|
||||||
@ -883,7 +883,8 @@ ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Put the renaming in the global rename map
|
// Put the renaming in the global rename map
|
||||||
RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S);
|
RenameMapKey Key =
|
||||||
|
makeRenameMapKey(Name, PointerType::getUnqual(Ty), ID.S);
|
||||||
CurModule.RenameMap[Key] = NewName;
|
CurModule.RenameMap[Key] = NewName;
|
||||||
|
|
||||||
// Rename it
|
// Rename it
|
||||||
@ -1404,7 +1405,7 @@ upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v' : {
|
case 'v' : {
|
||||||
const Type* PtrTy = PointerType::get(Type::Int8Ty);
|
const Type* PtrTy = PointerType::getUnqual(Type::Int8Ty);
|
||||||
std::vector<const Type*> Params;
|
std::vector<const Type*> Params;
|
||||||
if (Name == "llvm.va_start" || Name == "llvm.va_end") {
|
if (Name == "llvm.va_start" || Name == "llvm.va_end") {
|
||||||
if (Args.size() != 1)
|
if (Args.size() != 1)
|
||||||
@ -1412,7 +1413,7 @@ upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
|
|||||||
Params.push_back(PtrTy);
|
Params.push_back(PtrTy);
|
||||||
const FunctionType *FTy =
|
const FunctionType *FTy =
|
||||||
FunctionType::get(Type::VoidTy, Params, false);
|
FunctionType::get(Type::VoidTy, Params, false);
|
||||||
const PointerType *PFTy = PointerType::get(FTy);
|
const PointerType *PFTy = PointerType::getUnqual(FTy);
|
||||||
Value* Func = getVal(PFTy, ID);
|
Value* Func = getVal(PFTy, ID);
|
||||||
Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
|
Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
|
||||||
return new CallInst(Func, Args.begin(), Args.end());
|
return new CallInst(Func, Args.begin(), Args.end());
|
||||||
@ -1423,7 +1424,7 @@ upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
|
|||||||
Params.push_back(PtrTy);
|
Params.push_back(PtrTy);
|
||||||
const FunctionType *FTy =
|
const FunctionType *FTy =
|
||||||
FunctionType::get(Type::VoidTy, Params, false);
|
FunctionType::get(Type::VoidTy, Params, false);
|
||||||
const PointerType *PFTy = PointerType::get(FTy);
|
const PointerType *PFTy = PointerType::getUnqual(FTy);
|
||||||
Value* Func = getVal(PFTy, ID);
|
Value* Func = getVal(PFTy, ID);
|
||||||
std::string InstName0(makeNameUnique("va0"));
|
std::string InstName0(makeNameUnique("va0"));
|
||||||
std::string InstName1(makeNameUnique("va1"));
|
std::string InstName1(makeNameUnique("va1"));
|
||||||
@ -1592,7 +1593,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in,
|
|||||||
|
|
||||||
const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
|
const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
|
||||||
const Type* ArgTy = F->getFunctionType()->getReturnType();
|
const Type* ArgTy = F->getFunctionType()->getReturnType();
|
||||||
const Type* ArgTyPtr = PointerType::get(ArgTy);
|
const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
|
||||||
Function* NF = cast<Function>(Result->getOrInsertFunction(
|
Function* NF = cast<Function>(Result->getOrInsertFunction(
|
||||||
"llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
|
"llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
|
||||||
|
|
||||||
@ -1619,7 +1620,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in,
|
|||||||
//vaend bar
|
//vaend bar
|
||||||
const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
|
const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
|
||||||
const Type* ArgTy = F->getFunctionType()->getParamType(0);
|
const Type* ArgTy = F->getFunctionType()->getParamType(0);
|
||||||
const Type* ArgTyPtr = PointerType::get(ArgTy);
|
const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
|
||||||
Function* NF = cast<Function>(Result->getOrInsertFunction(
|
Function* NF = cast<Function>(Result->getOrInsertFunction(
|
||||||
"llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
|
"llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
|
||||||
|
|
||||||
@ -1648,7 +1649,7 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in,
|
|||||||
|
|
||||||
const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
|
const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
|
||||||
const Type* ArgTy = F->getFunctionType()->getReturnType();
|
const Type* ArgTy = F->getFunctionType()->getReturnType();
|
||||||
const Type* ArgTyPtr = PointerType::get(ArgTy);
|
const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
|
||||||
Function* NF = cast<Function>(Result->getOrInsertFunction(
|
Function* NF = cast<Function>(Result->getOrInsertFunction(
|
||||||
"llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
|
"llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
|
||||||
|
|
||||||
@ -2126,7 +2127,8 @@ UpRTypes
|
|||||||
if ($1.PAT->get() == Type::LabelTy)
|
if ($1.PAT->get() == Type::LabelTy)
|
||||||
error("Cannot form a pointer to a basic block");
|
error("Cannot form a pointer to a basic block");
|
||||||
$$.S.makeComposite($1.S);
|
$$.S.makeComposite($1.S);
|
||||||
$$.PAT = new PATypeHolder(HandleUpRefs(PointerType::get($1.PAT->get()),
|
$$.PAT = new
|
||||||
|
PATypeHolder(HandleUpRefs(PointerType::getUnqual($1.PAT->get()),
|
||||||
$$.S));
|
$$.S));
|
||||||
delete $1.PAT;
|
delete $1.PAT;
|
||||||
}
|
}
|
||||||
@ -2834,10 +2836,10 @@ FunctionHeaderH
|
|||||||
// i8*. We check here for those names and override the parameter list
|
// i8*. We check here for those names and override the parameter list
|
||||||
// types to ensure the prototype is correct.
|
// types to ensure the prototype is correct.
|
||||||
if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
|
if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
|
||||||
ParamTyList.push_back(PointerType::get(Type::Int8Ty));
|
ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
|
||||||
} else if (FunctionName == "llvm.va_copy") {
|
} else if (FunctionName == "llvm.va_copy") {
|
||||||
ParamTyList.push_back(PointerType::get(Type::Int8Ty));
|
ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
|
||||||
ParamTyList.push_back(PointerType::get(Type::Int8Ty));
|
ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
|
||||||
} else if ($5) { // If there are arguments...
|
} else if ($5) { // If there are arguments...
|
||||||
for (std::vector<std::pair<PATypeInfo,char*> >::iterator
|
for (std::vector<std::pair<PATypeInfo,char*> >::iterator
|
||||||
I = $5->begin(), E = $5->end(); I != E; ++I) {
|
I = $5->begin(), E = $5->end(); I != E; ++I) {
|
||||||
@ -2852,7 +2854,7 @@ FunctionHeaderH
|
|||||||
ParamTyList.pop_back();
|
ParamTyList.pop_back();
|
||||||
|
|
||||||
const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg);
|
const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg);
|
||||||
const PointerType *PFT = PointerType::get(FT);
|
const PointerType *PFT = PointerType::getUnqual(FT);
|
||||||
delete $2.PAT;
|
delete $2.PAT;
|
||||||
|
|
||||||
ValID ID;
|
ValID ID;
|
||||||
@ -3102,7 +3104,8 @@ ConstValueRef
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
// SymbolicValueRef - Reference to one of two ways of symbolically refering to // another value.
|
// SymbolicValueRef - Reference to one of two ways of symbolically refering to
|
||||||
|
// another value.
|
||||||
//
|
//
|
||||||
SymbolicValueRef
|
SymbolicValueRef
|
||||||
: INTVAL { $$ = ValID::create($1); $$.S.makeSignless(); }
|
: INTVAL { $$ = ValID::create($1); $$.S.makeSignless(); }
|
||||||
@ -3251,7 +3254,7 @@ BBTerminatorInst
|
|||||||
bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
|
bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
|
||||||
if (isVarArg) ParamTypes.pop_back();
|
if (isVarArg) ParamTypes.pop_back();
|
||||||
Ty = FunctionType::get($3.PAT->get(), ParamTypes, isVarArg);
|
Ty = FunctionType::get($3.PAT->get(), ParamTypes, isVarArg);
|
||||||
PFTy = PointerType::get(Ty);
|
PFTy = PointerType::getUnqual(Ty);
|
||||||
$$.S.copy($3.S);
|
$$.S.copy($3.S);
|
||||||
} else {
|
} else {
|
||||||
FTySign = $3.S;
|
FTySign = $3.S;
|
||||||
@ -3656,7 +3659,7 @@ InstVal
|
|||||||
error("Functions cannot return aggregate types");
|
error("Functions cannot return aggregate types");
|
||||||
|
|
||||||
FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
|
FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
|
||||||
PFTy = PointerType::get(FTy);
|
PFTy = PointerType::getUnqual(FTy);
|
||||||
$$.S.copy($3.S);
|
$$.S.copy($3.S);
|
||||||
} else {
|
} else {
|
||||||
FTySign = $3.S;
|
FTySign = $3.S;
|
||||||
@ -3796,7 +3799,7 @@ MemoryInst
|
|||||||
Value *StoreVal = $3.V;
|
Value *StoreVal = $3.V;
|
||||||
Value* tmpVal = getVal(PTy, $6);
|
Value* tmpVal = getVal(PTy, $6);
|
||||||
if (ElTy != $3.V->getType()) {
|
if (ElTy != $3.V->getType()) {
|
||||||
PTy = PointerType::get(StoreVal->getType());
|
PTy = PointerType::getUnqual(StoreVal->getType());
|
||||||
if (Constant *C = dyn_cast<Constant>(tmpVal))
|
if (Constant *C = dyn_cast<Constant>(tmpVal))
|
||||||
tmpVal = ConstantExpr::getBitCast(C, PTy);
|
tmpVal = ConstantExpr::getBitCast(C, PTy);
|
||||||
else
|
else
|
||||||
|
@ -577,7 +577,8 @@ CppWriter::printTypeInternal(const Type* Ty) {
|
|||||||
bool isForward = printTypeInternal(ET);
|
bool isForward = printTypeInternal(ET);
|
||||||
std::string elemName(getCppName(ET));
|
std::string elemName(getCppName(ET));
|
||||||
Out << "PointerType* " << typeName << " = PointerType::get("
|
Out << "PointerType* " << typeName << " = PointerType::get("
|
||||||
<< elemName << (isForward ? "_fwd" : "") << ");";
|
<< elemName << (isForward ? "_fwd" : "")
|
||||||
|
<< ", " << utostr(PT->getAddressSpace()) << ");";
|
||||||
nl(Out);
|
nl(Out);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ static void EmitTypeGenerate(std::ostream &OS, Record *ArgType,
|
|||||||
EmitTypeForValueType(OS, MVT::getVectorElementType(VT));
|
EmitTypeForValueType(OS, MVT::getVectorElementType(VT));
|
||||||
OS << ", " << MVT::getVectorNumElements(VT) << ")";
|
OS << ", " << MVT::getVectorNumElements(VT) << ")";
|
||||||
} else if (VT == MVT::iPTR) {
|
} else if (VT == MVT::iPTR) {
|
||||||
OS << "PointerType::get(";
|
OS << "PointerType::getUnqual(";
|
||||||
EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo);
|
EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo);
|
||||||
OS << ")";
|
OS << ")";
|
||||||
} else if (VT == MVT::isVoid) {
|
} else if (VT == MVT::isVoid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user