@@ -421,31 +421,33 @@ class EmscriptenABIInfo : public DefaultABIInfo {
421
421
explicit EmscriptenABIInfo (CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
422
422
423
423
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
+ }
425
434
};
426
435
427
436
class EmscriptenTargetCodeGenInfo : public TargetCodeGenInfo {
428
437
public:
429
438
explicit EmscriptenTargetCodeGenInfo (CodeGen::CodeGenTypes &CGT)
430
439
: 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 ; }
435
440
};
436
441
437
442
// / \brief Classify argument of given type \p Ty.
438
443
ABIArgInfo EmscriptenABIInfo::classifyArgumentType (QualType Ty) const {
439
444
if (isAggregateTypeForABI (Ty)) {
445
+ unsigned TypeAlign = getContext ().getTypeAlignInChars (Ty).getQuantity ();
440
446
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 );
443
449
}
444
450
445
- // We can handle floating-point values directly.
446
- if (Ty->isFloatingType ())
447
- return ABIArgInfo::getDirect ();
448
-
449
451
// Otherwise just do the default thing.
450
452
return DefaultABIInfo::classifyArgumentType (Ty);
451
453
}
@@ -458,10 +460,6 @@ ABIArgInfo EmscriptenABIInfo::classifyReturnType(QualType RetTy) const {
458
460
return ABIArgInfo::getDirect (CGT.ConvertType (QualType (SeltTy, 0 )));
459
461
}
460
462
461
- // We can handle floating-point values directly.
462
- if (RetTy->isFloatingType ())
463
- return ABIArgInfo::getDirect ();
464
-
465
463
// Otherwise just do the default thing.
466
464
return DefaultABIInfo::classifyReturnType (RetTy);
467
465
}
0 commit comments