@@ -2003,16 +2003,16 @@ Value *llvm::emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilderBase &B,
2003
2003
return CI;
2004
2004
}
2005
2005
2006
- Value *llvm::emitMalloc (Value *Num, IRBuilderBase &B, const DataLayout &DL ,
2007
- const TargetLibraryInfo *TLI, unsigned AddrSpace ) {
2006
+ Value *llvm::emitMalloc (Type *RetTy, Value *Num, IRBuilderBase &B,
2007
+ const DataLayout &DL, const TargetLibraryInfo *TLI ) {
2008
2008
Module *M = B.GetInsertBlock ()->getModule ();
2009
2009
if (!isLibFuncEmittable (M, TLI, LibFunc_malloc))
2010
2010
return nullptr ;
2011
2011
2012
2012
StringRef MallocName = TLI->getName (LibFunc_malloc);
2013
2013
Type *SizeTTy = getSizeTTy (B, TLI);
2014
- FunctionCallee Malloc = getOrInsertLibFunc (M, *TLI, LibFunc_malloc,
2015
- B. getPtrTy (AddrSpace) , SizeTTy);
2014
+ FunctionCallee Malloc =
2015
+ getOrInsertLibFunc (M, *TLI, LibFunc_malloc, RetTy , SizeTTy);
2016
2016
inferNonMandatoryLibFuncAttrs (M, MallocName, *TLI);
2017
2017
CallInst *CI = B.CreateCall (Malloc, Num, MallocName);
2018
2018
@@ -2023,16 +2023,16 @@ Value *llvm::emitMalloc(Value *Num, IRBuilderBase &B, const DataLayout &DL,
2023
2023
return CI;
2024
2024
}
2025
2025
2026
- Value *llvm::emitCalloc (Value *Num, Value *Size, IRBuilderBase &B,
2027
- const TargetLibraryInfo &TLI, unsigned AddrSpace ) {
2026
+ Value *llvm::emitCalloc (Type *RetTy, Value *Num, Value *Size, IRBuilderBase &B,
2027
+ const TargetLibraryInfo &TLI) {
2028
2028
Module *M = B.GetInsertBlock ()->getModule ();
2029
2029
if (!isLibFuncEmittable (M, &TLI, LibFunc_calloc))
2030
2030
return nullptr ;
2031
2031
2032
2032
StringRef CallocName = TLI.getName (LibFunc_calloc);
2033
2033
Type *SizeTTy = getSizeTTy (B, &TLI);
2034
- FunctionCallee Calloc = getOrInsertLibFunc (
2035
- M, TLI, LibFunc_calloc, B. getPtrTy (AddrSpace) , SizeTTy, SizeTTy);
2034
+ FunctionCallee Calloc =
2035
+ getOrInsertLibFunc ( M, TLI, LibFunc_calloc, RetTy , SizeTTy, SizeTTy);
2036
2036
inferNonMandatoryLibFuncAttrs (M, CallocName, TLI);
2037
2037
CallInst *CI = B.CreateCall (Calloc, {Num, Size}, CallocName);
2038
2038
@@ -2043,10 +2043,11 @@ Value *llvm::emitCalloc(Value *Num, Value *Size, IRBuilderBase &B,
2043
2043
return CI;
2044
2044
}
2045
2045
2046
- Value *llvm::emitHotColdSizeReturningNew (Value *Num, IRBuilderBase &B,
2046
+ Value *llvm::emitHotColdSizeReturningNew (Type *RetTy, Value *Num,
2047
+ IRBuilderBase &B,
2047
2048
const TargetLibraryInfo *TLI,
2048
2049
LibFunc SizeFeedbackNewFunc,
2049
- uint8_t HotCold, unsigned AddrSpace ) {
2050
+ uint8_t HotCold) {
2050
2051
Module *M = B.GetInsertBlock ()->getModule ();
2051
2052
if (!isLibFuncEmittable (M, TLI, SizeFeedbackNewFunc))
2052
2053
return nullptr ;
@@ -2055,7 +2056,7 @@ Value *llvm::emitHotColdSizeReturningNew(Value *Num, IRBuilderBase &B,
2055
2056
2056
2057
// __sized_ptr_t struct return type { void*, size_t }
2057
2058
StructType *SizedPtrT =
2058
- StructType::get (M->getContext (), {B. getPtrTy (AddrSpace) , Num->getType ()});
2059
+ StructType::get (M->getContext (), {RetTy , Num->getType ()});
2059
2060
FunctionCallee Func =
2060
2061
M->getOrInsertFunction (Name, SizedPtrT, Num->getType (), B.getInt8Ty ());
2061
2062
inferNonMandatoryLibFuncAttrs (M, Name, *TLI);
@@ -2067,9 +2068,11 @@ Value *llvm::emitHotColdSizeReturningNew(Value *Num, IRBuilderBase &B,
2067
2068
return CI;
2068
2069
}
2069
2070
2070
- Value *llvm::emitHotColdSizeReturningNewAligned (
2071
- Value *Num, Value *Align, IRBuilderBase &B, const TargetLibraryInfo *TLI,
2072
- LibFunc SizeFeedbackNewFunc, uint8_t HotCold, unsigned AddrSpace) {
2071
+ Value *llvm::emitHotColdSizeReturningNewAligned (Type *RetTy, Value *Num,
2072
+ Value *Align, IRBuilderBase &B,
2073
+ const TargetLibraryInfo *TLI,
2074
+ LibFunc SizeFeedbackNewFunc,
2075
+ uint8_t HotCold) {
2073
2076
Module *M = B.GetInsertBlock ()->getModule ();
2074
2077
if (!isLibFuncEmittable (M, TLI, SizeFeedbackNewFunc))
2075
2078
return nullptr ;
@@ -2078,7 +2081,7 @@ Value *llvm::emitHotColdSizeReturningNewAligned(
2078
2081
2079
2082
// __sized_ptr_t struct return type { void*, size_t }
2080
2083
StructType *SizedPtrT =
2081
- StructType::get (M->getContext (), {B. getPtrTy (AddrSpace) , Num->getType ()});
2084
+ StructType::get (M->getContext (), {RetTy , Num->getType ()});
2082
2085
FunctionCallee Func = M->getOrInsertFunction (Name, SizedPtrT, Num->getType (),
2083
2086
Align->getType (), B.getInt8Ty ());
2084
2087
inferNonMandatoryLibFuncAttrs (M, Name, *TLI);
@@ -2091,16 +2094,16 @@ Value *llvm::emitHotColdSizeReturningNewAligned(
2091
2094
return CI;
2092
2095
}
2093
2096
2094
- Value *llvm::emitHotColdNew (Value *Num, IRBuilderBase &B,
2097
+ Value *llvm::emitHotColdNew (Type *RetTy, Value *Num, IRBuilderBase &B,
2095
2098
const TargetLibraryInfo *TLI, LibFunc NewFunc,
2096
- uint8_t HotCold, unsigned AddrSpace ) {
2099
+ uint8_t HotCold) {
2097
2100
Module *M = B.GetInsertBlock ()->getModule ();
2098
2101
if (!isLibFuncEmittable (M, TLI, NewFunc))
2099
2102
return nullptr ;
2100
2103
2101
2104
StringRef Name = TLI->getName (NewFunc);
2102
- FunctionCallee Func = M-> getOrInsertFunction (Name, B. getPtrTy (AddrSpace),
2103
- Num->getType (), B.getInt8Ty ());
2105
+ FunctionCallee Func =
2106
+ M-> getOrInsertFunction (Name, RetTy, Num->getType (), B.getInt8Ty ());
2104
2107
inferNonMandatoryLibFuncAttrs (M, Name, *TLI);
2105
2108
CallInst *CI = B.CreateCall (Func, {Num, B.getInt8 (HotCold)}, Name);
2106
2109
@@ -2111,18 +2114,17 @@ Value *llvm::emitHotColdNew(Value *Num, IRBuilderBase &B,
2111
2114
return CI;
2112
2115
}
2113
2116
2114
- Value *llvm::emitHotColdNewNoThrow (Value *Num, Value *NoThrow, IRBuilderBase &B,
2117
+ Value *llvm::emitHotColdNewNoThrow (Type *RetTy, Value *Num, Value *NoThrow,
2118
+ IRBuilderBase &B,
2115
2119
const TargetLibraryInfo *TLI,
2116
- LibFunc NewFunc, uint8_t HotCold,
2117
- unsigned AddrSpace) {
2120
+ LibFunc NewFunc, uint8_t HotCold) {
2118
2121
Module *M = B.GetInsertBlock ()->getModule ();
2119
2122
if (!isLibFuncEmittable (M, TLI, NewFunc))
2120
2123
return nullptr ;
2121
2124
2122
2125
StringRef Name = TLI->getName (NewFunc);
2123
- FunctionCallee Func =
2124
- M->getOrInsertFunction (Name, B.getPtrTy (AddrSpace), Num->getType (),
2125
- NoThrow->getType (), B.getInt8Ty ());
2126
+ FunctionCallee Func = M->getOrInsertFunction (
2127
+ Name, RetTy, Num->getType (), NoThrow->getType (), B.getInt8Ty ());
2126
2128
inferNonMandatoryLibFuncAttrs (M, Name, *TLI);
2127
2129
CallInst *CI = B.CreateCall (Func, {Num, NoThrow, B.getInt8 (HotCold)}, Name);
2128
2130
@@ -2133,18 +2135,17 @@ Value *llvm::emitHotColdNewNoThrow(Value *Num, Value *NoThrow, IRBuilderBase &B,
2133
2135
return CI;
2134
2136
}
2135
2137
2136
- Value *llvm::emitHotColdNewAligned (Value *Num, Value *Align, IRBuilderBase &B,
2138
+ Value *llvm::emitHotColdNewAligned (Type *RetTy, Value *Num, Value *Align,
2139
+ IRBuilderBase &B,
2137
2140
const TargetLibraryInfo *TLI,
2138
- LibFunc NewFunc, uint8_t HotCold,
2139
- unsigned AddrSpace) {
2141
+ LibFunc NewFunc, uint8_t HotCold) {
2140
2142
Module *M = B.GetInsertBlock ()->getModule ();
2141
2143
if (!isLibFuncEmittable (M, TLI, NewFunc))
2142
2144
return nullptr ;
2143
2145
2144
2146
StringRef Name = TLI->getName (NewFunc);
2145
- FunctionCallee Func =
2146
- M->getOrInsertFunction (Name, B.getPtrTy (AddrSpace), Num->getType (),
2147
- Align->getType (), B.getInt8Ty ());
2147
+ FunctionCallee Func = M->getOrInsertFunction (Name, RetTy, Num->getType (),
2148
+ Align->getType (), B.getInt8Ty ());
2148
2149
inferNonMandatoryLibFuncAttrs (M, Name, *TLI);
2149
2150
CallInst *CI = B.CreateCall (Func, {Num, Align, B.getInt8 (HotCold)}, Name);
2150
2151
@@ -2155,19 +2156,18 @@ Value *llvm::emitHotColdNewAligned(Value *Num, Value *Align, IRBuilderBase &B,
2155
2156
return CI;
2156
2157
}
2157
2158
2158
- Value *llvm::emitHotColdNewAlignedNoThrow (Value *Num, Value *Align,
2159
+ Value *llvm::emitHotColdNewAlignedNoThrow (Type *RetTy, Value *Num, Value *Align,
2159
2160
Value *NoThrow, IRBuilderBase &B,
2160
2161
const TargetLibraryInfo *TLI,
2161
- LibFunc NewFunc, uint8_t HotCold,
2162
- unsigned AddrSpace) {
2162
+ LibFunc NewFunc, uint8_t HotCold) {
2163
2163
Module *M = B.GetInsertBlock ()->getModule ();
2164
2164
if (!isLibFuncEmittable (M, TLI, NewFunc))
2165
2165
return nullptr ;
2166
2166
2167
2167
StringRef Name = TLI->getName (NewFunc);
2168
- FunctionCallee Func = M-> getOrInsertFunction (
2169
- Name, B. getPtrTy (AddrSpace) , Num->getType (), Align->getType (),
2170
- NoThrow->getType (), B.getInt8Ty ());
2168
+ FunctionCallee Func =
2169
+ M-> getOrInsertFunction ( Name, RetTy , Num->getType (), Align->getType (),
2170
+ NoThrow->getType (), B.getInt8Ty ());
2171
2171
inferNonMandatoryLibFuncAttrs (M, Name, *TLI);
2172
2172
CallInst *CI =
2173
2173
B.CreateCall (Func, {Num, Align, NoThrow, B.getInt8 (HotCold)}, Name);
0 commit comments