@@ -1920,7 +1920,7 @@ static bool getRangeForType(CodeGenFunction &CGF, QualType Ty,
1920
1920
llvm::MDNode *CodeGenFunction::getRangeForLoadFromType (QualType Ty) {
1921
1921
llvm::APInt Min, End;
1922
1922
if (!getRangeForType (*this , Ty, Min, End, CGM.getCodeGenOpts ().StrictEnums ,
1923
- Ty->hasBooleanRepresentation ()))
1923
+ Ty->hasBooleanRepresentation () && !Ty-> isVectorType () ))
1924
1924
return nullptr ;
1925
1925
1926
1926
llvm::MDBuilder MDHelper (getLLVMContext ());
@@ -1948,7 +1948,7 @@ bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType Ty,
1948
1948
if (!HasBoolCheck && !HasEnumCheck)
1949
1949
return false ;
1950
1950
1951
- bool IsBool = Ty->hasBooleanRepresentation () ||
1951
+ bool IsBool = ( Ty->hasBooleanRepresentation () && !Ty-> isVectorType () ) ||
1952
1952
NSAPI (CGM.getContext()).isObjCBOOLType(Ty);
1953
1953
bool NeedsBoolCheck = HasBoolCheck && IsBool;
1954
1954
bool NeedsEnumCheck = HasEnumCheck && Ty->getAs <EnumType>();
@@ -2068,11 +2068,8 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
2068
2068
// / by ConvertType) to its load/store type (as returned by
2069
2069
// / convertTypeForLoadStore).
2070
2070
llvm::Value *CodeGenFunction::EmitToMemory (llvm::Value *Value, QualType Ty) {
2071
- if (Ty->hasBooleanRepresentation () || Ty->isBitIntType ()) {
2072
- llvm::Type *StoreTy = convertTypeForLoadStore (Ty, Value->getType ());
2073
- bool Signed = Ty->isSignedIntegerOrEnumerationType ();
2074
- return Builder.CreateIntCast (Value, StoreTy, Signed, " storedv" );
2075
- }
2071
+ if (auto *AtomicTy = Ty->getAs <AtomicType>())
2072
+ Ty = AtomicTy->getValueType ();
2076
2073
2077
2074
if (Ty->isExtVectorBoolType ()) {
2078
2075
llvm::Type *StoreTy = convertTypeForLoadStore (Ty, Value->getType ());
@@ -2088,13 +2085,22 @@ llvm::Value *CodeGenFunction::EmitToMemory(llvm::Value *Value, QualType Ty) {
2088
2085
Value = Builder.CreateBitCast (Value, StoreTy);
2089
2086
}
2090
2087
2088
+ if (Ty->hasBooleanRepresentation () || Ty->isBitIntType ()) {
2089
+ llvm::Type *StoreTy = convertTypeForLoadStore (Ty, Value->getType ());
2090
+ bool Signed = Ty->isSignedIntegerOrEnumerationType ();
2091
+ return Builder.CreateIntCast (Value, StoreTy, Signed, " storedv" );
2092
+ }
2093
+
2091
2094
return Value;
2092
2095
}
2093
2096
2094
2097
// / Converts a scalar value from its load/store type (as returned
2095
2098
// / by convertTypeForLoadStore) to its primary IR type (as returned
2096
2099
// / by ConvertType).
2097
2100
llvm::Value *CodeGenFunction::EmitFromMemory (llvm::Value *Value, QualType Ty) {
2101
+ if (auto *AtomicTy = Ty->getAs <AtomicType>())
2102
+ Ty = AtomicTy->getValueType ();
2103
+
2098
2104
if (Ty->isPackedVectorBoolType (getContext ())) {
2099
2105
const auto *RawIntTy = Value->getType ();
2100
2106
0 commit comments