[llvm] [AMDGPU] Fix use-after-erase in OpenCL printf runtime binding (PR #177356)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 22 07:53:08 PST 2026


================
@@ -257,19 +410,70 @@ define i32 @format_str_A(float %f32.0, double %f64, float %f32.1, i16 %i16, i32
 ; GCN-NEXT:    store i32 [[TMP6]], ptr addrspace(1) [[PRINTBUFFNEXTPTR9]], align 4
 ; GCN-NEXT:    br label [[TMP3]]
 ; GCN:       6:
-; GCN-NEXT:    [[TMP7:%.*]] = xor i1 [[TMP1]], true
-; GCN-NEXT:    [[PRINTF_RES:%.*]] = sext i1 [[TMP7]] to i32
+; GCN-NEXT:    ret void
+;
+  %fpext.f32.to.f64 = fpext float %f32.1 to double
+  %call1 = call i32 @printf(ptr addrspace(4) @format.str.A, float %f32.0, double %f64, double %fpext.f32.to.f64, float 1.0, double 2.0, i16 %i16, i32 %i32, i64 %i64, <2 x float> <float 1.0, float 2.0>, <2 x i32> <i32 8, i32 234>, half %f16)
+  ret void
+}
+
+define i32 @format_str_A_with_use(float %f32.0, double %f64, float %f32.1, i16 %i16, i32 %i32, i64 %i64, half %f16) {
----------------
arsenm wrote:

I don't think we need every function duplicated with a return use? Just one, and shouldn't need all of the arguments?

https://github.com/llvm/llvm-project/pull/177356


More information about the llvm-commits mailing list