This is an archive of the discontinued LLVM Phabricator instance.

Omitting debug info function entry for functions that has no code.
Needs ReviewPublic

Authored by aaboud on Aug 27 2015, 11:39 PM.

Details

Reviewers
dblaikie
Summary

Stopped emitting function debug info if that function has no code (or alternatively, has no code associated with debug info).
Modified few LIT tests due to this change.

This patch is needed for "D11180" and should be committed first.

Diff Detail

Repository
rL LLVM

Event Timeline

aaboud updated this revision to Diff 33397.Aug 27 2015, 11:39 PM
aaboud retitled this revision from to Omitting debug info function entry for functions that has no code..
aaboud updated this object.
aaboud added a reviewer: dblaikie.
aaboud set the repository for this revision to rL LLVM.
aaboud added a subscriber: llvm-commits.

I assume that a function without code will never get inlined, so this should not cause a problem with inlining.
David, could this affect overload resolution if it is a C++ method that is being eliminated?

Hmm? What's the motivation here?

-eric

Hmm? What's the motivation here?

-eric

As I said, we need this for the fix in D11180.
The example we are trying to fix is:
void f1() {

while (true) {
  struct nested {
    static void f2() {}
  };
  nested::f2();
}

}

Once we start supporting lexical block context for local types (i.e. the structure "nested" in the example), we assume that if a local type is needed, there must be a code in the lexical block containing that type or any of its nested blocks.
LexicalScopes component will handle any lexical block that contains code (directly or indirectly), but will skip those that does not have code.

In the above example (when compiled with "-inline") the lexical block "while" will contain no code, and thus will not be handled or emitted.
However, at endModule, we still try to emit an entry for the "nested::f2" function, even though there is no code associated to this function.
Doing that lead us trying to emit an entry for the structure "nested" because "f2" is a method in that structure, and there is where we will fail, because the lexical block "while" was not handled or created.

I discussed this with David, and suggested that we stop emitting such functions that has no association for source line, user will not be able to break in them anyway...

So, this is the reason for this patch.
Now the question would be: "is there any reason why we should not omit debug info for these functions?"