[PATCH] D103415: [BuildLibCalls] Properly set ABI attributes on arguments
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 31 09:24:34 PDT 2021
aeubanks created this revision.
Herald added a subscriber: hiraditya.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Some floating point lib calls have ABI attributes that need to be set on
the caller.
Found via D103412 <https://reviews.llvm.org/D103412>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D103415
Files:
llvm/lib/Transforms/Utils/BuildLibCalls.cpp
llvm/test/Transforms/InstCombine/pow_fp_int.ll
llvm/test/Transforms/InstCombine/simplify-libcalls.ll
Index: llvm/test/Transforms/InstCombine/simplify-libcalls.ll
===================================================================
--- llvm/test/Transforms/InstCombine/simplify-libcalls.ll
+++ llvm/test/Transforms/InstCombine/simplify-libcalls.ll
@@ -189,7 +189,7 @@
}
define double @fake_ldexp(i32 %x) {
; CHECK-LABEL: @fake_ldexp(
-; CHECK-NEXT: [[Z:%.*]] = call double @ldexp(double 1.0{{.*}}, i32 %x)
+; CHECK-NEXT: [[Z:%.*]] = call double @ldexp(double 1.0{{.*}}, i32 signext %x)
; CHECK-NEXT: ret double [[Z]]
%y = sitofp i32 %x to double
@@ -197,6 +197,8 @@
ret double %z
}
+; CHECK: declare double @ldexp(double, i32 signext)
+
attributes #0 = { nobuiltin }
attributes #1 = { builtin }
Index: llvm/test/Transforms/InstCombine/pow_fp_int.ll
===================================================================
--- llvm/test/Transforms/InstCombine/pow_fp_int.ll
+++ llvm/test/Transforms/InstCombine/pow_fp_int.ll
@@ -51,7 +51,7 @@
define double @pow_sitofp_double_const_base_2_fast(i32 %x) {
; CHECK-LABEL: @pow_sitofp_double_const_base_2_fast(
-; CHECK-NEXT: [[LDEXPF:%.*]] = call afn float @ldexpf(float 1.000000e+00, i32 [[X:%.*]])
+; CHECK-NEXT: [[LDEXPF:%.*]] = call afn float @ldexpf(float 1.000000e+00, i32 signext [[X:%.*]])
; CHECK-NEXT: [[RES:%.*]] = fpext float [[LDEXPF]] to double
; CHECK-NEXT: ret double [[RES]]
;
@@ -78,7 +78,7 @@
define double @pow_uitofp_const_base_2_fast(i31 %x) {
; CHECK-LABEL: @pow_uitofp_const_base_2_fast(
; CHECK-NEXT: [[TMP1:%.*]] = zext i31 [[X:%.*]] to i32
-; CHECK-NEXT: [[LDEXPF:%.*]] = call afn float @ldexpf(float 1.000000e+00, i32 [[TMP1]])
+; CHECK-NEXT: [[LDEXPF:%.*]] = call afn float @ldexpf(float 1.000000e+00, i32 signext [[TMP1]])
; CHECK-NEXT: [[RES:%.*]] = fpext float [[LDEXPF]] to double
; CHECK-NEXT: ret double [[RES]]
;
@@ -343,7 +343,7 @@
define double @pow_sitofp_const_base_2_no_fast(i32 %x) {
; CHECK-LABEL: @pow_sitofp_const_base_2_no_fast(
-; CHECK-NEXT: [[LDEXPF:%.*]] = call float @ldexpf(float 1.000000e+00, i32 [[X:%.*]])
+; CHECK-NEXT: [[LDEXPF:%.*]] = call float @ldexpf(float 1.000000e+00, i32 signext [[X:%.*]])
; CHECK-NEXT: [[RES:%.*]] = fpext float [[LDEXPF]] to double
; CHECK-NEXT: ret double [[RES]]
;
Index: llvm/lib/Transforms/Utils/BuildLibCalls.cpp
===================================================================
--- llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -1501,6 +1501,12 @@
CI->setAttributes(Attrs.removeAttribute(B.getContext(),
AttributeList::FunctionIndex,
Attribute::Speculatable));
+ for (int I = 0, E = Callee.getFunctionType()->getNumParams(); I != E; ++I) {
+ for (const auto &A :
+ CI->getCalledFunction()->getAttributes().getParamAttributes(I)) {
+ CI->addParamAttr(I, A);
+ }
+ }
if (const Function *F =
dyn_cast<Function>(Callee.getCallee()->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103415.348820.patch
Type: text/x-patch
Size: 3086 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210531/20ef6272/attachment.bin>
More information about the llvm-commits
mailing list