Skip to content

Commit 2bf473b

Browse files
authored
[GlobalOpt] Don't query TTI on a llvm.memcpy declaration. (#127760)
Querying TTI creates a Subtarget object, but an llvm.memcpy declaration doesn't have target-cpu and target-feature attributes like functions with definitions. This can cause a warning to be printed on RISC-V because the target-abi in the Module requires floating point, but the subtarget features don't enable floating point. So far we've only seen this in LTO when an -mcpu is not supplied for the TargetMachine. To fix this, get TTI for the calling function instead. Fixes the issue reported here #69780 (comment)
1 parent 9ebb618 commit 2bf473b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Transforms/IPO/GlobalOpt.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,8 +2186,10 @@ static bool tryWidenGlobalArraysUsedByMemcpy(
21862186
if (NumElementsToCopy != DZSize || DZSize != SZSize)
21872187
continue;
21882188

2189-
unsigned NumBytesToPad = GetTTI(*F).getNumBytesToPadGlobalArray(
2190-
NumBytesToCopy, SourceDataArray->getType());
2189+
unsigned NumBytesToPad =
2190+
GetTTI(*CI->getFunction())
2191+
.getNumBytesToPadGlobalArray(NumBytesToCopy,
2192+
SourceDataArray->getType());
21912193
if (NumBytesToPad) {
21922194
return tryWidenGlobalArrayAndDests(F, GV, NumBytesToPad, NumBytesToCopy,
21932195
BytesToCopyOp, SourceDataArray);

0 commit comments

Comments
 (0)