Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 9596f4e

Browse files
committed
Merge branch 'incoming'
2 parents 51c484d + 926efa5 commit 9596f4e

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ option(CLANG_INCLUDE_TESTS
290290
"Generate build targets for the Clang unit tests."
291291
${LLVM_INCLUDE_TESTS})
292292

293-
# TODO: docs.
294-
add_subdirectory(test)
295-
296293
if( CLANG_INCLUDE_TESTS )
294+
# TODO: docs.
295+
add_subdirectory(test) # XXX Emscripten: Backport fix from upstream LLVM 3.4 to actually skip tests if CLANG_INCLUDE_TESTS = OFF
296+
297297
add_subdirectory(unittests)
298298
endif()
299299

emscripten-version.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1.16.0
2+

lib/Basic/Targets.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ class EmscriptenTargetInfo : public OSTargetInfo<Target> {
269269
// handled outside of clang. TODO: Handling this within clang may be
270270
// beneficial.
271271
this->UserLabelPrefix = "";
272+
this->MaxAtomicPromoteWidth = this->MaxAtomicInlineWidth = 32;
272273
}
273274
};
274275

@@ -5102,8 +5103,11 @@ class AsmJSTargetInfo : public TargetInfo {
51025103
// the direction suggested here:
51035104
// https://bugzilla.mozilla.org/show_bug.cgi?id=904913#c21
51045105
// We can still set the preferred alignment to 16 bytes though.
5106+
//
5107+
// Set the natural stack alignment to 16 bytes to accomodate 128-bit
5108+
// aligned vectors.
51055109
DescriptionString = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
5106-
"f32:32:32-f64:64:64-p:32:32:32-v128:32:128-n32";
5110+
"f32:32:32-f64:64:64-p:32:32:32-v128:32:128-n32-S128";
51075111
}
51085112

51095113
void getDefaultFeatures(llvm::StringMap<bool> &Features) const {

lib/CodeGen/TargetInfo.cpp

+13-15
Original file line numberDiff line numberDiff line change
@@ -421,31 +421,33 @@ class EmscriptenABIInfo : public DefaultABIInfo {
421421
explicit EmscriptenABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
422422

423423
ABIArgInfo classifyReturnType(QualType RetTy) const;
424-
ABIArgInfo classifyArgumentType(QualType RetTy) const;
424+
ABIArgInfo classifyArgumentType(QualType Ty) const;
425+
426+
// DefaultABIInfo's classifyReturnType and classifyArgumentType are
427+
// non-virtual, but computeInfo is virtual, so we overload that.
428+
virtual void computeInfo(CGFunctionInfo &FI) const {
429+
FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
430+
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
431+
it != ie; ++it)
432+
it->info = classifyArgumentType(it->type);
433+
}
425434
};
426435

427436
class EmscriptenTargetCodeGenInfo : public TargetCodeGenInfo {
428437
public:
429438
explicit EmscriptenTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
430439
: TargetCodeGenInfo(new EmscriptenABIInfo(CGT)) {}
431-
432-
// TODO: Re-evaluate whether these hacks, borrowed from PNaCl, are necessary.
433-
bool addAsmMemoryAroundSyncSynchronize() const { return true; }
434-
bool asmMemoryIsFence() const { return true; }
435440
};
436441

437442
/// \brief Classify argument of given type \p Ty.
438443
ABIArgInfo EmscriptenABIInfo::classifyArgumentType(QualType Ty) const {
439444
if (isAggregateTypeForABI(Ty)) {
445+
unsigned TypeAlign = getContext().getTypeAlignInChars(Ty).getQuantity();
440446
if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, CGT))
441-
return ABIArgInfo::getIndirect(0, RAA == CGCXXABI::RAA_DirectInMemory);
442-
return ABIArgInfo::getIndirect(0);
447+
return ABIArgInfo::getIndirect(TypeAlign, RAA == CGCXXABI::RAA_DirectInMemory);
448+
return ABIArgInfo::getIndirect(TypeAlign);
443449
}
444450

445-
// We can handle floating-point values directly.
446-
if (Ty->isFloatingType())
447-
return ABIArgInfo::getDirect();
448-
449451
// Otherwise just do the default thing.
450452
return DefaultABIInfo::classifyArgumentType(Ty);
451453
}
@@ -458,10 +460,6 @@ ABIArgInfo EmscriptenABIInfo::classifyReturnType(QualType RetTy) const {
458460
return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0)));
459461
}
460462

461-
// We can handle floating-point values directly.
462-
if (RetTy->isFloatingType())
463-
return ABIArgInfo::getDirect();
464-
465463
// Otherwise just do the default thing.
466464
return DefaultABIInfo::classifyReturnType(RetTy);
467465
}

0 commit comments

Comments
 (0)