[PATCH] getMangledTypeStr: add support for vectors

Ramkumar Ramachandra artagnon at gmail.com
Sun Jan 11 20:18:14 PST 2015


After some investigation, I have concluded that this change is
completely incorrect. For integers, floats and vectors, it is supposed
to fall back to the `getEVTString()` which may then return "i", "v",
"f" prefixes in the common case.

I have instead focused on updating the comment with this information,
and writing a set of tests that people can use as a guide for coming
up with the correct mangling string.


http://reviews.llvm.org/D6915

Files:
  lib/IR/Function.cpp
  test/CodeGen/Generic/overloaded-intrinsic-name.ll

Index: lib/IR/Function.cpp
===================================================================
--- lib/IR/Function.cpp
+++ lib/IR/Function.cpp
@@ -447,14 +447,16 @@
 
 /// Returns a stable mangling for the type specified for use in the name
 /// mangling scheme used by 'any' types in intrinsic signatures.  The mangling
-/// of named types is simply their name.  Manglings for unnamed types consist
-/// of a prefix ('p' for pointers, 'a' for arrays, 'f_' for functions)
-/// combined with the mangling of their component types.  A vararg function
-/// type will have a suffix of 'vararg'.  Since function types can contain
-/// other function types, we close a function type mangling with suffix 'f'
-/// which can't be confused with it's prefix.  This ensures we don't have
-/// collisions between two unrelated function types. Otherwise, you might
-/// parse ffXX as f(fXX) or f(fX)X.  (X is a placeholder for any other type.)
+/// of named types is simply their name.  Manglings for unnamed types consist of
+/// a prefix ('p' for pointers, 'a' for arrays, 'f_' for functions) combined
+/// with the mangling of their component types.  A vararg function type will
+/// have a suffix of 'vararg'.  Since function types can contain other function
+/// types, we close a function type mangling with suffix 'f' which can't be
+/// confused with it's prefix.  This ensures we don't have collisions between
+/// two unrelated function types. Otherwise, you might parse ffXX as f(fXX) or
+/// f(fX)X.  (X is a placeholder for any other type). Manglings of integers,
+/// floats, and vectors ('i', 'f', and 'v' prefix in most cases) fall back to
+/// the MVT codepath, where they could be mangled to 'x86mmx', for example.
 static std::string getMangledTypeStr(Type* Ty) {
   std::string Result;
   if (PointerType* PTyp = dyn_cast<PointerType>(Ty)) {
Index: test/CodeGen/Generic/overloaded-intrinsic-name.ll
===================================================================
--- /dev/null
+++ test/CodeGen/Generic/overloaded-intrinsic-name.ll
@@ -0,0 +1,39 @@
+; RUN: llc < %s
+; Tests the name mangling performed by the codepath following
+; getMangledTypeStr(). Exercise the most general case,
+; llvm_anyptr_type, using gc.relocate and gc.statepoint.
+
+; function and integer
+define i32* @test_iAny(i32* %v) {
+       %tok = call i32 (i1 ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0, i32* %v)
+       %v-new = call i32* @llvm.experimental.gc.relocate.p0i32(i32 %tok, i32 4, i32 4)
+       ret i32* %v-new
+}
+
+; float
+define float* @test_fAny(float* %v) {
+       %tok = call i32 (i1 ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0, float* %v)
+       %v-new = call float* @llvm.experimental.gc.relocate.p0f32(i32 %tok, i32 4, i32 4)
+       ret float* %v-new
+}
+
+; array of integers
+define [3 x i32]* @test_aAny([3 x i32]* %v) {
+       %tok = call i32 (i1 ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0, [3 x i32]* %v)
+       %v-new = call [3 x i32]* @llvm.experimental.gc.relocate.p0a3i32(i32 %tok, i32 4, i32 4)
+       ret [3 x i32]* %v-new
+}
+
+; vector of integers
+define <3 x i32>* @test_vAny(<3 x i32>* %v) {
+       %tok = call i32 (i1 ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0, <3 x i32>* %v)
+       %v-new = call <3 x i32>* @llvm.experimental.gc.relocate.p0v3i32(i32 %tok, i32 4, i32 4)
+       ret <3 x i32>* %v-new
+}
+
+declare zeroext i1 @return_i1()
+declare i32 @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()*, i32, i32, ...)
+declare i32* @llvm.experimental.gc.relocate.p0i32(i32, i32, i32)
+declare float* @llvm.experimental.gc.relocate.p0f32(i32, i32, i32)
+declare [3 x i32]* @llvm.experimental.gc.relocate.p0a3i32(i32, i32, i32)
+declare <3 x i32>* @llvm.experimental.gc.relocate.p0v3i32(i32, i32, i32)

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6915.17995.patch
Type: text/x-patch
Size: 3961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150112/fedbffff/attachment.bin>


More information about the llvm-commits mailing list