mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 16:11:08 +03:00
cleanup obsolete changes
This commit is contained in:
parent
1f41496326
commit
03e7834a49
6 changed files with 6 additions and 126 deletions
|
@ -29,11 +29,6 @@ AttrBuilder &AttrBuilder::add(LLAttribute attribute) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrBuilder &AttrBuilder::add(llvm::StringRef A, llvm::StringRef V) {
|
|
||||||
builder.addAttribute(A, V);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
AttrBuilder &AttrBuilder::remove(LLAttribute attribute) {
|
AttrBuilder &AttrBuilder::remove(LLAttribute attribute) {
|
||||||
// never remove 'None' explicitly
|
// never remove 'None' explicitly
|
||||||
if (attribute) {
|
if (attribute) {
|
||||||
|
|
|
@ -27,7 +27,6 @@ public:
|
||||||
AttrBuilder &add(LLAttribute attribute);
|
AttrBuilder &add(LLAttribute attribute);
|
||||||
AttrBuilder &remove(LLAttribute attribute);
|
AttrBuilder &remove(LLAttribute attribute);
|
||||||
AttrBuilder &merge(const AttrBuilder &other);
|
AttrBuilder &merge(const AttrBuilder &other);
|
||||||
AttrBuilder &add(llvm::StringRef A, llvm::StringRef V = llvm::StringRef());
|
|
||||||
|
|
||||||
AttrBuilder &addAlignment(unsigned alignment);
|
AttrBuilder &addAlignment(unsigned alignment);
|
||||||
AttrBuilder &addByVal(unsigned alignment);
|
AttrBuilder &addByVal(unsigned alignment);
|
||||||
|
|
|
@ -110,11 +110,10 @@ void cloneBlocks(const std::vector<llvm::BasicBlock *> &srcblocks,
|
||||||
CInst, llvm::OperandBundleDef("funclet", funclet));
|
CInst, llvm::OperandBundleDef("funclet", funclet));
|
||||||
call->setIsNoInline();
|
call->setIsNoInline();
|
||||||
newInst = call;
|
newInst = call;
|
||||||
|
} else if (funclet && llvm::isa<llvm::UnreachableInst>(Inst)) {
|
||||||
|
newInst = llvm::BranchInst::Create(continueWith); // to cleanupret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (funclet && llvm::isa<llvm::UnreachableInst>(Inst)) {
|
|
||||||
newInst = llvm::BranchInst::Create(continueWith); // cleanupret
|
|
||||||
}
|
|
||||||
if (!newInst)
|
if (!newInst)
|
||||||
newInst = Inst->clone();
|
newInst = Inst->clone();
|
||||||
|
|
||||||
|
@ -140,7 +139,7 @@ bool isCatchSwitchBlock(llvm::BasicBlock* bb) {
|
||||||
|
|
||||||
// copy from clang/.../MicrosoftCXXABI.cpp
|
// copy from clang/.../MicrosoftCXXABI.cpp
|
||||||
|
|
||||||
// 5 routines for constructing the llvm types for MS RTTI structs.
|
// routines for constructing the llvm types for MS RTTI structs.
|
||||||
llvm::StructType *getTypeDescriptorType(IRState &irs,
|
llvm::StructType *getTypeDescriptorType(IRState &irs,
|
||||||
llvm::Constant *classInfoPtr,
|
llvm::Constant *classInfoPtr,
|
||||||
llvm::StringRef TypeInfoString) {
|
llvm::StringRef TypeInfoString) {
|
||||||
|
@ -187,82 +186,4 @@ llvm::GlobalVariable *getTypeDescriptor(IRState &irs, ClassDeclaration *cd) {
|
||||||
return Var;
|
return Var;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// currently unused, information built at runtime ATM
|
|
||||||
llvm::StructType *BaseClassDescriptorType;
|
|
||||||
llvm::StructType *ClassHierarchyDescriptorType;
|
|
||||||
llvm::StructType *CompleteObjectLocatorType;
|
|
||||||
|
|
||||||
bool isImageRelative() {
|
|
||||||
return global.params.targetTriple.isArch64Bit();
|
|
||||||
}
|
|
||||||
|
|
||||||
llvm::Type *getImageRelativeType(llvm::Type *PtrType) {
|
|
||||||
if (!isImageRelative())
|
|
||||||
return PtrType;
|
|
||||||
return LLType::getInt32Ty(gIR->context());
|
|
||||||
}
|
|
||||||
|
|
||||||
llvm::StructType *getClassHierarchyDescriptorType();
|
|
||||||
|
|
||||||
llvm::StructType *getBaseClassDescriptorType() {
|
|
||||||
if (BaseClassDescriptorType)
|
|
||||||
return BaseClassDescriptorType;
|
|
||||||
auto intTy = LLType::getInt32Ty(gIR->context());
|
|
||||||
auto int8Ty = LLType::getInt8Ty(gIR->context());
|
|
||||||
llvm::Type *FieldTypes[] = {
|
|
||||||
getImageRelativeType(getPtrToType(int8Ty)),
|
|
||||||
intTy,
|
|
||||||
intTy,
|
|
||||||
intTy,
|
|
||||||
intTy,
|
|
||||||
intTy,
|
|
||||||
getImageRelativeType(getClassHierarchyDescriptorType()->getPointerTo()),
|
|
||||||
};
|
|
||||||
BaseClassDescriptorType = llvm::StructType::create(
|
|
||||||
gIR->context(), FieldTypes, "rtti.BaseClassDescriptor");
|
|
||||||
return BaseClassDescriptorType;
|
|
||||||
}
|
|
||||||
|
|
||||||
llvm::StructType *getClassHierarchyDescriptorType() {
|
|
||||||
if (ClassHierarchyDescriptorType)
|
|
||||||
return ClassHierarchyDescriptorType;
|
|
||||||
// Forward-declare RTTIClassHierarchyDescriptor to break a cycle.
|
|
||||||
ClassHierarchyDescriptorType = llvm::StructType::create(
|
|
||||||
gIR->context(), "rtti.ClassHierarchyDescriptor");
|
|
||||||
auto intTy = LLType::getInt32Ty(gIR->context());
|
|
||||||
llvm::Type *FieldTypes[] = {
|
|
||||||
intTy,
|
|
||||||
intTy,
|
|
||||||
intTy,
|
|
||||||
getImageRelativeType(
|
|
||||||
getBaseClassDescriptorType()->getPointerTo()->getPointerTo()),
|
|
||||||
};
|
|
||||||
ClassHierarchyDescriptorType->setBody(FieldTypes);
|
|
||||||
return ClassHierarchyDescriptorType;
|
|
||||||
}
|
|
||||||
|
|
||||||
llvm::StructType *getCompleteObjectLocatorType() {
|
|
||||||
if (CompleteObjectLocatorType)
|
|
||||||
return CompleteObjectLocatorType;
|
|
||||||
CompleteObjectLocatorType = llvm::StructType::create(
|
|
||||||
gIR->context(), "rtti.CompleteObjectLocator");
|
|
||||||
auto intTy = LLType::getInt32Ty(gIR->context());
|
|
||||||
auto int8Ty = LLType::getInt8Ty(gIR->context());
|
|
||||||
llvm::Type *FieldTypes[] = {
|
|
||||||
intTy,
|
|
||||||
intTy,
|
|
||||||
intTy,
|
|
||||||
getImageRelativeType(getPtrToType(int8Ty)),
|
|
||||||
getImageRelativeType(getClassHierarchyDescriptorType()->getPointerTo()),
|
|
||||||
getImageRelativeType(CompleteObjectLocatorType),
|
|
||||||
};
|
|
||||||
llvm::ArrayRef<llvm::Type *> FieldTypesRef(FieldTypes);
|
|
||||||
if (!isImageRelative())
|
|
||||||
FieldTypesRef = FieldTypesRef.drop_back();
|
|
||||||
CompleteObjectLocatorType->setBody(FieldTypesRef);
|
|
||||||
return CompleteObjectLocatorType;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // LDC_LLVM_VER >= 308
|
#endif // LDC_LLVM_VER >= 308
|
||||||
|
|
|
@ -776,9 +776,6 @@ public:
|
||||||
exnObj = cpyObj;
|
exnObj = cpyObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto enterCatchFn =
|
|
||||||
getRuntimeFunction(Loc(), irs->module, "_d_eh_enter_catch");
|
|
||||||
#if 1
|
|
||||||
// Exceptions are never rethrown by D code (but thrown again), so
|
// Exceptions are never rethrown by D code (but thrown again), so
|
||||||
// we can leave the catch handler right away and continue execution
|
// we can leave the catch handler right away and continue execution
|
||||||
// outside the catch funclet
|
// outside the catch funclet
|
||||||
|
@ -786,21 +783,9 @@ public:
|
||||||
llvm::BasicBlock::Create(irs->context(), "catchhandler", irs->topfunc());
|
llvm::BasicBlock::Create(irs->context(), "catchhandler", irs->topfunc());
|
||||||
llvm::CatchReturnInst::Create(catchpad, catchhandler, irs->scopebb());
|
llvm::CatchReturnInst::Create(catchpad, catchhandler, irs->scopebb());
|
||||||
irs->scope() = IRScope(catchhandler);
|
irs->scope() = IRScope(catchhandler);
|
||||||
|
auto enterCatchFn =
|
||||||
|
getRuntimeFunction(Loc(), irs->module, "_d_eh_enter_catch");
|
||||||
irs->CreateCallOrInvoke(enterCatchFn, DtoBitCast(exnObj, getVoidPtrType()), clssInfo);
|
irs->CreateCallOrInvoke(enterCatchFn, DtoBitCast(exnObj, getVoidPtrType()), clssInfo);
|
||||||
#else
|
|
||||||
irs->ir->CreateCall(enterCatchFn,
|
|
||||||
{DtoBitCast(exnObj, getVoidPtrType()), clssInfo},
|
|
||||||
{llvm::OperandBundleDef("funclet", catchpad)});
|
|
||||||
|
|
||||||
// The code generator will extract the catch handler to funclets
|
|
||||||
// so it needs to know the end of the code executed in the handler.
|
|
||||||
// This is marked by a catch return instruction that is created here
|
|
||||||
// as a cleanup so it appears in all code paths exiting the catch block
|
|
||||||
llvm::BasicBlock *retbb =
|
|
||||||
llvm::BasicBlock::Create(irs->context(), "catchret", irs->topfunc());
|
|
||||||
llvm::CatchReturnInst::Create(catchpad, endbb, retbb);
|
|
||||||
irs->func()->scopes->pushCleanup(retbb, retbb);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -851,10 +836,7 @@ public:
|
||||||
irs->scope() = IRScope(catchBB);
|
irs->scope() = IRScope(catchBB);
|
||||||
irs->DBuilder.EmitBlockStart((*it)->loc);
|
irs->DBuilder.EmitBlockStart((*it)->loc);
|
||||||
|
|
||||||
CleanupCursor currentScope = scopes->currentCleanupScope();
|
|
||||||
|
|
||||||
emitBeginCatchMSVCEH(*it, endbb, catchSwitchInst);
|
emitBeginCatchMSVCEH(*it, endbb, catchSwitchInst);
|
||||||
//scopes->pushFunclet(&catchBB->front());
|
|
||||||
|
|
||||||
// Emit handler, if there is one. The handler is zero, for instance,
|
// Emit handler, if there is one. The handler is zero, for instance,
|
||||||
// when building 'catch { debug foo(); }' in non-debug mode.
|
// when building 'catch { debug foo(); }' in non-debug mode.
|
||||||
|
@ -863,10 +845,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!irs->scopereturned()) {
|
if (!irs->scopereturned()) {
|
||||||
scopes->runCleanups(currentScope, endbb);
|
irs->ir->CreateBr(endbb);
|
||||||
}
|
}
|
||||||
scopes->popCleanups(currentScope);
|
|
||||||
//scopes->popFunclet();
|
|
||||||
|
|
||||||
irs->DBuilder.EmitBlockEnd();
|
irs->DBuilder.EmitBlockEnd();
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,6 @@ void executeCleanup(IRState *irs, CleanupScope &scope,
|
||||||
scope.exitTargets.push_back(CleanupExitTarget(continueWith));
|
scope.exitTargets.push_back(CleanupExitTarget(continueWith));
|
||||||
scope.exitTargets.back().sourceBlocks.push_back(sourceBlock);
|
scope.exitTargets.back().sourceBlocks.push_back(sourceBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopeStack::~ScopeStack() {
|
ScopeStack::~ScopeStack() {
|
||||||
|
@ -255,17 +254,6 @@ llvm::BasicBlock *ScopeStack::runCleanupPad(CleanupCursor scope,
|
||||||
if (isCatchSwitchBlock(cleanupScopes[scope].beginBlock))
|
if (isCatchSwitchBlock(cleanupScopes[scope].beginBlock))
|
||||||
return cleanupScopes[scope].beginBlock;
|
return cleanupScopes[scope].beginBlock;
|
||||||
|
|
||||||
// when hitting a catch return instruction during cleanup,
|
|
||||||
// just unwind to the corresponding catchswitch block instead
|
|
||||||
if (!cleanupScopes[scope].beginBlock->empty()) {
|
|
||||||
if (auto catchret = llvm::dyn_cast<llvm::CatchReturnInst>(
|
|
||||||
&cleanupScopes[scope].beginBlock->front())) {
|
|
||||||
llvm::BasicBlock* endcatch = nullptr;
|
|
||||||
auto catchpad = catchret->getCatchPad();
|
|
||||||
auto catchswitch = catchpad->getCatchSwitch();
|
|
||||||
return catchswitch->getUnwindDest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// each cleanup block is bracketed by a pair of cleanuppad/cleanupret
|
// each cleanup block is bracketed by a pair of cleanuppad/cleanupret
|
||||||
// instructions, any unwinding should also just continue at the next
|
// instructions, any unwinding should also just continue at the next
|
||||||
|
|
|
@ -416,7 +416,6 @@ llvm::CallSite ScopeStack::callOrInvoke(llvm::Value *callee, const T &args,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (doesNotThrow || (cleanupScopes.empty() && catchScopes.empty())) {
|
if (doesNotThrow || (cleanupScopes.empty() && catchScopes.empty())) {
|
||||||
L_call:
|
|
||||||
llvm::CallInst *call = irs->ir->CreateCall(callee, args,
|
llvm::CallInst *call = irs->ir->CreateCall(callee, args,
|
||||||
#if LDC_LLVM_VER >= 308
|
#if LDC_LLVM_VER >= 308
|
||||||
BundleList,
|
BundleList,
|
||||||
|
@ -429,8 +428,6 @@ L_call:
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::BasicBlock* landingPad = getLandingPad();
|
llvm::BasicBlock* landingPad = getLandingPad();
|
||||||
if (!landingPad)
|
|
||||||
goto L_call;
|
|
||||||
|
|
||||||
llvm::BasicBlock *postinvoke = llvm::BasicBlock::Create(
|
llvm::BasicBlock *postinvoke = llvm::BasicBlock::Create(
|
||||||
irs->context(), "postinvoke", irs->topfunc(), landingPad);
|
irs->context(), "postinvoke", irs->topfunc(), landingPad);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue