Skip to content

Commit e156646

Browse files
committed
Fix the hash function for SILDebugScopes to handle the empty scopes
generated for artificial LLVM-only functions correctly. This fixes an IR Verifier error that was introduced in LLVM r302576. The bug itself was introduced together with the code in 5ea2d13. <rdar://problem/31926379>
1 parent 62e8028 commit e156646

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
7070
IRGenModule &IGM;
7171

7272
/// Used for caching SILDebugScopes without inline information.
73-
typedef std::pair<const void *, void *> LocalScopeHash;
73+
typedef std::pair<const void *, const void *> LocalScopeHash;
7474
struct LocalScope : public LocalScopeHash {
7575
LocalScope(const SILDebugScope *DS)
76-
: LocalScopeHash(
77-
{DS->Loc.getOpaquePointerValue(), DS->Parent.getOpaqueValue()}) {}
76+
: LocalScopeHash({DS->Loc.getOpaquePointerValue(),
77+
// If there is no parent SIL function use the scope
78+
// pointer as a unique id instead. This is safe
79+
// because such a function could also never have been
80+
// SIL-inlined.
81+
DS->Parent.getOpaqueValue()
82+
? DS->Parent.getOpaqueValue()
83+
: DS}) {}
7884
};
7985

8086
/// Various caches.

0 commit comments

Comments
 (0)