Skip to content

Commit e55823f

Browse files
committed
Merge remote-tracking branch 'origin/ltsmaster'
2 parents 3b1f042 + 1d27989 commit e55823f

File tree

11 files changed

+60
-38
lines changed

11 files changed

+60
-38
lines changed

driver/linker.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,15 @@ static int linkObjToBinaryGcc(bool sharedLib, bool fullyStatic) {
164164
switch (global.params.targetTriple->getOS()) {
165165
case llvm::Triple::Linux:
166166
addSoname = true;
167-
args.push_back("-lrt");
168167
if (!opts::disableLinkerStripDead) {
169168
args.push_back("-Wl,--gc-sections");
170169
}
170+
if (global.params.targetTriple.getEnvironment() == llvm::Triple::Android) {
171+
args.push_back("-ldl");
172+
args.push_back("-lm");
173+
break;
174+
}
175+
args.push_back("-lrt");
171176
// fallthrough
172177
case llvm::Triple::Darwin:
173178
case llvm::Triple::MacOSX:

driver/main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,6 @@ static void registerPredefinedTargetVersions() {
754754
VersionCondition::addPredefinedGlobalIdent("Android");
755755
VersionCondition::addPredefinedGlobalIdent("CRuntime_Bionic");
756756
} else {
757-
VersionCondition::addPredefinedGlobalIdent("linux");
758-
VersionCondition::addPredefinedGlobalIdent("Posix");
759757
VersionCondition::addPredefinedGlobalIdent("CRuntime_Glibc");
760758
}
761759
break;

gen/abi-arm.cpp

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,10 @@
1818
#include "gen/abi-generic.h"
1919
#include "gen/abi-arm.h"
2020

21-
namespace {
22-
struct CompositeToArray32 : ABIRewrite {
23-
LLValue *get(Type *dty, LLValue *v) override {
24-
Logger::println("rewriting i32 array -> as %s", dty->toChars());
25-
LLValue *lval = DtoRawAlloca(v->getType(), 0);
26-
DtoStore(v, lval);
27-
28-
LLType *pTy = getPtrToType(DtoType(dty));
29-
return DtoLoad(DtoBitCast(lval, pTy), "get-result");
30-
}
31-
32-
LLValue *put(DValue *dv) override {
33-
Type *dty = dv->getType();
34-
Logger::println("rewriting %s -> as i32 array", dty->toChars());
35-
LLType *t = type(dty, nullptr);
36-
return DtoLoad(DtoBitCast(dv->getRVal(), getPtrToType(t)));
37-
}
38-
39-
LLType *type(Type *t, LLType *) override {
40-
// An i32 array that will hold Type 't'
41-
size_t sz = (t->size() + 3) / 4;
42-
return LLArrayType::get(LLIntegerType::get(gIR->context(), 32), sz);
43-
}
44-
};
45-
}
46-
4721
struct ArmTargetABI : TargetABI {
4822
HFAToArray hfaToArray;
4923
CompositeToArray32 compositeToArray32;
24+
CompositeToArray64 compositeToArray64;
5025
IntegerRewrite integerRewrite;
5126

5227
bool returnInArg(TypeFunction *tf) override {
@@ -134,9 +109,12 @@ struct ArmTargetABI : TargetABI {
134109
// non-HFA and messes up register selection
135110
if (isHFA((TypeStruct *)ty, &arg.ltype)) {
136111
arg.rewrite = &hfaToArray;
137-
} else {
112+
} else if (DtoAlignment(ty) <= 4) {
138113
arg.rewrite = &compositeToArray32;
139114
arg.ltype = compositeToArray32.type(arg.type, arg.ltype);
115+
} else {
116+
arg.rewrite = &compositeToArray64;
117+
arg.ltype = compositeToArray64.type(arg.type, arg.ltype);
140118
}
141119
}
142120
}

gen/abi-generic.h

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ struct HFAToArray : ABIRewrite {
271271
};
272272

273273
/**
274-
* Rewrite a composite as array of i64.
275-
*/
274+
* Rewrite a composite as array of i64.
275+
*/
276276
struct CompositeToArray64 : ABIRewrite {
277277
LLValue *get(Type *dty, LLValue *v) override {
278278
Logger::println("rewriting i64 array -> as %s", dty->toChars());
@@ -297,4 +297,31 @@ struct CompositeToArray64 : ABIRewrite {
297297
}
298298
};
299299

300+
/**
301+
* Rewrite a composite as array of i32.
302+
*/
303+
struct CompositeToArray32 : ABIRewrite {
304+
LLValue *get(Type *dty, LLValue *v) override {
305+
Logger::println("rewriting i32 array -> as %s", dty->toChars());
306+
LLValue *lval = DtoRawAlloca(v->getType(), 0);
307+
DtoStore(v, lval);
308+
309+
LLType *pTy = getPtrToType(DtoType(dty));
310+
return DtoLoad(DtoBitCast(lval, pTy), "get-result");
311+
}
312+
313+
LLValue *put(DValue *dv) override {
314+
Type *dty = dv->getType();
315+
Logger::println("rewriting %s -> as i32 array", dty->toChars());
316+
LLType *t = type(dty, nullptr);
317+
return DtoLoad(DtoBitCast(dv->getRVal(), getPtrToType(t)));
318+
}
319+
320+
LLType *type(Type *t, LLType *) override {
321+
// An i32 array that will hold Type 't'
322+
size_t sz = (t->size() + 3) / 4;
323+
return LLArrayType::get(LLIntegerType::get(gIR->context(), 32), sz);
324+
}
325+
};
326+
300327
#endif

gen/coverage.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ void emitCoverageLinecountInc(Loc &loc) {
4040

4141
// Do an atomic increment, so this works when multiple threads are executed.
4242
gIR->ir->CreateAtomicRMW(llvm::AtomicRMWInst::Add, ptr, DtoConstUint(1),
43-
llvm::AtomicOrdering::Monotonic);
43+
#if LDC_LLVM_VER >= 309
44+
llvm::AtomicOrdering::Monotonic
45+
#else
46+
llvm::Monotonic
47+
#endif
48+
);
4449

4550
unsigned num_sizet_bits = gDataLayout->getTypeSizeInBits(DtoSize_t());
4651
unsigned idx = line / num_sizet_bits;

gen/llvmhelpers.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ static llvm::ManagedStatic<llvm::LLVMContext> GlobalContext;
7575

7676
llvm::LLVMContext& getGlobalContext() { return *GlobalContext; }
7777

78+
/******************************************************************************
79+
* Global context
80+
******************************************************************************/
81+
static llvm::ManagedStatic<llvm::LLVMContext> GlobalContext;
82+
83+
llvm::LLVMContext& getGlobalContext() { return *GlobalContext; }
84+
7885
/******************************************************************************
7986
* DYNAMIC MEMORY HELPERS
8087
******************************************************************************/

gen/module.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,9 @@ static void genModuleInfo(Module *m, bool emitFullModuleInfo) {
900900
b.finalize(moduleInfoSym->getType()->getPointerElementType(), moduleInfoSym);
901901
setLinkage({LLGlobalValue::ExternalLinkage, false}, moduleInfoSym);
902902

903-
if (global.params.targetTriple->isOSLinux() || global.params.targetTriple->isOSFreeBSD() ||
903+
if ((global.params.targetTriple.isOSLinux() &&
904+
global.params.targetTriple.getEnvironment() != llvm::Triple::Android) ||
905+
global.params.targetTriple.isOSFreeBSD() ||
904906
#if LDC_LLVM_VER > 305
905907
global.params.targetTriple->isOSNetBSD() || global.params.targetTriple->isOSOpenBSD() ||
906908
global.params.targetTriple->isOSDragonFly()

runtime/druntime

runtime/phobos

Submodule phobos updated 1 file

tests/codegen/atomicrmw.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %ldc -c -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
1+
// RUN: %ldc -c -de -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
22

33
import core.atomic;
44

0 commit comments

Comments
 (0)