Skip to content

Commit 8e576a8

Browse files
committed
Fix another bug
Created using spr 1.3.6-beta.1
1 parent 709e43b commit 8e576a8

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

llvm/lib/Transforms/IPO/LowerTypeTests.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,7 @@ class LowerTypeTestsModule {
502502
uint8_t *exportTypeId(StringRef TypeId, const TypeIdLowering &TIL);
503503
TypeIdLowering importTypeId(StringRef TypeId);
504504
void importTypeTest(CallInst *CI);
505-
void importFunction(Function *F, bool isJumpTableCanonical,
506-
std::vector<GlobalAlias *> &AliasesToErase);
505+
void importFunction(Function *F, bool isJumpTableCanonical);
507506

508507
BitSetInfo
509508
buildBitSet(Metadata *TypeId,
@@ -1103,9 +1102,8 @@ void LowerTypeTestsModule::maybeReplaceComdat(Function *F,
11031102

11041103
// ThinLTO backend: the function F has a jump table entry; update this module
11051104
// accordingly. isJumpTableCanonical describes the type of the jump table entry.
1106-
void LowerTypeTestsModule::importFunction(
1107-
Function *F, bool isJumpTableCanonical,
1108-
std::vector<GlobalAlias *> &AliasesToErase) {
1105+
void LowerTypeTestsModule::importFunction(Function *F,
1106+
bool isJumpTableCanonical) {
11091107
assert(F->getType()->getAddressSpace() == 0);
11101108

11111109
GlobalValue::VisibilityTypes Visibility = F->getVisibility();
@@ -1135,23 +1133,23 @@ void LowerTypeTestsModule::importFunction(
11351133
} else {
11361134
F->setName(Name + ".cfi");
11371135
maybeReplaceComdat(F, Name);
1138-
F->setLinkage(GlobalValue::ExternalLinkage);
11391136
FDecl = Function::Create(F->getFunctionType(), GlobalValue::ExternalLinkage,
11401137
F->getAddressSpace(), Name, &M);
11411138
FDecl->setVisibility(Visibility);
11421139
Visibility = GlobalValue::HiddenVisibility;
11431140

1144-
// Delete aliases pointing to this function, they'll be re-created in the
1145-
// merged output. Don't do it yet though because ScopedSaveAliaseesAndUsed
1146-
// will want to reset the aliasees first.
1141+
// Update aliases pointing to this function to also include the ".cfi" suffix,
1142+
// We expect the jump table entry to either point to the real function or an
1143+
// alias. Redirect all other users to the jump table entry.
11471144
for (auto &U : F->uses()) {
11481145
if (auto *A = dyn_cast<GlobalAlias>(U.getUser())) {
1146+
std::string AliasName = A->getName().str() + ".cfi";
11491147
Function *AliasDecl = Function::Create(
11501148
F->getFunctionType(), GlobalValue::ExternalLinkage,
11511149
F->getAddressSpace(), "", &M);
11521150
AliasDecl->takeName(A);
11531151
A->replaceAllUsesWith(AliasDecl);
1154-
AliasesToErase.push_back(A);
1152+
A->setName(AliasName);
11551153
}
11561154
}
11571155
}
@@ -2077,16 +2075,13 @@ bool LowerTypeTestsModule::lower() {
20772075
Decls.push_back(&F);
20782076
}
20792077

2080-
std::vector<GlobalAlias *> AliasesToErase;
20812078
{
20822079
ScopedSaveAliaseesAndUsed S(M);
20832080
for (auto *F : Defs)
2084-
importFunction(F, /*isJumpTableCanonical*/ true, AliasesToErase);
2081+
importFunction(F, /*isJumpTableCanonical*/ true);
20852082
for (auto *F : Decls)
2086-
importFunction(F, /*isJumpTableCanonical*/ false, AliasesToErase);
2083+
importFunction(F, /*isJumpTableCanonical*/ false);
20872084
}
2088-
for (GlobalAlias *GA : AliasesToErase)
2089-
GA->eraseFromParent();
20902085

20912086
return true;
20922087
}

0 commit comments

Comments
 (0)