mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 09:31:03 +03:00
Merge branch 'master' into merge-2.066
Conflicts: gen/functions.cpp
This commit is contained in:
commit
e1ffd58732
5 changed files with 26 additions and 103 deletions
|
@ -1285,7 +1285,7 @@ int main(int argc, char **argv)
|
|||
// user perspective.
|
||||
//
|
||||
// Thus, if a library contained some functions in version(unittest), for
|
||||
// example the tests in std.concurrency, and we ended up inline-scannin
|
||||
// example the tests in std.concurrency, and we ended up inline-scanning
|
||||
// these functions while doing an -unittest build of a client application,
|
||||
// we could end up referencing functions that we think are
|
||||
// availableExternally, but have never been touched when the library was built.
|
||||
|
|
|
@ -275,7 +275,7 @@ public:
|
|||
gvar->setInitializer(initVal);
|
||||
gvar->setLinkage(llLinkage);
|
||||
|
||||
// Also set up the edbug info.
|
||||
// Also set up the debug info.
|
||||
irs->DBuilder.EmitGlobalVariable(gvar, decl);
|
||||
}
|
||||
|
||||
|
|
|
@ -962,25 +962,36 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
|||
return;
|
||||
}
|
||||
|
||||
// Skip generating code for this part of a TemplateInstance if it has been
|
||||
// instantiated by any non-root module (i.e. a module not listed on the
|
||||
// command line).
|
||||
// Check this before calling DtoDeclareFunction to avoid touching
|
||||
// unanalyzed code.
|
||||
if (!fd->needsCodegen())
|
||||
{
|
||||
IF_LOG Logger::println("No code generation for %s", fd->toChars());
|
||||
fd->ir.setDefined();
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip array ops implemented in druntime
|
||||
if (fd->isArrayOp && isDruntimeArrayOp(fd))
|
||||
{
|
||||
IF_LOG Logger::println("No code generation for array op %s implemented in druntime", fd->toChars());
|
||||
fd->ir.setDefined();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fd->semanticRun != PASSsemantic3done || fd->ident == Id::empty)
|
||||
{
|
||||
// We cannot ever generate code for this function. DMD would just filter
|
||||
// it out by checking needsCodegen(), but we want to emit functions even
|
||||
// if we do not need as available_exernally for inlining purposes.
|
||||
assert(!fd->needsCodegen());
|
||||
|
||||
IF_LOG Logger::println("No code generation for incomplete function '%s'",
|
||||
fd->toPrettyChars());
|
||||
fd->ir.setDefined();
|
||||
return;
|
||||
}
|
||||
|
||||
// If we do not know already that we do not need to emit this because its
|
||||
// from an extra inlining semantic, check whether we can omit it anyway.
|
||||
if (!fd->availableExternally && !fd->needsCodegen())
|
||||
{
|
||||
IF_LOG Logger::println("Emitting '%s' as available_externally",
|
||||
fd->toPrettyChars());
|
||||
fd->availableExternally = true;
|
||||
}
|
||||
|
||||
DtoDeclareFunction(fd);
|
||||
assert(fd->ir.isDeclared());
|
||||
|
||||
|
@ -1009,10 +1020,7 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
|||
assert(fd->ident != Id::empty);
|
||||
|
||||
if (fd->isUnitTestDeclaration()) {
|
||||
if (global.params.useUnitTests)
|
||||
gIR->unitTests.push_back(fd);
|
||||
else
|
||||
return;
|
||||
} else if (fd->isSharedStaticCtorDeclaration()) {
|
||||
gIR->sharedCtors.push_back(fd);
|
||||
} else if (StaticDtorDeclaration *dtorDecl = fd->isSharedStaticDtorDeclaration()) {
|
||||
|
@ -1204,10 +1212,6 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
|||
codegenFunction(fd->fbody, gIR);
|
||||
irFunc->gen = 0;
|
||||
|
||||
// TODO: clean up this mess
|
||||
|
||||
// std::cout << *func << std::endl;
|
||||
|
||||
llvm::BasicBlock* bb = gIR->scopebb();
|
||||
if (pred_begin(bb) == pred_end(bb) && bb != &bb->getParent()->getEntryBlock()) {
|
||||
// This block is trivially unreachable, so just delete it.
|
||||
|
@ -1237,8 +1241,6 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
|||
llvm::ReturnInst::Create(gIR->context(), LLConstant::getNullValue(func->getReturnType()), bb);
|
||||
}
|
||||
|
||||
// std::cout << *func << std::endl;
|
||||
|
||||
// erase alloca point
|
||||
if (allocaPoint->getParent())
|
||||
allocaPoint->eraseFromParent();
|
||||
|
@ -1252,8 +1254,6 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
|||
func->getBasicBlockList().pop_back();
|
||||
|
||||
gIR->functions.pop_back();
|
||||
|
||||
// std::cout << *func << std::endl;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -604,24 +604,6 @@ void DtoAggrCopy(LLValue* dst, LLValue* src)
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DtoMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device)
|
||||
{
|
||||
// FIXME: implement me
|
||||
/*llvm::Function* fn = GET_INTRINSIC_DECL(memory_barrier);
|
||||
assert(fn != NULL);
|
||||
|
||||
LLSmallVector<LLValue*, 5> llargs;
|
||||
llargs.push_back(DtoConstBool(ll));
|
||||
llargs.push_back(DtoConstBool(ls));
|
||||
llargs.push_back(DtoConstBool(sl));
|
||||
llargs.push_back(DtoConstBool(ss));
|
||||
llargs.push_back(DtoConstBool(device));
|
||||
|
||||
llvm::CallInst::Create(fn, llargs, "", gIR->scopebb());*/
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
llvm::ConstantInt* DtoConstSize_t(uint64_t i)
|
||||
{
|
||||
return LLConstantInt::get(DtoSize_t(), i, false);
|
||||
|
@ -690,18 +672,6 @@ LLConstant* DtoConstString(const char* str)
|
|||
);
|
||||
}
|
||||
|
||||
LLConstant* DtoConstStringPtr(const char* str, const char* section)
|
||||
{
|
||||
llvm::StringRef s(str);
|
||||
LLConstant* init = llvm::ConstantDataArray::getString(gIR->context(), s, true);
|
||||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(
|
||||
*gIR->module, init->getType(), true, llvm::GlobalValue::InternalLinkage, init, ".str");
|
||||
if (section) gvar->setSection(section);
|
||||
gvar->setUnnamedAddr(true);
|
||||
LLConstant* idxs[] = { DtoConstUint(0), DtoConstUint(0) };
|
||||
return llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LLValue* DtoLoad(LLValue* src, const char* name)
|
||||
|
@ -916,38 +886,6 @@ unsigned char getABITypeAlign(LLType* t)
|
|||
return gDataLayout->getABITypeAlignment(t);
|
||||
}
|
||||
|
||||
unsigned char getPrefTypeAlign(LLType* t)
|
||||
{
|
||||
return gDataLayout->getPrefTypeAlignment(t);
|
||||
}
|
||||
|
||||
LLType* getBiggestType(LLType** begin, size_t n)
|
||||
{
|
||||
LLType* bigTy = 0;
|
||||
size_t bigSize = 0;
|
||||
size_t bigAlign = 0;
|
||||
|
||||
LLType** end = begin+n;
|
||||
while (begin != end)
|
||||
{
|
||||
LLType* T = *begin;
|
||||
|
||||
size_t sz = getTypePaddedSize(T);
|
||||
size_t ali = getABITypeAlign(T);
|
||||
if (sz > bigSize || (sz == bigSize && ali > bigAlign))
|
||||
{
|
||||
bigTy = T;
|
||||
bigSize = sz;
|
||||
bigAlign = ali;
|
||||
}
|
||||
|
||||
++begin;
|
||||
}
|
||||
|
||||
// will be null for n==0
|
||||
return bigTy;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LLStructType* DtoInterfaceInfoType()
|
||||
|
|
15
gen/tollvm.h
15
gen/tollvm.h
|
@ -86,7 +86,6 @@ LLConstantInt* DtoConstUbyte(unsigned char i);
|
|||
LLConstant* DtoConstFP(Type* t, longdouble value);
|
||||
|
||||
LLConstant* DtoConstString(const char*);
|
||||
LLConstant* DtoConstStringPtr(const char* str, const char* section = 0);
|
||||
LLConstant* DtoConstBool(bool);
|
||||
|
||||
// llvm wrappers
|
||||
|
@ -132,10 +131,6 @@ size_t getTypeAllocSize(LLType* t);
|
|||
|
||||
// type alignments
|
||||
unsigned char getABITypeAlign(LLType* t);
|
||||
unsigned char getPrefTypeAlign(LLType* t);
|
||||
|
||||
// get biggest type, for unions ...
|
||||
LLType* getBiggestType(LLType** begin, size_t n);
|
||||
|
||||
// pair type helpers
|
||||
LLValue* DtoAggrPair(LLType* type, LLValue* V1, LLValue* V2, const char* name = 0);
|
||||
|
@ -185,14 +180,4 @@ void DtoAggrZeroInit(LLValue* v);
|
|||
*/
|
||||
void DtoAggrCopy(LLValue* dst, LLValue* src);
|
||||
|
||||
/**
|
||||
* Generates a call to llvm.memory.barrier
|
||||
* @param ll load-load
|
||||
* @param ls load-store
|
||||
* @param sl store-load
|
||||
* @param ss store-store
|
||||
* @param device special device flag
|
||||
*/
|
||||
void DtoMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device=false);
|
||||
|
||||
#endif // LDC_GEN_TOLLVM_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue