Conversation
|
@llvm/pr-subscribers-llvm-selectiondag @llvm/pr-subscribers-backend-powerpc Author: zhijian lin (diggerlin) Changesthe patch add it prevents the backend from optimizing even non-math libcalls such as Full diff: https://github.com/llvm/llvm-project/pull/165464.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index a52265055c88a..37108aa3a56d8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -9392,7 +9392,9 @@ bool SelectionDAGBuilder::visitStrNLenCall(const CallInst &I) {
bool SelectionDAGBuilder::visitUnaryFloatCall(const CallInst &I,
unsigned Opcode) {
// We already checked this call's prototype; verify it doesn't modify errno.
- if (!I.onlyReadsMemory())
+ // Do not perform optimizations for call sites that require strict
+ // floating-point semantics.
+ if (!I.onlyReadsMemory() || I.isStrictFP())
return false;
SDNodeFlags Flags;
@@ -9412,7 +9414,9 @@ bool SelectionDAGBuilder::visitUnaryFloatCall(const CallInst &I,
bool SelectionDAGBuilder::visitBinaryFloatCall(const CallInst &I,
unsigned Opcode) {
// We already checked this call's prototype; verify it doesn't modify errno.
- if (!I.onlyReadsMemory())
+ // Do not perform optimizations for call sites that require strict
+ // floating-point semantics.
+ if (!I.onlyReadsMemory() || I.isStrictFP())
return false;
SDNodeFlags Flags;
@@ -9445,11 +9449,10 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
// Check for well-known libc/libm calls. If the function is internal, it
// can't be a library call. Don't do the check if marked as nobuiltin for
- // some reason or the call site requires strict floating point semantics.
+ // some reason.
LibFunc Func;
- if (!I.isNoBuiltin() && !I.isStrictFP() && !F->hasLocalLinkage() &&
- F->hasName() && LibInfo->getLibFunc(*F, Func) &&
- LibInfo->hasOptimizedCodeGen(Func)) {
+ if (!I.isNoBuiltin() && !F->hasLocalLinkage() && F->hasName() &&
+ LibInfo->getLibFunc(*F, Func) && LibInfo->hasOptimizedCodeGen(Func)) {
switch (Func) {
default: break;
case LibFunc_bcmp:
diff --git a/llvm/test/CodeGen/PowerPC/milicode32.ll b/llvm/test/CodeGen/PowerPC/milicode32.ll
index 78d036202fe4e..09239fb9d1b09 100644
--- a/llvm/test/CodeGen/PowerPC/milicode32.ll
+++ b/llvm/test/CodeGen/PowerPC/milicode32.ll
@@ -64,8 +64,9 @@ entry:
%str.addr = alloca ptr, align 4
store ptr %str, ptr %str.addr, align 4
%0 = load ptr, ptr %str.addr, align 4
- %call = call i32 @strlen(ptr noundef %0)
+ %call = call i32 @strlen(ptr noundef %0) #0
ret i32 %call
}
declare i32 @strlen(ptr noundef) nounwind
+attributes #0 = { strictfp }
|
|
Friendly reminder — any feedback on this patch when you have a moment? |
|
Just wanted to kindly follow up on my previous message in case it got buried. |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/203/builds/28789 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/39887 Here is the relevant piece of the build log for the reference |
|
I checked the error information, it is not related to this patch |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/33/builds/26288 Here is the relevant piece of the build log for the reference |
the patch
Add strictfp attribute to prevent unwanted optimizations of libm calls
add
I.isStrictFP()intoit prevents the backend from optimizing even non-math libcalls such as
strlenandmemcmpif a call has the strict floating-point attribute. For example, it prevent converting strlen and memcmp to milicode call __strlen and __memcmp.