Skip to content

Commit eef5db2

Browse files
committed
Revert "[llvm] Support forward-referenced globals with dso_local_equivalent"
This reverts commit 411020a. One of the tests here fails on some upstream builders: https://lab.llvm.org/buildbot#builders/16/builds/35314
1 parent 3285f9a commit eef5db2

File tree

4 files changed

+1
-181
lines changed

4 files changed

+1
-181
lines changed

llvm/include/llvm/AsmParser/LLParser.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ namespace llvm {
131131
/// function.
132132
PerFunctionState *BlockAddressPFS;
133133

134-
// References to dso_local_equivalent. The key is the global's ValID, the
135-
// value is a placeholder value that will be replaced.
136-
std::map<ValID, GlobalValue *> ForwardRefDSOLocalEquivalents;
137-
138134
// Attribute builder reference information.
139135
std::map<Value*, std::vector<unsigned> > ForwardRefAttrGroups;
140136
std::map<unsigned, AttrBuilder> NumberedAttrBuilders;

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -215,31 +215,6 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
215215
return error(ForwardRefBlockAddresses.begin()->first.Loc,
216216
"expected function name in blockaddress");
217217

218-
// If there are entries in ForwardRefDSOLocalEquivalents at this point, they
219-
// are references after the function was defined. Resolve those now.
220-
for (auto &Iter : ForwardRefDSOLocalEquivalents) {
221-
GlobalValue *GV = nullptr;
222-
const ValID &GVRef = Iter.first;
223-
if (GVRef.Kind == ValID::t_GlobalName)
224-
GV = M->getNamedValue(GVRef.StrVal);
225-
else if (GVRef.UIntVal < NumberedVals.size())
226-
GV = dyn_cast<GlobalValue>(NumberedVals[GVRef.UIntVal]);
227-
228-
if (!GV)
229-
return error(GVRef.Loc, "unknown function '" + GVRef.StrVal +
230-
"' referenced by dso_local_equivalent");
231-
232-
if (!GV->getValueType()->isFunctionTy())
233-
return error(GVRef.Loc,
234-
"expected a function, alias to function, or ifunc "
235-
"in dso_local_equivalent");
236-
237-
auto *Equiv = DSOLocalEquivalent::get(GV);
238-
Iter.second->replaceAllUsesWith(Equiv);
239-
Iter.second->eraseFromParent();
240-
}
241-
ForwardRefDSOLocalEquivalents.clear();
242-
243218
for (const auto &NT : NumberedTypes)
244219
if (NT.second.second.isValid())
245220
return error(NT.second.second,
@@ -3453,21 +3428,7 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
34533428
GV = M->getNamedValue(Fn.StrVal);
34543429
}
34553430

3456-
if (!GV) {
3457-
// Make a placeholder global variable as a placeholder for this reference.
3458-
GlobalValue *&FwdRef = ForwardRefDSOLocalEquivalents
3459-
.try_emplace(std::move(Fn), nullptr)
3460-
.first->second;
3461-
if (!FwdRef) {
3462-
FwdRef = new GlobalVariable(*M, Type::getInt8Ty(Context), false,
3463-
GlobalValue::InternalLinkage, nullptr, "",
3464-
nullptr, GlobalValue::NotThreadLocal);
3465-
}
3466-
3467-
ID.ConstantVal = FwdRef;
3468-
ID.Kind = ValID::t_Constant;
3469-
return false;
3470-
}
3431+
assert(GV && "Could not find a corresponding global variable");
34713432

34723433
if (!GV->getValueType()->isFunctionTy())
34733434
return error(Fn.Loc, "expected a function, alias to function, or ifunc "

llvm/test/CodeGen/X86/dso_local_equivalent.ll

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -97,121 +97,3 @@ define void @call_dso_local_ifunc_func() {
9797
call void dso_local_equivalent @dso_local_ifunc_func()
9898
ret void
9999
}
100-
101-
;; PR57815
102-
;; Ensure dso_local_equivalent works the exact same way as the previous
103-
;; examples but with forward-referenced symbols.
104-
105-
; CHECK: call_forward_func:
106-
; CHECK: callq forward_extern_func@PLT
107-
define void @call_forward_func() {
108-
call void dso_local_equivalent @forward_extern_func()
109-
ret void
110-
}
111-
112-
; CHECK: call_forward_hidden_func:
113-
; CHECK: callq forward_hidden_func{{$}}
114-
define void @call_forward_hidden_func() {
115-
call void dso_local_equivalent @forward_hidden_func()
116-
ret void
117-
}
118-
119-
; CHECK: call_forward_protected_func:
120-
; CHECK: callq forward_protected_func{{$}}
121-
define void @call_forward_protected_func() {
122-
call void dso_local_equivalent @forward_protected_func()
123-
ret void
124-
}
125-
126-
; CHECK: call_forward_dso_local_func:
127-
; CHECK: callq forward_dso_local_func{{$}}
128-
define void @call_forward_dso_local_func() {
129-
call void dso_local_equivalent @forward_dso_local_func()
130-
ret void
131-
}
132-
133-
; CHECK: call_forward_internal_func:
134-
; CHECK: callq forward_internal_func{{$}}
135-
define void @call_forward_internal_func() {
136-
call void dso_local_equivalent @forward_internal_func()
137-
ret void
138-
}
139-
140-
declare hidden void @forward_hidden_func()
141-
declare protected void @forward_protected_func()
142-
declare dso_local void @forward_dso_local_func()
143-
define internal void @forward_internal_func() {
144-
entry:
145-
ret void
146-
}
147-
define private void @forward_private_func() {
148-
entry:
149-
ret void
150-
}
151-
152-
; CHECK: call_forward_alias_func:
153-
; CHECK: callq forward_alias_func@PLT
154-
define void @call_forward_alias_func() {
155-
call void dso_local_equivalent @forward_alias_func()
156-
ret void
157-
}
158-
159-
; CHECK: call_forward_dso_local_alias_func:
160-
; CHECK: callq .Lforward_dso_local_alias_func$local{{$}}
161-
define void @call_forward_dso_local_alias_func() {
162-
call void dso_local_equivalent @forward_dso_local_alias_func()
163-
ret void
164-
}
165-
166-
define void @forward_aliasee_func() {
167-
entry:
168-
ret void
169-
}
170-
171-
@forward_alias_func = alias void (), ptr @forward_aliasee_func
172-
@forward_dso_local_alias_func = dso_local alias void (), ptr @forward_aliasee_func
173-
174-
; If an ifunc is not dso_local already, then we should still emit a stub for it
175-
; to ensure it will be dso_local.
176-
; CHECK: call_forward_ifunc_func:
177-
; CHECK: callq forward_ifunc_func@PLT
178-
define void @call_forward_ifunc_func() {
179-
call void dso_local_equivalent @forward_ifunc_func()
180-
ret void
181-
}
182-
183-
; CHECK: call_forward_dso_local_ifunc_func:
184-
; CHECK: callq forward_dso_local_ifunc_func{{$}}
185-
define void @call_forward_dso_local_ifunc_func() {
186-
call void dso_local_equivalent @forward_dso_local_ifunc_func()
187-
ret void
188-
}
189-
190-
@forward_ifunc_func = ifunc void (), ptr @resolver
191-
@forward_dso_local_ifunc_func = dso_local ifunc void (), ptr @resolver
192-
193-
;; Test "no-named" variables
194-
; CHECK: call_no_name_hidden:
195-
; CHECK: callq __unnamed_{{[0-9]+}}{{$}}
196-
define void @call_no_name_hidden() {
197-
call void dso_local_equivalent @0()
198-
ret void
199-
}
200-
201-
; CHECK: call_no_name_extern:
202-
; CHECK: callq __unnamed_{{[0-9]+}}@PLT
203-
define void @call_no_name_extern() {
204-
call void dso_local_equivalent @1()
205-
ret void
206-
}
207-
208-
declare hidden void @0()
209-
declare void @1()
210-
211-
;; Note that we keep this at the very end because llc emits this after all the
212-
;; functions.
213-
; CHECK: const:
214-
; CHECK: .long forward_extern_func@PLT
215-
@const = constant i32 trunc (i64 ptrtoint (ptr dso_local_equivalent @forward_extern_func to i64) to i32)
216-
217-
declare void @forward_extern_func()

llvm/test/CodeGen/X86/dso_local_equivalent_errors.ll

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)