Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/SPIRV/SPIRVBuiltinHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ Value *BuiltinCallMutator::doConversion() {
Builder.Insert(addCallInst(CI->getModule(), FuncName, ReturnTy, Args,
&Attrs, nullptr, Mangler.get()));
NewCall->copyMetadata(*CI);
NewCall->setAttributes(CI->getAttributes());
if (CI->hasFnAttr("fpbuiltin-max-error")) {
auto Attr = CI->getFnAttr("fpbuiltin-max-error");
NewCall->addFnAttr(Attr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also call setAttributes() to copy all the other attributes, not just fpbuiltin-max-error?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to Viktoria's comment, like this we also discard calling convention if it was not a default one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to NOT introduce any new logic here. This PR aims to only correct the bug introduced by PR #2056

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I understand. Should we also guard addition of the metadata?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think copyMetadata overwrites existing metadata. So we should be fine here.

Thanks

}
Value *Result = MutateRet ? MutateRet(Builder, NewCall) : NewCall;
Result->takeName(CI);
if (!CI->getType()->isVoidTy())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
; CHECK-SPIRV: Name [[#T31:]] "t31"
; CHECK-SPIRV: Name [[#T32:]] "t32"
; CHECK-SPIRV: Name [[#T33:]] "t33"
; CHECK-SPIRV: Name [[#T34:]] "t34"

; CHECK-SPIRV: Decorate [[#T3]] FPMaxErrorDecorationINTEL 1056964608
; CHECK-SPIRV: Decorate [[#T4]] FPMaxErrorDecorationINTEL 1065353216
Expand Down Expand Up @@ -75,8 +74,7 @@
; CHECK-SPIRV: Decorate [[#T30]] FPMaxErrorDecorationINTEL 1082130432
; CHECK-SPIRV: Decorate [[#T31]] FPMaxErrorDecorationINTEL 1082130432
; CHECK-SPIRV: Decorate [[#T32]] FPMaxErrorDecorationINTEL 1082130432
; CHECK-SPIRV: Decorate [[#T33]] FPMaxErrorDecorationINTEL 1082130432
; CHECK-SPIRV: Decorate [[#T34]] FPMaxErrorDecorationINTEL 1166016512
; CHECK-SPIRV: Decorate [[#T33]] FPMaxErrorDecorationINTEL 1166016512

; CHECK-SPIRV: 3 TypeFloat [[#FTYPE:]] 32

Expand Down Expand Up @@ -113,7 +111,6 @@
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T31]] [[#OCLEXTID]] ldexp
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T32]] [[#OCLEXTID]] pow
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T33]] [[#OCLEXTID]] hypot
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T34]] [[#OCLEXTID]] hypot

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
target triple = "spir64-unknown-unknown"
Expand Down Expand Up @@ -189,14 +186,12 @@ entry:
; CHECK-LLVM: call spir_func float @_Z5atan2ff(float %f1, float %f2) #[[#AT4:]]
; CHECK-LLVM: call spir_func float @_Z5ldexpfi(float %f1, i32 %f4) #[[#AT4]]
; CHECK-LLVM: call spir_func float @_Z3powff(float %f1, float %f2) #[[#AT4]]
; CHECK-LLVM: call spir_func float @_Z5hypotff(float %f1, float %f2) #[[#AT4]]
%t30 = call float @llvm.fpbuiltin.atan2.f32(float %f1, float %f2) #3
%t31 = call float @llvm.fpbuiltin.ldexp.f32.i32(float %f1, i32 %f4) #3
%t32 = call float @llvm.fpbuiltin.pow.f32(float %f1, float %f2) #3
%t33 = call float @llvm.fpbuiltin.hypot.f32(float %f1, float %f2) #3

; CHECK-LLVM: call spir_func float @_Z5hypotff(float %f1, float %f2) #[[#AT5:]]
%t34 = call float @llvm.fpbuiltin.hypot.f32(float %f1, float %f2) #4
%t33 = call float @llvm.fpbuiltin.hypot.f32(float %f1, float %f2) #4

ret void
}
Expand Down