Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable support of non-instrinsic debug-info #12768

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/IR/BasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cl::opt<bool>
UseNewDbgInfoFormat("experimental-debuginfo-iterators",
cl::desc("Enable communicating debuginfo positions "
"through iterators, eliminating intrinsics"),
cl::init(false)); // INTEL
cl::init(true));

DPMarker *BasicBlock::createMarker(Instruction *I) {
assert(IsNewDbgInfoFormat &&
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/IR/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,10 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
if (Ty->getNumParams())
setValueSubclassData(1); // Set the "has lazy arguments" bit.

if (ParentModule)
if (ParentModule) {
ParentModule->getFunctionList().push_back(this);
IsNewDbgInfoFormat = ParentModule->IsNewDbgInfoFormat;
}

HasLLVMReservedName = getName().starts_with("llvm.");
// Ensure intrinsics have the right parameter attributes.
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/IR/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,9 @@ FunctionCallee Module::getOrInsertFunction(StringRef Name, FunctionType *Ty,
if (!F) {
// Nope, add it
Function *New = Function::Create(Ty, GlobalVariable::ExternalLinkage,
DL.getProgramAddressSpace(), Name);
DL.getProgramAddressSpace(), Name, this);
if (!New->isIntrinsic()) // Intrinsics get attrs set on construction
New->setAttributes(AttributeList);
FunctionList.push_back(New);
return {Ty, New}; // Return the new prototype.
}

Expand Down
11 changes: 7 additions & 4 deletions llvm/lib/Transforms/IPO/IROutliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,12 @@ static void moveFunctionData(Function &Old, Function &New,
std::vector<Instruction *> DebugInsts;

for (Instruction &Val : CurrBB) {
// Since debug-info originates from many different locations in the
// program, it will cause incorrect reporting from a debugger if we keep
// the same debug instructions. Drop non-intrinsic DPValues here,
// collect intrinsics for removal later.
Val.dropDbgValues();

// We must handle the scoping of called functions differently than
// other outlined instructions.
if (!isa<CallInst>(&Val)) {
Expand All @@ -744,10 +750,7 @@ static void moveFunctionData(Function &Old, Function &New,
// From this point we are only handling call instructions.
CallInst *CI = cast<CallInst>(&Val);

// We add any debug statements here, to be removed after. Since the
// instructions originate from many different locations in the program,
// it will cause incorrect reporting from a debugger if we keep the
// same debug instructions.
// Collect debug intrinsics for later removal.
if (isa<DbgInfoIntrinsic>(CI)) {
DebugInsts.push_back(&Val);
continue;
Expand Down
Loading