@@ -2064,7 +2064,7 @@ static bool destArrayCanBeWidened(CallInst *CI) {
2064
2064
return true ;
2065
2065
}
2066
2066
2067
- static GlobalVariable *widenGlobalVariable (GlobalVariable *OldVar, Function *F,
2067
+ static GlobalVariable *widenGlobalVariable (GlobalVariable *OldVar,
2068
2068
unsigned NumBytesToPad,
2069
2069
unsigned NumBytesToCopy) {
2070
2070
if (!OldVar->hasInitializer ())
@@ -2083,10 +2083,10 @@ static GlobalVariable *widenGlobalVariable(GlobalVariable *OldVar, Function *F,
2083
2083
StrData.push_back (' \0 ' );
2084
2084
auto Arr = ArrayRef (StrData.data (), NumBytesToCopy + NumBytesToPad);
2085
2085
// Create new padded version of global variable.
2086
- Constant *SourceReplace = ConstantDataArray::get (F ->getContext (), Arr);
2086
+ Constant *SourceReplace = ConstantDataArray::get (OldVar ->getContext (), Arr);
2087
2087
GlobalVariable *NewGV = new GlobalVariable (
2088
- *(F ->getParent ()), SourceReplace->getType (), true , OldVar-> getLinkage () ,
2089
- SourceReplace, SourceReplace->getName ());
2088
+ *(OldVar ->getParent ()), SourceReplace->getType (), true ,
2089
+ OldVar-> getLinkage (), SourceReplace, SourceReplace->getName ());
2090
2090
// Copy any other attributes from original global variable
2091
2091
// e.g. unamed_addr
2092
2092
NewGV->copyAttributesFrom (OldVar);
@@ -2114,13 +2114,13 @@ static void widenDestArray(CallInst *CI, const unsigned NumBytesToPad,
2114
2114
}
2115
2115
}
2116
2116
2117
- static bool tryWidenGlobalArrayAndDests (Function *F, GlobalVariable *SourceVar,
2117
+ static bool tryWidenGlobalArrayAndDests (GlobalVariable *SourceVar,
2118
2118
const unsigned NumBytesToPad,
2119
2119
const unsigned NumBytesToCopy,
2120
2120
ConstantInt *BytesToCopyOp,
2121
2121
ConstantDataArray *SourceDataArray) {
2122
2122
auto *NewSourceGV =
2123
- widenGlobalVariable (SourceVar, F, NumBytesToPad, NumBytesToCopy);
2123
+ widenGlobalVariable (SourceVar, NumBytesToPad, NumBytesToCopy);
2124
2124
if (!NewSourceGV)
2125
2125
return false ;
2126
2126
@@ -2158,8 +2158,6 @@ static bool tryWidenGlobalArraysUsedByMemcpy(
2158
2158
if (!callInstIsMemcpy (CI) || !destArrayCanBeWidened (CI))
2159
2159
continue ;
2160
2160
2161
- Function *F = CI->getCalledFunction ();
2162
-
2163
2161
auto *BytesToCopyOp = dyn_cast<ConstantInt>(CI->getArgOperand (2 ));
2164
2162
if (!BytesToCopyOp)
2165
2163
continue ;
@@ -2191,7 +2189,7 @@ static bool tryWidenGlobalArraysUsedByMemcpy(
2191
2189
.getNumBytesToPadGlobalArray (NumBytesToCopy,
2192
2190
SourceDataArray->getType ());
2193
2191
if (NumBytesToPad) {
2194
- return tryWidenGlobalArrayAndDests (F, GV, NumBytesToPad, NumBytesToCopy,
2192
+ return tryWidenGlobalArrayAndDests (GV, NumBytesToPad, NumBytesToCopy,
2195
2193
BytesToCopyOp, SourceDataArray);
2196
2194
}
2197
2195
}
0 commit comments