[llvm] [GlobalOpt] Don't query TTI on a llvm.memcpy declaration. (PR #127760)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 18 23:58:59 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Craig Topper (topperc)
<details>
<summary>Changes</summary>
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 https://github.com/llvm/llvm-project/issues/69780#issuecomment-2665273161
---
Full diff: https://github.com/llvm/llvm-project/pull/127760.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/IPO/GlobalOpt.cpp (+4-2)
``````````diff
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 9586fc97a39f7..1a2a27d22ae68 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2186,8 +2186,10 @@ static bool tryWidenGlobalArraysUsedByMemcpy(
if (NumElementsToCopy != DZSize || DZSize != SZSize)
continue;
- unsigned NumBytesToPad = GetTTI(*F).getNumBytesToPadGlobalArray(
- NumBytesToCopy, SourceDataArray->getType());
+ unsigned NumBytesToPad =
+ GetTTI(*CI->getFunction())
+ .getNumBytesToPadGlobalArray(NumBytesToCopy,
+ SourceDataArray->getType());
if (NumBytesToPad) {
return tryWidenGlobalArrayAndDests(F, GV, NumBytesToPad, NumBytesToCopy,
BytesToCopyOp, SourceDataArray);
``````````
</details>
https://github.com/llvm/llvm-project/pull/127760
More information about the llvm-commits
mailing list