Skip to content

Commit c60327f

Browse files
authored
[Builtin] Fix issue with attribute list update (#2192)
When adding changes to support fpbuiltins in the translator, there was a bug that overwrote some attributes. This PR aims to fix that issue. Signed-off-by: Arvind Sudarsanam <[email protected]>
1 parent 5c1e2c7 commit c60327f

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/SPIRV/SPIRVBuiltinHelper.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ Value *BuiltinCallMutator::doConversion() {
103103
Builder.Insert(addCallInst(CI->getModule(), FuncName, ReturnTy, Args,
104104
&Attrs, nullptr, Mangler.get()));
105105
NewCall->copyMetadata(*CI);
106-
NewCall->setAttributes(CI->getAttributes());
106+
if (CI->hasFnAttr("fpbuiltin-max-error")) {
107+
auto Attr = CI->getFnAttr("fpbuiltin-max-error");
108+
NewCall->addFnAttr(Attr);
109+
}
107110
Value *Result = MutateRet ? MutateRet(Builder, NewCall) : NewCall;
108111
Result->takeName(CI);
109112
if (!CI->getType()->isVoidTy())

test/extensions/INTEL/SPV_INTEL_fp_max_error/IntelFPMaxError.ll

+2-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
; CHECK-SPIRV: Name [[#T31:]] "t31"
4444
; CHECK-SPIRV: Name [[#T32:]] "t32"
4545
; CHECK-SPIRV: Name [[#T33:]] "t33"
46-
; CHECK-SPIRV: Name [[#T34:]] "t34"
4746

4847
; CHECK-SPIRV: Decorate [[#T3]] FPMaxErrorDecorationINTEL 1056964608
4948
; CHECK-SPIRV: Decorate [[#T4]] FPMaxErrorDecorationINTEL 1065353216
@@ -75,8 +74,7 @@
7574
; CHECK-SPIRV: Decorate [[#T30]] FPMaxErrorDecorationINTEL 1082130432
7675
; CHECK-SPIRV: Decorate [[#T31]] FPMaxErrorDecorationINTEL 1082130432
7776
; CHECK-SPIRV: Decorate [[#T32]] FPMaxErrorDecorationINTEL 1082130432
78-
; CHECK-SPIRV: Decorate [[#T33]] FPMaxErrorDecorationINTEL 1082130432
79-
; CHECK-SPIRV: Decorate [[#T34]] FPMaxErrorDecorationINTEL 1166016512
77+
; CHECK-SPIRV: Decorate [[#T33]] FPMaxErrorDecorationINTEL 1166016512
8078

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

@@ -113,7 +111,6 @@
113111
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T31]] [[#OCLEXTID]] ldexp
114112
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T32]] [[#OCLEXTID]] pow
115113
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T33]] [[#OCLEXTID]] hypot
116-
; CHECK-SPIRV: ExtInst [[#FTYPE]] [[#T34]] [[#OCLEXTID]] hypot
117114

118115
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"
119116
target triple = "spir64-unknown-unknown"
@@ -189,14 +186,12 @@ entry:
189186
; CHECK-LLVM: call spir_func float @_Z5atan2ff(float %f1, float %f2) #[[#AT4:]]
190187
; CHECK-LLVM: call spir_func float @_Z5ldexpfi(float %f1, i32 %f4) #[[#AT4]]
191188
; CHECK-LLVM: call spir_func float @_Z3powff(float %f1, float %f2) #[[#AT4]]
192-
; CHECK-LLVM: call spir_func float @_Z5hypotff(float %f1, float %f2) #[[#AT4]]
193189
%t30 = call float @llvm.fpbuiltin.atan2.f32(float %f1, float %f2) #3
194190
%t31 = call float @llvm.fpbuiltin.ldexp.f32.i32(float %f1, i32 %f4) #3
195191
%t32 = call float @llvm.fpbuiltin.pow.f32(float %f1, float %f2) #3
196-
%t33 = call float @llvm.fpbuiltin.hypot.f32(float %f1, float %f2) #3
197192

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

201196
ret void
202197
}

0 commit comments

Comments
 (0)