summaryrefslogtreecommitdiffstats
path: root/unittests/Linker
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2017-02-15 23:16:20 +0000
committerDaniel Berlin <dberlin@dberlin.org>2017-02-15 23:16:20 +0000
commitd17bca97a51bcf4b75c622af1b85f51e421b8616 (patch)
tree869efbfd003828a4eb54f105217a1dbf0344d104 /unittests/Linker
parent644ed4d33fbe2219bf0f039f09965f77ab7bca5b (diff)
Implement intrinsic mangling for literal struct types.
Fixes PR 31921 Summary: Predicateinfo requires an ugly workaround to try to avoid literal struct types due to the intrinsic mangling not being implemented. This workaround actually does not work in all cases (you can hit the assert by bootstrapping with -print-predicateinfo), and can't be made to work without DFS'ing the type (IE copying getMangledStr and using a version that detects if it would crash). Rather than do that, i just implemented the mangling. It seems simple, since they are unified structurally. Looking at the overloaded-mangling testcase we have, it actually turns out the gc intrinsics will *also* crash if you try to use a literal struct. Thus, the testcase added fails before this patch, and works after, without needing to resort to predicateinfo. Reviewers: chandlerc, davide Subscribers: llvm-commits, sanjoy Differential Revision: https://reviews.llvm.org/D29925 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295253 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Linker')
-rw-r--r--unittests/Linker/LinkModulesTest.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/unittests/Linker/LinkModulesTest.cpp b/unittests/Linker/LinkModulesTest.cpp
index 92c483278be9..f31409c50121 100644
--- a/unittests/Linker/LinkModulesTest.cpp
+++ b/unittests/Linker/LinkModulesTest.cpp
@@ -317,34 +317,34 @@ TEST_F(LinkModuleTest, RemangleIntrinsics) {
const char *FooStr =
"%struct.rtx_def = type { i16 }\n"
"define void @foo(%struct.rtx_def* %a, i8 %b, i32 %c) {\n"
- " call void @llvm.memset.p0struct.rtx_def.i32(%struct.rtx_def* %a, i8 %b, i32 %c, i32 4, i1 true)\n"
+ " call void @llvm.memset.p0s_struct.rtx_defs.i32(%struct.rtx_def* %a, i8 %b, i32 %c, i32 4, i1 true)\n"
" ret void\n"
"}\n"
- "declare void @llvm.memset.p0struct.rtx_def.i32(%struct.rtx_def*, i8, i32, i32, i1)\n";
+ "declare void @llvm.memset.p0s_struct.rtx_defs.i32(%struct.rtx_def*, i8, i32, i32, i1)\n";
const char *BarStr =
"%struct.rtx_def = type { i16 }\n"
"define void @bar(%struct.rtx_def* %a, i8 %b, i32 %c) {\n"
- " call void @llvm.memset.p0struct.rtx_def.i32(%struct.rtx_def* %a, i8 %b, i32 %c, i32 4, i1 true)\n"
+ " call void @llvm.memset.p0s_struct.rtx_defs.i32(%struct.rtx_def* %a, i8 %b, i32 %c, i32 4, i1 true)\n"
" ret void\n"
"}\n"
- "declare void @llvm.memset.p0struct.rtx_def.i32(%struct.rtx_def*, i8, i32, i32, i1)\n";
+ "declare void @llvm.memset.p0s_struct.rtx_defs.i32(%struct.rtx_def*, i8, i32, i32, i1)\n";
std::unique_ptr<Module> Foo = parseAssemblyString(FooStr, Err, C);
assert(Foo);
ASSERT_TRUE(Foo.get());
// Foo is loaded first, so the type and the intrinsic have theis original
// names.
- ASSERT_TRUE(Foo->getFunction("llvm.memset.p0struct.rtx_def.i32"));
- ASSERT_FALSE(Foo->getFunction("llvm.memset.p0struct.rtx_def.0.i32"));
+ ASSERT_TRUE(Foo->getFunction("llvm.memset.p0s_struct.rtx_defs.i32"));
+ ASSERT_FALSE(Foo->getFunction("llvm.memset.p0s_struct.rtx_defs.0.i32"));
std::unique_ptr<Module> Bar = parseAssemblyString(BarStr, Err, C);
assert(Bar);
ASSERT_TRUE(Bar.get());
// Bar is loaded after Foo, so the type is renamed to struct.rtx_def.0. Check
// that the intrinsic is also renamed.
- ASSERT_FALSE(Bar->getFunction("llvm.memset.p0struct.rtx_def.i32"));
- ASSERT_TRUE(Bar->getFunction("llvm.memset.p0struct.rtx_def.0.i32"));
+ ASSERT_FALSE(Bar->getFunction("llvm.memset.p0s_struct.rtx_defs.i32"));
+ ASSERT_TRUE(Bar->getFunction("llvm.memset.p0s_struct.rtx_def.0s.i32"));
// Link two modules together.
auto Dst = llvm::make_unique<Module>("Linked", C);
@@ -356,7 +356,7 @@ TEST_F(LinkModuleTest, RemangleIntrinsics) {
// "struct.rtx_def" from Foo and "struct.rtx_def.0" from Bar are isomorphic
// types, so they must be uniquified by linker. Check that they use the same
// intrinsic definition.
- Function *F = Foo->getFunction("llvm.memset.p0struct.rtx_def.i32");
+ Function *F = Foo->getFunction("llvm.memset.p0s_struct.rtx_defs.i32");
ASSERT_EQ(F->getNumUses(), (unsigned)2);
}