mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
For PR950:
This patch replaces signed integer types with signless ones: 1. [US]Byte -> Int8 2. [U]Short -> Int16 3. [U]Int -> Int32 4. [U]Long -> Int64. 5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion and other methods related to signedness. In a few places this warranted identifying the signedness information from other sources. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32785 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -22,17 +22,17 @@
|
||||
|
||||
void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
|
||||
GlobalValue *Array) {
|
||||
const Type *ArgVTy = PointerType::get(PointerType::get(Type::SByteTy));
|
||||
const PointerType *UIntPtr = PointerType::get(Type::UIntTy);
|
||||
const Type *ArgVTy = PointerType::get(PointerType::get(Type::Int8Ty));
|
||||
const PointerType *UIntPtr = PointerType::get(Type::Int32Ty);
|
||||
Module &M = *MainFn->getParent();
|
||||
Function *InitFn = M.getOrInsertFunction(FnName, Type::IntTy, Type::IntTy,
|
||||
ArgVTy, UIntPtr, Type::UIntTy,
|
||||
Function *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
|
||||
ArgVTy, UIntPtr, Type::Int32Ty,
|
||||
(Type *)0);
|
||||
|
||||
// This could force argc and argv into programs that wouldn't otherwise have
|
||||
// them, but instead we just pass null values in.
|
||||
std::vector<Value*> Args(4);
|
||||
Args[0] = Constant::getNullValue(Type::IntTy);
|
||||
Args[0] = Constant::getNullValue(Type::Int32Ty);
|
||||
Args[1] = Constant::getNullValue(ArgVTy);
|
||||
|
||||
// Skip over any allocas in the entry block.
|
||||
@ -40,7 +40,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
|
||||
BasicBlock::iterator InsertPos = Entry->begin();
|
||||
while (isa<AllocaInst>(InsertPos)) ++InsertPos;
|
||||
|
||||
std::vector<Constant*> GEPIndices(2, Constant::getNullValue(Type::IntTy));
|
||||
std::vector<Constant*> GEPIndices(2, Constant::getNullValue(Type::Int32Ty));
|
||||
unsigned NumElements = 0;
|
||||
if (Array) {
|
||||
Args[2] = ConstantExpr::getGetElementPtr(Array, GEPIndices);
|
||||
@ -51,7 +51,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
|
||||
// pass null.
|
||||
Args[2] = ConstantPointerNull::get(UIntPtr);
|
||||
}
|
||||
Args[3] = ConstantInt::get(Type::UIntTy, NumElements);
|
||||
Args[3] = ConstantInt::get(Type::Int32Ty, NumElements);
|
||||
|
||||
Instruction *InitCall = new CallInst(InitFn, Args, "newargc", InsertPos);
|
||||
|
||||
@ -75,16 +75,16 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
|
||||
AI = MainFn->arg_begin();
|
||||
// If the program looked at argc, have it look at the return value of the
|
||||
// init call instead.
|
||||
if (AI->getType() != Type::IntTy) {
|
||||
if (AI->getType() != Type::Int32Ty) {
|
||||
Instruction::CastOps opcode;
|
||||
if (!AI->use_empty()) {
|
||||
opcode = CastInst::getCastOpcode(InitCall, true, AI->getType(), true);
|
||||
AI->replaceAllUsesWith(
|
||||
CastInst::create(opcode, InitCall, AI->getType(), "", InsertPos));
|
||||
}
|
||||
opcode = CastInst::getCastOpcode(AI, true, Type::IntTy, true);
|
||||
opcode = CastInst::getCastOpcode(AI, true, Type::Int32Ty, true);
|
||||
InitCall->setOperand(1,
|
||||
CastInst::create(opcode, AI, Type::IntTy, "argc.cast", InitCall));
|
||||
CastInst::create(opcode, AI, Type::Int32Ty, "argc.cast", InitCall));
|
||||
} else {
|
||||
AI->replaceAllUsesWith(InitCall);
|
||||
InitCall->setOperand(1, AI);
|
||||
@ -103,14 +103,14 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum,
|
||||
|
||||
// Create the getelementptr constant expression
|
||||
std::vector<Constant*> Indices(2);
|
||||
Indices[0] = Constant::getNullValue(Type::IntTy);
|
||||
Indices[1] = ConstantInt::get(Type::IntTy, CounterNum);
|
||||
Indices[0] = Constant::getNullValue(Type::Int32Ty);
|
||||
Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum);
|
||||
Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, Indices);
|
||||
|
||||
// Load, increment and store the value back.
|
||||
Value *OldVal = new LoadInst(ElementPtr, "OldFuncCounter", InsertPos);
|
||||
Value *NewVal = BinaryOperator::create(Instruction::Add, OldVal,
|
||||
ConstantInt::get(Type::UIntTy, 1),
|
||||
ConstantInt::get(Type::Int32Ty, 1),
|
||||
"NewFuncCounter", InsertPos);
|
||||
new StoreInst(NewVal, ElementPtr, InsertPos);
|
||||
}
|
||||
|
Reference in New Issue
Block a user