diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-04-14 00:35:42 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-04-14 00:35:42 +0000 |
commit | 843237f5731243b21762adf5bb77da0c4d884df2 (patch) | |
tree | 7e320c09ae40d326af6c2f057625297ac1a3ac18 /llvm/lib/IR/DebugInfoMetadata.cpp | |
parent | 4fd839b0da90963ac23edf79cd7e1fdd7f0e2cbc (diff) | |
download | llvm-843237f5731243b21762adf5bb77da0c4d884df2.zip llvm-843237f5731243b21762adf5bb77da0c4d884df2.tar.gz llvm-843237f5731243b21762adf5bb77da0c4d884df2.tar.bz2 |
DebugInfo: Move DILocation::computeNewDiscriminators()
As documented in PR23200 (and the FIXMEs I've added to the code here),
this logic is fairly broken: it modifies the `LLVMContext` in a way that
affects other modules and cannot be serialized to assembly/bitcode. For
now, move it over to `MDLocation::computeNewDiscriminators()` anyway.
llvm-svn: 234825
Diffstat (limited to 'llvm/lib/IR/DebugInfoMetadata.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfoMetadata.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index ed62062..1ad09da 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -66,6 +66,23 @@ MDLocation *MDLocation::getImpl(LLVMContext &Context, unsigned Line, Storage, Context.pImpl->MDLocations); } +unsigned MDLocation::computeNewDiscriminator() const { + // FIXME: This seems completely wrong. + // + // 1. If two modules are generated in the same context, then the second + // Module will get different discriminators than it would have if it were + // generated in its own context. + // 2. If this function is called after round-tripping to bitcode instead of + // before, it will give a different (and potentially incorrect!) return. + // + // The discriminator should instead be calculated from local information + // where it's actually needed. This logic should be moved to + // AddDiscriminators::runOnFunction(), where it doesn't pollute the + // LLVMContext. + std::pair<const char *, unsigned> Key(getFilename().data(), getLine()); + return ++getContext().pImpl->DiscriminatorTable[Key]; +} + unsigned DebugNode::getFlag(StringRef Flag) { return StringSwitch<unsigned>(Flag) #define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME) |