Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions llvm/examples/BrainF/BrainF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ void BrainF::header(LLVMContext& C) {

//declare i32 @puts(i8 *)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a followup, this code could use same larger cleanup to use opaque pointers in the comments and remove some unnecessary stuff like the zero-offset GEP below.

FunctionCallee puts_func = module->getOrInsertFunction(
"puts", IntegerType::getInt32Ty(C),
PointerType::getUnqual(IntegerType::getInt8Ty(C)));
"puts", IntegerType::getInt32Ty(C), PointerType::getUnqual(C));

//brainf.aberror:
aberrorbb = BasicBlock::Create(C, label, brainf_func);
Expand Down Expand Up @@ -296,8 +295,8 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
builder->SetInsertPoint(bb_1);

// Make part of PHI instruction now, wait until end of loop to finish
PHINode *phi_0 = PHINode::Create(PointerType::getUnqual(Int8Ty), 2,
headreg, testbb);
PHINode *phi_0 =
PHINode::Create(PointerType::getUnqual(C), 2, headreg, testbb);
phi_0->addIncoming(curhead, bb_0);
curhead = phi_0;

Expand Down Expand Up @@ -451,7 +450,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,

//%head.%d = phi i8 *[%head.%d, %main.%d]
PHINode *phi_1 =
builder->CreatePHI(PointerType::getUnqual(Int8Ty), 1, headreg);
builder->CreatePHI(PointerType::getUnqual(C), 1, headreg);
phi_1->addIncoming(head_0, testbb);
curhead = phi_1;
}
Expand Down
6 changes: 4 additions & 2 deletions llvm/include/llvm/FuzzMutate/OpDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ static inline SourcePred anyPtrType() {
std::vector<Constant *> Result;
// TODO: Should these point at something?
for (Type *T : Ts)
Result.push_back(PoisonValue::get(PointerType::getUnqual(T)));
Result.push_back(
PoisonValue::get(PointerType::getUnqual(T->getContext())));
return Result;
};
return {Pred, Make};
Expand All @@ -175,7 +176,8 @@ static inline SourcePred sizedPtrType() {
// as the pointer type will always be the same.
for (Type *T : Ts)
if (T->isSized())
Result.push_back(PoisonValue::get(PointerType::getUnqual(T)));
Result.push_back(
PoisonValue::get(PointerType::getUnqual(T->getContext())));

return Result;
};
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13601,7 +13601,7 @@ const SCEV *ScalarEvolution::getElementSize(Instruction *Inst) {
else
return nullptr;

Type *ETy = getEffectiveSCEVType(PointerType::getUnqual(Ty));
Type *ETy = getEffectiveSCEVType(PointerType::getUnqual(Inst->getContext()));
return getSizeOfExpr(ETy, Ty);
}

Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9006,8 +9006,9 @@ static SDValue getMemCmpLoad(const Value *PtrVal, MVT LoadVT,
if (LoadVT.isVector())
LoadTy = FixedVectorType::get(LoadTy, LoadVT.getVectorNumElements());

LoadInput = ConstantExpr::getBitCast(const_cast<Constant *>(LoadInput),
PointerType::getUnqual(LoadTy));
LoadInput =
ConstantExpr::getBitCast(const_cast<Constant *>(LoadInput),
PointerType::getUnqual(LoadTy->getContext()));

if (const Constant *LoadCst =
ConstantFoldLoadFromConstPtr(const_cast<Constant *>(LoadInput),
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/ShadowStackGCLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ bool ShadowStackGCLoweringImpl::doInitialization(Module &M) {
// Specifies length of variable length array.
EltTys.push_back(Type::getInt32Ty(M.getContext()));
FrameMapTy = StructType::create(EltTys, "gc_map");
PointerType *FrameMapPtrTy = PointerType::getUnqual(FrameMapTy);
PointerType *FrameMapPtrTy = PointerType::getUnqual(M.getContext());

// struct StackEntry {
// ShadowStackEntry *Next; // Caller's stack entry.
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SjLjEHPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,10 @@ bool SjLjEHPrepareImpl::runOnFunction(Function &F) {
Module &M = *F.getParent();
RegisterFn = M.getOrInsertFunction(
"_Unwind_SjLj_Register", Type::getVoidTy(M.getContext()),
PointerType::getUnqual(FunctionContextTy));
PointerType::getUnqual(FunctionContextTy->getContext()));
UnregisterFn = M.getOrInsertFunction(
"_Unwind_SjLj_Unregister", Type::getVoidTy(M.getContext()),
PointerType::getUnqual(FunctionContextTy));
PointerType::getUnqual(FunctionContextTy->getContext()));

PointerType *AllocaPtrTy = M.getDataLayout().getAllocaPtrType(M.getContext());

Expand Down
10 changes: 3 additions & 7 deletions llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ class GenericLLVMIRPlatformSupport : public LLJIT::PlatformSupport {
{PlatformInstanceDecl, DSOHandle});

auto *IntTy = Type::getIntNTy(*Ctx, sizeof(int) * CHAR_BIT);
auto *AtExitCallbackTy = FunctionType::get(VoidTy, {}, false);
auto *AtExitCallbackPtrTy = PointerType::getUnqual(AtExitCallbackTy);
auto *AtExitCallbackPtrTy = PointerType::getUnqual(*Ctx);
auto *AtExit = addHelperAndWrapper(
*M, "atexit", FunctionType::get(IntTy, {AtExitCallbackPtrTy}, false),
GlobalValue::HiddenVisibility, "__lljit.atexit_helper",
Expand Down Expand Up @@ -468,12 +467,9 @@ class GenericLLVMIRPlatformSupport : public LLJIT::PlatformSupport {
*M, GenericIRPlatformSupportTy, true, GlobalValue::ExternalLinkage,
nullptr, "__lljit.platform_support_instance");

auto *Int8Ty = Type::getInt8Ty(*Ctx);
auto *IntTy = Type::getIntNTy(*Ctx, sizeof(int) * CHAR_BIT);
auto *VoidTy = Type::getVoidTy(*Ctx);
auto *BytePtrTy = PointerType::getUnqual(Int8Ty);
auto *CxaAtExitCallbackTy = FunctionType::get(VoidTy, {BytePtrTy}, false);
auto *CxaAtExitCallbackPtrTy = PointerType::getUnqual(CxaAtExitCallbackTy);
auto *BytePtrTy = PointerType::getUnqual(*Ctx);
auto *CxaAtExitCallbackPtrTy = PointerType::getUnqual(*Ctx);

auto *CxaAtExit = addHelperAndWrapper(
*M, "__cxa_atexit",
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Frontend/Offloading/OffloadWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ StructType *getDeviceImageTy(Module &M) {
}

PointerType *getDeviceImagePtrTy(Module &M) {
return PointerType::getUnqual(getDeviceImageTy(M));
return PointerType::getUnqual(M.getContext());
}

// struct __tgt_bin_desc {
Expand All @@ -70,7 +70,7 @@ StructType *getBinDescTy(Module &M) {
}

PointerType *getBinDescPtrTy(Module &M) {
return PointerType::getUnqual(getBinDescTy(M));
return PointerType::getUnqual(M.getContext());
}
Comment on lines 72 to 74
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both this and getDeviceImagePtrTy give the same type. Will look into if deduplicating makes sense.


/// Creates binary descriptor for the given device images. Binary descriptor
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9177,16 +9177,16 @@ void OpenMPIRBuilder::initializeTypes(Module &M) {
#define OMP_TYPE(VarName, InitValue) VarName = InitValue;
#define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize) \
VarName##Ty = ArrayType::get(ElemTy, ArraySize); \
VarName##PtrTy = PointerType::getUnqual(VarName##Ty);
VarName##PtrTy = PointerType::getUnqual(Ctx);
#define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...) \
VarName = FunctionType::get(ReturnType, {__VA_ARGS__}, IsVarArg); \
VarName##Ptr = PointerType::getUnqual(VarName);
VarName##Ptr = PointerType::getUnqual(Ctx);
#define OMP_STRUCT_TYPE(VarName, StructName, Packed, ...) \
T = StructType::getTypeByName(Ctx, StructName); \
if (!T) \
T = StructType::create(Ctx, {__VA_ARGS__}, StructName, Packed); \
VarName = T; \
VarName##Ptr = PointerType::getUnqual(T);
VarName##Ptr = PointerType::getUnqual(Ctx);
#include "llvm/Frontend/OpenMP/OMPKinds.def"
}

Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/IR/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2482,7 +2482,8 @@ Constant *ConstantExpr::getSizeOf(Type* Ty) {
// Note that a non-inbounds gep is used, as null isn't within any object.
Constant *GEPIdx = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
Constant *GEP = getGetElementPtr(
Ty, Constant::getNullValue(PointerType::getUnqual(Ty)), GEPIdx);
Ty, Constant::getNullValue(PointerType::getUnqual(Ty->getContext())),
GEPIdx);
return getPtrToInt(GEP,
Type::getInt64Ty(Ty->getContext()));
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/ConstantsContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ struct InlineAsmKeyType {
using TypeClass = ConstantInfo<InlineAsm>::TypeClass;

InlineAsm *create(TypeClass *Ty) const {
assert(PointerType::getUnqual(FTy) == Ty);
assert(PointerType::getUnqual(FTy->getContext()) == Ty);
return new InlineAsm(FTy, std::string(AsmString), std::string(Constraints),
HasSideEffects, IsAlignStack, AsmDialect, CanThrow);
}
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/IR/InlineAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using namespace llvm;
InlineAsm::InlineAsm(FunctionType *FTy, const std::string &asmString,
const std::string &constraints, bool hasSideEffects,
bool isAlignStack, AsmDialect asmDialect, bool canThrow)
: Value(PointerType::getUnqual(FTy), Value::InlineAsmVal),
: Value(PointerType::getUnqual(FTy->getContext()), Value::InlineAsmVal),
AsmString(asmString), Constraints(constraints), FTy(FTy),
HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
Dialect(asmDialect), CanThrow(canThrow) {
Expand All @@ -47,7 +47,8 @@ InlineAsm *InlineAsm::get(FunctionType *FTy, StringRef AsmString,
InlineAsmKeyType Key(AsmString, Constraints, FTy, hasSideEffects,
isAlignStack, asmDialect, canThrow);
LLVMContextImpl *pImpl = FTy->getContext().pImpl;
return pImpl->InlineAsms.getOrCreate(PointerType::getUnqual(FTy), Key);
return pImpl->InlineAsms.getOrCreate(
PointerType::getUnqual(FTy->getContext()), Key);
}

void InlineAsm::destroyConstant() {
Expand Down
5 changes: 0 additions & 5 deletions llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1954,10 +1954,8 @@ instCombineLD1GatherIndex(InstCombiner &IC, IntrinsicInst &II) {
Align Alignment =
BasePtr->getPointerAlignment(II.getDataLayout());

Type *VecPtrTy = PointerType::getUnqual(Ty);
Value *Ptr = IC.Builder.CreateGEP(cast<VectorType>(Ty)->getElementType(),
BasePtr, IndexBase);
Ptr = IC.Builder.CreateBitCast(Ptr, VecPtrTy);
CallInst *MaskedLoad =
IC.Builder.CreateMaskedLoad(Ty, Ptr, Alignment, Mask, PassThru);
MaskedLoad->takeName(&II);
Expand Down Expand Up @@ -1986,9 +1984,6 @@ instCombineST1ScatterIndex(InstCombiner &IC, IntrinsicInst &II) {

Value *Ptr = IC.Builder.CreateGEP(cast<VectorType>(Ty)->getElementType(),
BasePtr, IndexBase);
Type *VecPtrTy = PointerType::getUnqual(Ty);
Ptr = IC.Builder.CreateBitCast(Ptr, VecPtrTy);

(void)IC.Builder.CreateMaskedStore(Val, Ptr, Alignment, Mask);

return IC.eraseInstFromFunction(II);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/Sparc/SparcISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,7 @@ SDValue SparcTargetLowering::LowerF128_LibCallArg(SDValue Chain,
Align(8));

Entry.Node = FIPtr;
Entry.Ty = PointerType::getUnqual(ArgTy);
Entry.Ty = PointerType::getUnqual(ArgTy->getContext());
}
Args.push_back(Entry);
return Chain;
Expand Down Expand Up @@ -2351,7 +2351,7 @@ SparcTargetLowering::LowerF128Op(SDValue Op, SelectionDAG &DAG,
int RetFI = MFI.CreateStackObject(16, Align(8), false);
RetPtr = DAG.getFrameIndex(RetFI, PtrVT);
Entry.Node = RetPtr;
Entry.Ty = PointerType::getUnqual(RetTy);
Entry.Ty = PointerType::getUnqual(RetTy->getContext());
if (!Subtarget->is64Bit()) {
Entry.IsSRet = true;
Entry.IndirectType = RetTy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ Function *WebAssemblyLowerEmscriptenEHSjLj::getInvokeWrapper(CallBase *CI) {
return It->second;

// Put the pointer to the callee as first argument
ArgTys.push_back(PointerType::getUnqual(CalleeFTy));
ArgTys.push_back(PointerType::getUnqual(CI->getContext()));
// Add argument types
ArgTys.append(CalleeFTy->param_begin(), CalleeFTy->param_end());

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Coroutines/CoroSplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ struct SwitchCoroutineSplitter {
SmallVector<Type *> NewParams;
NewParams.reserve(OldParams.size() + 1);
NewParams.append(OldParams.begin(), OldParams.end());
NewParams.push_back(PointerType::getUnqual(Shape.FrameTy));
NewParams.push_back(PointerType::getUnqual(Shape.FrameTy->getContext()));

auto *NewFnTy = FunctionType::get(OrigFnTy->getReturnType(), NewParams,
OrigFnTy->isVarArg());
Expand Down
10 changes: 4 additions & 6 deletions llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1529,20 +1529,18 @@ void DevirtModule::applyICallBranchFunnel(VTableSlotInfo &SlotInfo,
FunctionType *NewFT =
FunctionType::get(CB.getFunctionType()->getReturnType(), NewArgs,
CB.getFunctionType()->isVarArg());
PointerType *NewFTPtr = PointerType::getUnqual(NewFT);

IRBuilder<> IRB(&CB);
std::vector<Value *> Args;
Args.push_back(VCallSite.VTable);
llvm::append_range(Args, CB.args());

CallBase *NewCS = nullptr;
if (isa<CallInst>(CB))
NewCS = IRB.CreateCall(NewFT, IRB.CreateBitCast(JT, NewFTPtr), Args);
NewCS = IRB.CreateCall(NewFT, JT, Args);
else
NewCS = IRB.CreateInvoke(NewFT, IRB.CreateBitCast(JT, NewFTPtr),
cast<InvokeInst>(CB).getNormalDest(),
cast<InvokeInst>(CB).getUnwindDest(), Args);
NewCS =
IRB.CreateInvoke(NewFT, JT, cast<InvokeInst>(CB).getNormalDest(),
cast<InvokeInst>(CB).getUnwindDest(), Args);
NewCS->setCallingConv(CB.getCallingConv());

AttributeList Attrs = CB.getAttributes();
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,9 +1150,9 @@ bool DataFlowSanitizer::initializeModule(Module &M) {
Ctx = &M.getContext();
Int8Ptr = PointerType::getUnqual(*Ctx);
OriginTy = IntegerType::get(*Ctx, OriginWidthBits);
OriginPtrTy = PointerType::getUnqual(OriginTy);
OriginPtrTy = PointerType::getUnqual(*Ctx);
PrimitiveShadowTy = IntegerType::get(*Ctx, ShadowWidthBits);
PrimitiveShadowPtrTy = PointerType::getUnqual(PrimitiveShadowTy);
PrimitiveShadowPtrTy = PointerType::getUnqual(*Ctx);
Comment on lines -1153 to +1155
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These types are also the same. Will look into if deduplicating makes sense separately.

IntptrTy = DL.getIntPtrType(*Ctx);
ZeroPrimitiveShadow = ConstantInt::getSigned(PrimitiveShadowTy, 0);
ZeroOrigin = ConstantInt::getSigned(OriginTy, 0);
Expand Down
10 changes: 1 addition & 9 deletions llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,7 @@ void ObjCARCContract::tryToContractReleaseIntoStoreStrong(
<< " Retain: " << *Retain << "\n"
<< " Load: " << *Load << "\n");

LLVMContext &C = Release->getContext();
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *I8XX = PointerType::getUnqual(I8X);

Value *Args[] = { Load->getPointerOperand(), New };
if (Args[0]->getType() != I8XX)
Args[0] = new BitCastInst(Args[0], I8XX, "", Store->getIterator());
if (Args[1]->getType() != I8X)
Args[1] = new BitCastInst(Args[1], I8X, "", Store->getIterator());
Value *Args[] = {Load->getPointerOperand(), New};
Function *Decl = EP.get(ARCRuntimeEntryPointKind::StoreStrong);
CallInst *StoreStrong = objcarc::createCallInstWithColors(
Decl, Args, "", Store->getIterator(), BlockColors);
Expand Down
7 changes: 2 additions & 5 deletions llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1763,20 +1763,17 @@ void ObjCARCOpt::MoveCalls(Value *Arg, RRInfo &RetainsToMove,
SmallVectorImpl<Instruction *> &DeadInsts,
Module *M) {
Type *ArgTy = Arg->getType();
Type *ParamTy = PointerType::getUnqual(Type::getInt8Ty(ArgTy->getContext()));
Type *ParamTy = PointerType::getUnqual(ArgTy->getContext());

LLVM_DEBUG(dbgs() << "== ObjCARCOpt::MoveCalls ==\n");

// Insert the new retain and release calls.
for (Instruction *InsertPt : ReleasesToMove.ReverseInsertPts) {
Value *MyArg = ArgTy == ParamTy ? Arg
: new BitCastInst(Arg, ParamTy, "",
InsertPt->getIterator());
Function *Decl = EP.get(ARCRuntimeEntryPointKind::Retain);
SmallVector<OperandBundleDef, 1> BundleList;
addOpBundleForFunclet(InsertPt->getParent(), BundleList);
CallInst *Call =
CallInst::Create(Decl, MyArg, BundleList, "", InsertPt->getIterator());
CallInst::Create(Decl, Arg, BundleList, "", InsertPt->getIterator());
Call->setDoesNotThrow();
Call->setTailCall();

Expand Down
9 changes: 2 additions & 7 deletions llvm/tools/bugpoint/Miscompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,18 +894,13 @@ CleanupAndPrepareModules(BugDriver &BD, std::unique_ptr<Module> Test,
CallInst *Resolver = CallInst::Create(resolverFunc, ResolverArgs,
"resolver", LookupBB);

// Cast the result from the resolver to correctly-typed function.
CastInst *CastedResolver = new BitCastInst(
Resolver, PointerType::getUnqual(F->getFunctionType()),
"resolverCast", LookupBB);

// Save the value in our cache.
new StoreInst(CastedResolver, Cache, LookupBB);
new StoreInst(Resolver, Cache, LookupBB);
BranchInst::Create(DoCallBB, LookupBB);

PHINode *FuncPtr =
PHINode::Create(NullPtr->getType(), 2, "fp", DoCallBB);
FuncPtr->addIncoming(CastedResolver, LookupBB);
FuncPtr->addIncoming(Resolver, LookupBB);
FuncPtr->addIncoming(CachedVal, EntryBB);

// Save the argument list.
Expand Down
Loading