[PATCH] D14665: Support literal structs in mangled intrinsics.

Pat Gavlin via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 14:58:13 PST 2015


pgavlin added inline comments.

================
Comment at: lib/IR/Function.cpp:493
@@ +492,3 @@
+    } else {
+      Result += "s_" + STyp->getName().str();
+    }
----------------
reames wrote:
> I'm not sure the change in serialization is acceptable here.  This will silently break previously valid code.  Is there a reason why the nesting scheme needs to apply to non-literal structs?  I think you can leave the old code in place for non-literal structures and just add the nesting for the new case.  
Consider the following:


```
%si64 = type { i64 }
%s = type { i64 }

; struct
define %si64* @test_struct(%si64* %v, %s* %w) gc "statepoint-example" {
       %tok = call i32 (i64, i32, %si64* ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p0si64f(i64 0, i32 0, %si64* ()* @return_si64, i32 0, i32 0, i32 0, i32 0)
       ;%tok = call i32 (i64, i32, %s* (i64)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p0si64f(i64 0, i32 0, %s* (i64)* @return_s, i32 1, i32 0, i64 0, i32 0, i32 0)
       ret %si64* %v
}

declare %si64* @return_si64()
declare %s* @return_s(i64)

declare i32 @llvm.experimental.gc.statepoint.p0f_p0si64f(i64, i32, %si64* ()*, i32, i32, ...)
;declare i32 @llvm.experimental.gc.statepoint.p0f_p0si64f(i64, i32, %s* (i64)*, i32, i32, ...)
```

The mangled names of the two signatures for the statepoint intrinsic collide due to the names of the structs and the parameter types involved. The proposed scheme avoids this collision, as the names become:

```
declare i32 @llvm.experimental.gc.statepoint.p0f_p0s_si64sf(i64, i32, %si64* ()*, i32, i32, ...)
declare i32 @llvm.experimental.gc.statepoint.p0f_p0s_ssi64f(i64, i32, %s* (i64)*, i32, i32, ...)
```


http://reviews.llvm.org/D14665





More information about the llvm-commits mailing list