forked from OSchip/llvm-project
Move discriminator assignment to the right place.
Summary: Now discriminator is assigned per-function instead of per-module. Reviewers: davidxl, dnovillo Subscribers: dblaikie, llvm-commits Differential Revision: http://reviews.llvm.org/D17664 llvm-svn: 262240
This commit is contained in:
parent
522b5cb375
commit
939993ff2f
|
@ -1192,15 +1192,6 @@ public:
|
||||||
/// instructions that are on different basic blocks.
|
/// instructions that are on different basic blocks.
|
||||||
inline unsigned getDiscriminator() const;
|
inline unsigned getDiscriminator() const;
|
||||||
|
|
||||||
/// \brief Compute new discriminator in the given context.
|
|
||||||
///
|
|
||||||
/// This modifies the \a LLVMContext that \c this is in to increment the next
|
|
||||||
/// discriminator for \c this's line/filename combination.
|
|
||||||
///
|
|
||||||
/// FIXME: Delete this. See comments in implementation and at the only call
|
|
||||||
/// site in \a AddDiscriminators::runOnFunction().
|
|
||||||
unsigned computeNewDiscriminator() const;
|
|
||||||
|
|
||||||
Metadata *getRawScope() const { return getOperand(0); }
|
Metadata *getRawScope() const { return getOperand(0); }
|
||||||
Metadata *getRawInlinedAt() const {
|
Metadata *getRawInlinedAt() const {
|
||||||
if (getNumOperands() == 2)
|
if (getNumOperands() == 2)
|
||||||
|
|
|
@ -66,23 +66,6 @@ DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
|
||||||
Storage, Context.pImpl->DILocations);
|
Storage, Context.pImpl->DILocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DILocation::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 DINode::getFlag(StringRef Flag) {
|
unsigned DINode::getFlag(StringRef Flag) {
|
||||||
return StringSwitch<unsigned>(Flag)
|
return StringSwitch<unsigned>(Flag)
|
||||||
#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
|
#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
|
||||||
|
|
|
@ -173,8 +173,10 @@ bool AddDiscriminators::runOnFunction(Function &F) {
|
||||||
typedef std::pair<StringRef, unsigned> Location;
|
typedef std::pair<StringRef, unsigned> Location;
|
||||||
typedef DenseMap<const BasicBlock *, Metadata *> BBScopeMap;
|
typedef DenseMap<const BasicBlock *, Metadata *> BBScopeMap;
|
||||||
typedef DenseMap<Location, BBScopeMap> LocationBBMap;
|
typedef DenseMap<Location, BBScopeMap> LocationBBMap;
|
||||||
|
typedef DenseMap<Location, unsigned> LocationDiscriminatorMap;
|
||||||
|
|
||||||
LocationBBMap LBM;
|
LocationBBMap LBM;
|
||||||
|
LocationDiscriminatorMap LDM;
|
||||||
|
|
||||||
// Traverse all instructions in the function. If the source line location
|
// Traverse all instructions in the function. If the source line location
|
||||||
// of the instruction appears in other basic block, assign a new
|
// of the instruction appears in other basic block, assign a new
|
||||||
|
@ -199,8 +201,7 @@ bool AddDiscriminators::runOnFunction(Function &F) {
|
||||||
auto *Scope = DIL->getScope();
|
auto *Scope = DIL->getScope();
|
||||||
auto *File =
|
auto *File =
|
||||||
Builder.createFile(DIL->getFilename(), Scope->getDirectory());
|
Builder.createFile(DIL->getFilename(), Scope->getDirectory());
|
||||||
NewScope = Builder.createLexicalBlockFile(
|
NewScope = Builder.createLexicalBlockFile(Scope, File, ++LDM[L]);
|
||||||
Scope, File, DIL->computeNewDiscriminator());
|
|
||||||
}
|
}
|
||||||
I.setDebugLoc(DILocation::get(Ctx, DIL->getLine(), DIL->getColumn(),
|
I.setDebugLoc(DILocation::get(Ctx, DIL->getLine(), DIL->getColumn(),
|
||||||
NewScope, DIL->getInlinedAt()));
|
NewScope, DIL->getInlinedAt()));
|
||||||
|
@ -230,8 +231,10 @@ bool AddDiscriminators::runOnFunction(Function &F) {
|
||||||
auto *Scope = FirstDIL->getScope();
|
auto *Scope = FirstDIL->getScope();
|
||||||
auto *File = Builder.createFile(FirstDIL->getFilename(),
|
auto *File = Builder.createFile(FirstDIL->getFilename(),
|
||||||
Scope->getDirectory());
|
Scope->getDirectory());
|
||||||
auto *NewScope = Builder.createLexicalBlockFile(
|
Location L =
|
||||||
Scope, File, FirstDIL->computeNewDiscriminator());
|
std::make_pair(FirstDIL->getFilename(), FirstDIL->getLine());
|
||||||
|
auto *NewScope =
|
||||||
|
Builder.createLexicalBlockFile(Scope, File, ++LDM[L]);
|
||||||
Current->setDebugLoc(DILocation::get(
|
Current->setDebugLoc(DILocation::get(
|
||||||
Ctx, CurrentDIL->getLine(), CurrentDIL->getColumn(), NewScope,
|
Ctx, CurrentDIL->getLine(), CurrentDIL->getColumn(), NewScope,
|
||||||
CurrentDIL->getInlinedAt()));
|
CurrentDIL->getInlinedAt()));
|
||||||
|
|
Loading…
Reference in New Issue