Commit Graph

1085 Commits

Author SHA1 Message Date
Nico Weber 7123bca7fb Fix debug info for Objective-C properties from class extensions after r251874
After r251874, properties from class extensions no longer show up in
ObjCInterfaceDecl::properties().  Make debug info emission explicitly
look for properties in class extensions before looking at direct properties.

Also add a test that checks for this.  There are three interesting cases:

1. A property is only declared in a class extension, and the @implementation
   is in a different file.  This used to generated a DIObjcProperty before
   r251874 and does again with this fix.

2. A property is declared as readonly in the class itself and redeclared as
   readwrite in a class extension. clang before r251874 put the DIObjcProperty
   on the first declaration. clang after r251874 didn't emit any DIObjcProperty,
   and clang with this fix puts it on the readwrite redeclaration (which is
   what lookup finds).  This seems like a progression.

3. Like 2, but with an @implementation in the same file.  In this case,
   the property debug info gets generated a second time through the ivar
   from the definition.  In this case, lookup and declaration code need
   to agree on the line number so that the DIObjcProperty isn't emitted
   twice.  In this case, clang before r251874 emitted one DIObjcProperty
   on the first declaration, clang with r251874 emitted one on the second
   declaration, and clang with this patch still does the latter.

llvm-svn: 254750
2015-12-04 19:14:14 +00:00
Reid Kleckner 43ecd7c71d [DebugInfo] Look through type sugar on union types when casting
Fixes PR25584.

llvm-svn: 253680
2015-11-20 17:41:12 +00:00
Keno Fischer 87842f3b4e [CGDebugInfo] Set the size and align for reference types
In r253186, I changed the DIBuilder API to now take size and align
for reference types as well. This was done in preparation for upcoming
changes to the Verifier that will validate that sizes match between
DI types and IR values that are declared as having those types.
This updates clang to actually pass the information through.

llvm-svn: 253190
2015-11-16 09:04:13 +00:00
Peter Collingbourne 0900fe0f1b CodeGen: Update for debug info API change.
Differential Revision: http://reviews.llvm.org/D14266

llvm-svn: 252220
2015-11-05 22:04:14 +00:00
Douglas Gregor acf4fd3039 Stop back-patching 'readonly' Objective-C properties with 'readwrite' ones.
A 'readonly' Objective-C property declared in the primary class can
effectively be shadowed by a 'readwrite' property declared within an
extension of that class, so long as the types and attributes of the
two property declarations are compatible.

Previously, this functionality was implemented by back-patching the
original 'readonly' property to make it 'readwrite', destroying source
information and causing some hideously redundant, incorrect
code. Simplify the implementation to express how this should actually
be modeled: as a separate property declaration in the extension that
shadows (via the name lookup rules) the declaration in the primary
class. While here, correct some broken Fix-Its, eliminate a pile of
redundant code, clean up the ARC migrator's handling of properties
declared in extensions, and fix debug info's naming of methods that
come from categories.

A wonderous side effect of doing this write is that it eliminates the
"AddedObjCPropertyInClassExtension" method from the AST mutation
listener, which in turn eliminates the last place where we rewrite
entire declarations in a chained PCH file or a module file. This
change (which fixes rdar://problem/18475765) will allow us to
eliminate the rewritten-decls logic from the serialization library,
and fixes a crash (rdar://problem/23247794) illustrated by the
test/PCH/chain-categories.m example.

llvm-svn: 251874
2015-11-03 01:15:46 +00:00
Benjamin Kramer c2d2b4259c [CodeGen] Remove dead code. NFC.
llvm-svn: 250418
2015-10-15 15:29:40 +00:00
Eric Christopher 28a6db5929 Update clang for DIBuilder::createSubroutineType API change.
Patch by Amaury Sechet!

llvm-svn: 250373
2015-10-15 06:56:08 +00:00
Saleem Abdulrasool 436256a713 Support Debug Info path remapping
Add support for the `-fdebug-prefix-map=` option as in GCC.  The syntax is
`-fdebug-prefix-map=OLD=NEW`.  When compiling files from a path beginning with
OLD, change the debug info to indicate the path as start with NEW.  This is
particularly helpful if you are preprocessing in one path and compiling in
another (e.g. for a build cluster with distcc).

Note that the linearity of the implementation is not as terrible as it may seem.
This is normally done once per file with an expectation that the map will be
small (1-2) entries, making this roughly linear in the number of input paths.

Addresses PR24619.

llvm-svn: 250094
2015-10-12 20:21:08 +00:00
Adrian Prantl f0cd677b17 Module Debugging: Emit (ObjC) function declarations in the module scope
when building a module.

llvm-svn: 249282
2015-10-04 23:23:04 +00:00
Adrian Prantl 335f5c7e3e Module debugging: Don't emit forward declarations in module scopes.
A forward declaration inside a module header does not belong to the module.

llvm-svn: 249157
2015-10-02 17:36:14 +00:00
Adrian Prantl 7f30b4a14e Remove unused variable.
llvm-svn: 249155
2015-10-02 17:36:03 +00:00
Adrian Prantl 42ce2d3ba3 Module debugging: Also emit Objective-C interfaces forward declarations
in their module scope when building a clang module.

llvm-svn: 249031
2015-10-01 16:57:02 +00:00
Adrian Prantl fd69611c8e Module debugging: Emit Objective-C interfaces in their module scope when
building a clang module.

llvm-svn: 248974
2015-10-01 00:48:51 +00:00
Adrian Prantl 9e8ea3599e CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may
be modified in between. (NFC)

llvm-svn: 248826
2015-09-29 20:44:46 +00:00
Adrian Prantl 835e6633ab Module Debugging: Emit submodules as nested DW_TAG_modules.
llvm-svn: 248511
2015-09-24 16:10:10 +00:00
Adrian Prantl eb66a263c2 Debug Info: Use the module pointer as key for the module cache.
This way we don't need to rebuild the full module name for every decl.

llvm-svn: 248510
2015-09-24 16:10:04 +00:00
Adrian Prantl 6083b08580 Refactor ASTSourceDescriptor to not store copies of all strings. (NFC)
llvm-svn: 248509
2015-09-24 16:10:00 +00:00
Adrian Prantl a5206ce72a Module Debugging: Use the clang module signature as the module's dwo_id
when building a module. Clang already records the module signature when
building a skeleton CU to reference a clang module.

Matching the id in the skeleton with the one in the module allows a DWARF
consumer to verify that they found the correct version of the module
without them needing to know about the clang module format.

llvm-svn: 248345
2015-09-22 23:26:43 +00:00
Adrian Prantl 85d938aadb Debug Info: When building a module, emit skeleton CUs for imported modules.
llvm-svn: 248184
2015-09-21 17:48:37 +00:00
Adrian Prantl 9402cef0ae Module debugging: Support submodules in the PCM/PCH debug info.
llvm-svn: 248127
2015-09-20 16:51:35 +00:00
Adrian Prantl 2f957ac092 Further simplify CGDebugInfo::getOrCreateModuleRef().
DIBuilder ignoers DICompileUnits that are passed in as scopes anyway.

llvm-svn: 248077
2015-09-19 00:59:22 +00:00
Adrian Prantl 2d3d6dfe1c Rename ASTSourceDescriptor::ModuleName to FullModuleName for clarity.
llvm-svn: 248070
2015-09-19 00:10:37 +00:00
Adrian Prantl c6458d6a4d Refactor ASTReader::getSourceDescriptor(const Module &) into a constructor
of ASTSourceDescriptor. It was effectively a static function.

NFC.

llvm-svn: 248069
2015-09-19 00:10:32 +00:00
Adrian Prantl 666892051c CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.
We don't want a skeleton CU when generating debug info for the module
itself.

NFC.

llvm-svn: 248062
2015-09-18 23:01:45 +00:00
Adrian Prantl 201e10d007 Debug Info: Use the full module name as a key when caching DIModules.
The signature may not have been computed at the time the module reference
is generated (e.g.: in the future while emitting debug info for a clang
module). Using the full module name is safe because each clang module may
only have a single definition.

NFC.

llvm-svn: 248037
2015-09-18 21:06:14 +00:00
Alexey Bader 9c8453fb4b [OpenCL] Add new types for OpenCL 2.0.
Patch by Pedro Ferreira.
Reviewers: pekka.jaaskelainen
Differential Revision: http://reviews.llvm.org/D12855

llvm-svn: 247676
2015-09-15 11:18:52 +00:00
Adrian Prantl 453cdf08a2 Remove an unnecessary check. NFC
llvm-svn: 247448
2015-09-11 18:54:31 +00:00
Adrian Prantl 5d66c6bbb9 Remove a redundant check from CGDebugInfo::shouldOmitDefinition() (NFC).
llvm-svn: 247447
2015-09-11 18:54:28 +00:00
Adrian Prantl b67dbced9c Cleanup: Get rid of a bunch of unnecessary invocations of internString()
in CGDebugInfo.cpp: MDString::get() copies its arguments.

llvm-svn: 247445
2015-09-11 18:45:02 +00:00
Adrian Prantl 5c8bd88a4c Module Debugging: Emit forward declarations for types that are defined in
clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.

This reimplements r247369 in about a third of the amount of code.
Thanks to David Blaikie pointing this out in post-commit review!

llvm-svn: 247432
2015-09-11 17:23:08 +00:00
Adrian Prantl ca8441810f Revert "Module Debugging: Emit forward declarations for types that are defined in"
This reverts commit r247369 to facilitate reviewing of the following patch.

llvm-svn: 247431
2015-09-11 17:23:03 +00:00
Adrian Prantl 49553dd269 Module Debugging: Emit forward declarations for types that are defined in
clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.

llvm-svn: 247369
2015-09-11 01:03:26 +00:00
Adrian Prantl d0929a1c87 Cleanup: Let CGDebugInfo::ModuleRefCache use a TrackingMDNode (NFC).
llvm-svn: 247368
2015-09-11 01:03:19 +00:00
David Majnemer 9df56372e8 [MS ABI] Make member pointers return true for isIncompleteType
The type of a member pointer is incomplete if it has no inheritance
model.  This lets us reuse more general logic already embedded in clang.

llvm-svn: 247346
2015-09-10 21:52:00 +00:00
Adrian Prantl 6ec370a4ed Add a getDeclContextDescriptor() helper function to CGDebugInfo. (NFC)
llvm-svn: 247319
2015-09-10 18:39:45 +00:00
Adrian Prantl ab010c4e0e Remove unneeded #include.
llvm-svn: 247081
2015-09-08 22:06:40 +00:00
Adrian Prantl 748a6cd1ac Module Debugging: Emit debug type information into clang ObjC modules.
When -fmodule-format is set to "obj", emit debug info for all types
declared in a module or referenced by a declaration into the module's
object file container.

This patch adds support for Objective-C types and methods.

llvm-svn: 247068
2015-09-08 20:41:52 +00:00
Adrian Prantl 3a884fa9e3 CGDebugInfo: Instead of uniquing RetainedTypes, just refrain from retaining
them more than once. (NFC)

llvm-svn: 246231
2015-08-27 22:56:46 +00:00
Adrian Prantl ad9a195ee9 CGDebugInfo: Factor out a getOrCreateStandaloneType() method.
Usually debug info is created on the fly while during codegen.
With this API it becomes possible to create standalone debug info
for types that are not referenced by any code, such as emitting debug info
for a clang module or for implementing something like -gfull.
Because on-the-fly debug info generation may still insert retained types
on top of them, all RetainedTypes are uniqued in CGDebugInfo::finalize().

llvm-svn: 246210
2015-08-27 21:21:19 +00:00
Adrian Prantl 6b21ab21d1 Add a -gmodules option to the driver and a -dwarf-ext-refs to cc1
to enable the use of external type references in the debug info
(a.k.a. module debugging).

The driver expands -gmodules to "-g -fmodule-format=obj -dwarf-ext-refs"
and passes that to cc1. All this does at the moment is set a flag
codegenopts.

http://reviews.llvm.org/D11958

llvm-svn: 246192
2015-08-27 19:46:20 +00:00
Duncan P. N. Exon Smith 31d38f70ea DI: Clarify meaning of createTempFunctionFwdDecl() arg, NFC
I stared at `false /*declaration*/` for quite some time before giving up
and checking the actual function to see what it meant.  Replacing with
`/* isDefinition = */ false` to save myself effort later.

llvm-svn: 246095
2015-08-26 22:21:09 +00:00
Yaron Keren 556b21aa10 Remove and forbid raw_svector_ostream::flush() calls.
After r244870 flush() will only compare two null pointers and return,
doing nothing but wasting run time. The call is not required any more
as the stream and its SmallString are always in sync.

Thanks to David Blaikie for reviewing.

llvm-svn: 244928
2015-08-13 18:12:56 +00:00
David Blaikie d7057d9e52 Wdeprecated: ApplyDebugLocation is returned by value yet if it is ever copied (rather than RVO'd) that would be broken, make it movable instead
llvm-svn: 244838
2015-08-12 23:49:57 +00:00
Duncan P. N. Exon Smith e430654fd8 DI: Update for LLVM API change for local variables
Adjust to LLVM DIBuilder API changes in r243764, using
`createAutoVariable()` and `createParameterVariable()` in place of
`createLocalVariable()`.  No real functionality change here.

llvm-svn: 243765
2015-07-31 17:56:14 +00:00
Duncan P. N. Exon Smith bd210e638a DI: Make getOrCreateLimitedType() return DICompositeType, NFC
Change `getOrCreateLimitedType()` to return a `DICompositeType` and
remove the casts from its callers.  Inside, I've strengthened a `cast`
from `DICompositeTypeBase`, but the casts in the callers already prove
that this is safe.  There should be no functionality change here.

llvm-svn: 243155
2015-07-24 20:34:41 +00:00
Duncan P. N. Exon Smith ac346ba5a1 DI: Make StaticDataMemberCache type-safe, NFC
Change `StaticDataMemberCache` to store references to `DIDerivedType`
directly, and remove now-unnecessary casts from the accessors.

llvm-svn: 243129
2015-07-24 18:05:58 +00:00
Adrian Prantl 3e8bad42f3 Cleanup the doxygen comments in CGDebugInfo.cpp according to the coding
standards. Remove several hilariously out-of-date and redundant comments
and move the non-redundant ones into the header file.

llvm-svn: 241733
2015-07-08 21:18:34 +00:00
Adrian Prantl 3d2c051cf6 Debug info: Emit distinct __block_literal_generic types for blocks with
different function signatures. (Previously clang would emit all block
pointer types with the type of the first block pointer in the compile
unit.)

rdar://problem/21602473

llvm-svn: 241534
2015-07-07 00:49:35 +00:00
Adrian Prantl 498fff661d Debug info: Don't emit a bogus location for the global block pointer type
(__block_literal_generic).

The arbitrary nature of the location confuses lldb and prevents type
uniquing.

rdar://problem/21602473

llvm-svn: 241511
2015-07-06 21:31:35 +00:00
David Blaikie be822edf03 Revert "[DebugInfo] Fix debug info generation for function static variables, typedefs, and records"
Caused PR24008.

This reverts commit r241154.

llvm-svn: 241177
2015-07-01 18:07:22 +00:00
Michael Kuperstein def554db45 [DebugInfo] Fix debug info generation for function static variables, typedefs, and records
Function static variables, typedefs and records (class, struct or union) declared inside
a lexical scope were associated with the function as their parent scope, rather than the
lexical scope they are defined or declared in.

This fixes PR19238

Patch by: amjad.aboud@intel.com
Differential Revision: http://reviews.llvm.org/D9760

llvm-svn: 241154
2015-07-01 12:34:39 +00:00
Adrian Prantl 2388eadbd8 Use an early exit to improve readability. (NFC)
llvm-svn: 241088
2015-06-30 18:01:05 +00:00
Adrian Prantl c4bb47e301 Debug Info: Emit debug info for @import declarations.
This allows a module-aware debugger such as LLDB to import the currently
visible modules before dropping into the expression evaluator.

rdar://problem/20965932

llvm-svn: 241084
2015-06-30 17:39:51 +00:00
Paul Robinson 6a7511bea9 Omit 'nodebug' methods from the class description.
llvm-svn: 240664
2015-06-25 17:50:43 +00:00
David Majnemer e2be95b55b [CodeGen] Rename EmitMemberPointer to EmitMemberFunctionPointer
llvm-svn: 240382
2015-06-23 07:31:01 +00:00
Adrian Prantl c6f91a2081 Debug Info: Turn on ODR type uniquing for (the C++ part of) Objective-C++.
rdar://problem/20571359

llvm-svn: 239781
2015-06-15 23:18:16 +00:00
David Majnemer 34568bc602 [MS ABI, DebugInfo] Omit the size for model-less pointers-to-members
The representation of a pointer-to-member in the MS ABI is governed by
the layout of the relevant class or if a model has been explicitly
specified.  If no model is specified, then an appropriate
"worst-case-scenario" model is implicitly chosen if, and only, if the
pointer-to-member type's representation was needed.

Debug info cannot force a pointer-to-member type to have a
representation so do not try to query the size of such a type unless we
know it is safe to do so.

llvm-svn: 238259
2015-05-26 21:54:24 +00:00
Adrian Prantl be81cf570e Debug info: Adapt to new DIBuilder interface.
llvm-svn: 237948
2015-05-21 20:37:26 +00:00
Adrian Prantl 00820abf02 Debug Info: Represent local anonymous unions as anonymous unions
and as artificial local variables in the debug info.

This is a follow-up to r236059. We can't get rid of the local variables
entirely because the gdb buildbot depends on them, but we can mark them
as artificial while still emitting the correct debug info. As I learned
from review comments other compilers also follow this model.

A paired commit in LLVM temporarily relaxes the debug info verifier to
not check the integrity of DW_OP_bit_pieces of artificial variables.

rdar://problem/20730771

llvm-svn: 236125
2015-04-29 16:52:31 +00:00
Duncan P. N. Exon Smith 9dd4e4e63a DebugInfo: Metadata constructs now start with DI*
LLVM r236120 renamed debug info IR constructs to use a `DI` prefix, now
that the `DIDescriptor` hierarchy has been gone for about a week.  This
commit was generated using the rename-md-di-nodes.sh upgrade script
attached to PR23080, followed by running clang-format-diff.py on the
`lib/` portion of the patch.

llvm-svn: 236121
2015-04-29 16:40:08 +00:00
Adrian Prantl 0d82089233 Revert "Debug Info: Represent local anonymous unions as anonymous unions"
This reverts commit r236059 as it breaks the gdb buildbot.

llvm-svn: 236110
2015-04-29 15:05:50 +00:00
Adrian Prantl 0a4ddc180b Debug Info: Represent local anonymous unions as anonymous unions
in the debug info. This patch deletes a hack that emits the members
of local anonymous unions as local variables.

Besides being morally wrong, the existing representation using local
variables breaks internal assumptions about the local variables' storage
size.

Compiling

```
   void fn1() {
     union {
       int i;
       char c;
     };
     i = c;
   }

```

with -g -O3 -verify will cause the verifier to fail after SROA splits
the 32-bit storage for the "local variable" c into two pieces because the
second piece is clearly outside the 8-bit range that is expected for a
variable of type char. Given the choice I'd rather fix the debug
representation than weaken the verifier.

Debuggers generally already know how to deal with anonymous unions when
they are members of C++ record types, but they may have problems finding
the local anonymous struct members in the expression evaluator.

rdar://problem/20730771

llvm-svn: 236059
2015-04-28 23:01:24 +00:00
David Majnemer 5fd33e0d1a Replace getPointeeType()->isFunctionType with isMemberDataPointerType
llvm-svn: 235682
2015-04-24 01:25:08 +00:00
Duncan P. N. Exon Smith 8e47da4f5b DebugInfo: Prepare for removal of DIArray and DITypeArray typedefs
An upcoming LLVM commit will remove the `DIArray` and `DITypeArray`
typedefs that shadow `DebugNodeArray` and `MDTypeRefArray`,
respectively.  Use those types directly.

llvm-svn: 235412
2015-04-21 20:07:29 +00:00
Duncan P. N. Exon Smith dadc2b627d DebugInfo: Prepare for deletion of DIDescriptor subclasses
An upcoming LLVM commit will delete all the remaining subclasses of (the
already deleted) `DIDescriptor`.  Stop using them.

llvm-svn: 235403
2015-04-21 18:43:54 +00:00
Duncan P. N. Exon Smith a7fbcbfe00 DebugInfo: Prepare for deletion of subclasses of DIScope
Prepare for the deletion in LLVM of the subclasses of (the already
deleted) `DIScope` by using the raw pointers they were wrapping
directly.

llvm-svn: 235355
2015-04-20 22:09:57 +00:00
Duncan P. N. Exon Smith c09c548bf9 DebugInfo: Prepare for deletion of subclasses of DIType
Subclasses of (the already deleted) `DIType` will be deleted by an
upcoming LLVM commit.  Remove references.

While `DICompositeType` wraps `MDCompositeTypeBase` and `DIDerivedType`
wraps `MDDerivedTypeBase`, most uses of each really meant the more
specific `MDCompositeType` and `MDDerivedType`.  I updated accordingly.

llvm-svn: 235350
2015-04-20 21:17:26 +00:00
Duncan P. N. Exon Smith 0b6c369697 DebugInfo: Prepare for deletion of DIType
`DIType` is going to be deleted by an upcoming LLVM commit, so replace
uses with `MDType*`.

llvm-svn: 235330
2015-04-20 18:51:48 +00:00
Duncan P. N. Exon Smith fc8d9d9a20 DebugInfo: Prepare for deletion of DIScope
An upcoming LLVM commit will delete `DIScope`, so update users to
`MDScope*`.

llvm-svn: 235326
2015-04-20 18:32:15 +00:00
Duncan P. N. Exon Smith d899f6e4de DebugInfo: Prepare for deletion of DIDescriptor
Prepare for upcoming LLVM change to delete `DIDescriptor`.

llvm-svn: 235245
2015-04-18 00:07:30 +00:00
Duncan P. N. Exon Smith 4078ad4122 DebugInfo: Update for LLVM API change in DIBuilder (r235111)
LLVM r235111 changed the `DIBuilder` API to stop using `DIDescriptor`
and its subclasses.  Rolled into this was some tightening up of types:

  - Scopes: `DIDescriptor` => `MDScope*`.
  - Generic debug nodes: `DIDescriptor` => `DebugNode*`.
  - Subroutine types: `DICompositeType` => `MDSubroutineType*`.
  - Composite types: `DICompositeType` => `MDCompositeType*`.

Note that `DIDescriptor` wraps `MDNode`, and `DICompositeType` wraps
`MDCompositeTypeBase`.

It's this new type strictness that requires changes here.

llvm-svn: 235112
2015-04-16 16:36:45 +00:00
Duncan P. N. Exon Smith 526ab07e3c DebugInfo: Prepare for DIDescriptor to be gutted in LLVM
All the API is about to be dropped from `DIDescriptor` in LLVM, so stop
using it.

llvm-svn: 235068
2015-04-16 01:53:23 +00:00
Duncan P. N. Exon Smith 373ee85966 DebugInfo: Prepare for DIScope to be gutted in LLVM
An upcoming LLVM commit will gut `DIScope`, so just use `MDScope*`
directly.

llvm-svn: 235066
2015-04-16 01:36:36 +00:00
Duncan P. N. Exon Smith 4caa7f2a9c DebugInfo: Prepare for DIType to be gutted
`DIType` and its subclasses are about to be gutted in LLVM.  Prepare for
that by treating these like the raw pointers they wrap.

llvm-svn: 235063
2015-04-16 01:00:56 +00:00
Duncan P. N. Exon Smith b747023081 DebugInfo: Prepare for LLVM change removing DIType::isValid()
This is being replaced with a null check.

llvm-svn: 235058
2015-04-15 23:48:50 +00:00
Duncan P. N. Exon Smith 798d565fd8 DebugInfo: Prepare for LLVM gutting DICompileUnit/DIFile
An upcoming LLVM commit will gut `DICompileUnit` and `DIFile`, so start
treating them more like pointers.

llvm-svn: 235054
2015-04-15 23:19:15 +00:00
Duncan P. N. Exon Smith fe88b48632 DebugInfo: Pass DebugLocs when creating intrinsics
Update for LLVM API change r235041 that makes `DIBuilder` require a
`DebugLoc` to create a debug info intrinsic.

llvm-svn: 235042
2015-04-15 21:18:30 +00:00
Duncan P. N. Exon Smith 87afdeb8f5 DebugInfo: Prepare for DISubprogram/DILexicalBlock* to be gutted
An upcoming LLVM commit will remove this API, so stop using it.  Just
access the raw pointers using `operator->()`.

llvm-svn: 234848
2015-04-14 03:24:14 +00:00
Duncan P. N. Exon Smith 497d4d465b DebugInfo: Switch from replaceAllUsesWith() to replaceTemporary()
Stop using `DIDescriptor`'s wrapper around
`MDNode::replaceAllUsesWith()` (which is going away).  The new home for
this logic is `DIBuilder::replaceTemporary()`, added in LLVM r234695.

llvm-svn: 234696
2015-04-11 19:05:04 +00:00
Duncan P. N. Exon Smith 373285892b Revert "Fix a compiler error under MSVC"
This reverts the bandaid commit in r234308 now that I have a proper fix
in LLVM as of r234326.

llvm-svn: 234339
2015-04-07 18:41:26 +00:00
Duncan P. N. Exon Smith ebad0aa3ba DebugInfo: LLVM API change in r234326 for array-like tuple wrappers
Update a few calls to `DIBuilder` now that `MDTuple` array-wrappers
don't have implicit conversions to `MDTuple*`.  I may circle back and
update `DIBuilder` to take arrays here, to make it easier for the
callers.

llvm-svn: 234327
2015-04-07 16:50:49 +00:00
Timur Iskhodzhanov 90639edd3d Fix a compiler error under MSVC
Error message was:
CGDebugInfo.cpp(1047) : error C2666: 'llvm::MDTypeRefArray::operator []' : 2 overloads have similar conversions
  DebugInfoMetadata.h(106): could be 'llvm::MDTypeRef llvm::MDTypeRefArray::operator [](unsigned int) const'
  while trying to match the argument list '(llvm::DITypeArray, int)'

llvm-svn: 234308
2015-04-07 11:26:00 +00:00
Duncan P. N. Exon Smith a98fac64ea DebugInfo: Update for LLVM change in r234290
The API for `DIArray` changed; use the new one.

llvm-svn: 234291
2015-04-07 04:14:45 +00:00
Duncan P. N. Exon Smith c755128673 CGDebugInfo: Stop using DIDescriptor::is*() and auto-casting
The clang edition of r234255: use built-in `isa<>`, `dyn_cast<>`, etc.,
and only build `DIDescriptor`s from pointers that are correctly typed.

llvm-svn: 234256
2015-04-06 23:21:33 +00:00
Duncan P. N. Exon Smith ee55fac1d4 DebugInfo: Use DILexicalBlockFile::getContext() over getScope()
`getScope()` passes the scope back through a `DILexicalBlock` even
though the underlying pointer may be an incompatible `MDSubprogram`.
Just use `getContext()` directly.

llvm-svn: 234245
2015-04-06 22:04:18 +00:00
Duncan P. N. Exon Smith 2809cc7493 DebugInfo: Use new LLVM API for DebugLoc
Use the new API for `DebugLoc` added in r233573 before the old one
disappears.

llvm-svn: 233589
2015-03-30 20:01:41 +00:00
Duncan P. N. Exon Smith 5043f91657 DebugInfo: Don't call DIBuilder::retainType(nullptr)
An upcoming LLVM commit will make calling
`DIBuilder::retainType(nullptr)` illegal (actually, it already was, but
it wasn't verified).  Check for null before calling.

This triggered in test/CodeGenObjC/debug-info-block-helper.m.

llvm-svn: 233443
2015-03-27 22:58:05 +00:00
Duncan P. N. Exon Smith 7ea96c222f DebugInfo: Check for null before using DIType
A WIP patch to turn on stricter `DIDescriptor` accessor checks fires
here; it's obvious from the code that `T` can be null, so add an
explicit check.  Caught by dozens of current testcases.

llvm-svn: 232791
2015-03-20 00:53:40 +00:00
Peter Collingbourne d251b0a60e DebugInfo: Give externally defined types a size and alignment where
possible. Fixes PR22736.

llvm-svn: 230914
2015-03-01 22:07:04 +00:00
Saleem Abdulrasool cd187f033e DebugInfo: hoist definition into global context when needed
When generating debug info for a static inline member which is initialized for
the DLLExport storage class, hoist the definition into a non-composite type
context. Otherwise, we would trigger an assertion when generating the DIE for
the associated global value as the debug context has a type association. This
addresses PR22669.

Thanks to David Blakie for help in coming up with a solution to this!

llvm-svn: 230816
2015-02-28 00:13:13 +00:00
Duncan P. N. Exon Smith a346e03084 CGDebugInfo: Use DIImportedEntity default constructor, NFC
Use the newly minted `DIImportedEntity` default constructor (r230609)
rather than explicitly specifying `nullptr`.  The latter will become
ambiguous when the new debug info hierarchy is committed, since we'll
have both of the following:

    explicit DIImportedEntity(const MDNode *);
    DIImportedEntity(const MDImportedEntity *);

(Currently we just have the former.)

A default constructor is just as clear.

llvm-svn: 230610
2015-02-26 04:44:27 +00:00
Adrian Prantl 5f66bae411 Fix PR19351. While building up a composite type it is important to use
a non-uniqueable temporary node that is only turned into a permanent
unique or distinct node after it is finished.
Otherwise an intermediate node may get accidentally uniqued with another
node as illustrated by the testcase.

Paired commit with LLVM.

llvm-svn: 228855
2015-02-11 17:45:15 +00:00
Benjamin Kramer 0327866a53 CodeGen: Move DebugLocs.
It's slightly cheaper than copying it, if the DebugLoc points to replaceable
metadata every copy is recorded in a DenseMap, moving reduces the peak size of
that map.

llvm-svn: 228492
2015-02-07 13:15:54 +00:00
David Blaikie 4d52443c0e DebugInfo: Attribute cleanup code to the end of the scope, not the end of the function.
Now if you break on a dtor and go 'up' in your debugger (or you get an
asan failure in a dtor) during an exception unwind, you'll have more
context. Instead of all dtors appearing to be called from the '}' of the
function, they'll be attributed to the end of the scope of the variable,
the same as the non-exceptional dtor call.

This doesn't /quite/ remove all uses of CurEHLocation (which might be
nice to remove, for a few reasons) - it's still used to choose the
location for some other work in the landing pad. It'd be nice to
attribute that code to the same location as the exception calls within
the block and to remove CurEHLocation.

llvm-svn: 228181
2015-02-04 19:47:54 +00:00
Duncan P. N. Exon Smith f796a1ded0 CodeGen: Update for LLVM API change in r228030
The mock tags are no longer in `dwarf::LLVMConstants`; they're in
`dwarf::Tag`.

llvm-svn: 228032
2015-02-03 21:25:34 +00:00
Adrian Prantl 95b24e9b59 Address review feedback for r228003.
- use named constructors
- get rid of MarkAsPrologue

llvm-svn: 228021
2015-02-03 20:00:54 +00:00
Adrian Prantl 39428e74a0 Merge ArtificialLocation into ApplyDebugLocation and make a clear
distinction between the different use-cases. With the previous default
behavior we would occasionally emit empty debug locations in situations
where they actually were strictly required (= on invoke insns).
We now have a choice between defaulting to an empty location or an
artificial location.

Specifically, this fixes a bug caused by a missing debug location when
emitting C++ EH cleanup blocks from within an artificial function, such as
an ObjC destroy helper function.

rdar://problem/19670595

llvm-svn: 228003
2015-02-03 18:40:42 +00:00
David Blaikie 9b47966615 DebugInfo: Use the preferred location rather than the start location for expression line info
This causes things like assignment to refer to the '=' rather than the
LHS when attributing the store instruction, for example.

There were essentially 3 options for this:

* The beginning of an expression (this was the behavior prior to this
  commit). This meant that stepping through subexpressions would bounce
  around from subexpressions back to the start of the outer expression,
  etc. (eg: x + y + z would go x, y, x, z, x (the repeated 'x's would be
  where the actual addition occurred)).

* The end of an expression. This seems to be what GCC does /mostly/, and
  certainly this for function calls. This has the advantage that
  progress is always 'forwards' (never jumping backwards - except for
  independent subexpressions if they're evaluated in interesting orders,
  etc). "x + y + z" would go "x y z" with the additions occurring at y
  and z after the respective loads.
  The problem with this is that the user would still have to think
  fairly hard about precedence to realize which subexpression is being
  evaluated or which operator overload is being called in, say, an asan
  backtrace.

* The preferred location or 'exprloc'. In this case you get sort of what
  you'd expect, though it's a bit confusing in its own way due to going
  'backwards'. In this case the locations would be: "x y + z +" in
  lovely postfix arithmetic order. But this does mean that if the op+
  were an operator overload, say, and in a backtrace, the backtrace will
  point to the exact '+' that's being called, not to the end of one of
  its operands.

(actually the operator overload case doesn't work yet for other reasons,
but that's being fixed - but this at least gets scalar/complex
assignments and other plain operators right)

llvm-svn: 227027
2015-01-25 01:19:10 +00:00
David Blaikie 835afb205f DebugInfo: Remove forced column-info workaround for inlined calls
This workaround was to provide unique call sites to ensure LLVM's inline
debug info handling would properly unique two calls to the same function
on the same line. Instead, this has now been fixed in LLVM (r226736) and
the workaround here can be removed.

Originally committed in r176895, but this isn't a straight revert due to
all the changes since then. I just searched for anything ForcedColumn*
related and removed them.

We could test this - but it didn't strike me as terribly valuable once
we're no longer adding this workaround everything just works as expected
& it's no longer a special case to test for.

llvm-svn: 226738
2015-01-21 23:08:17 +00:00
Adrian Prantl 7c6f944cdf Migrate all uses of DIVariable's FlagIndirectVariable to use a DIExpression
with a DW_OP_deref instead.

llvm-svn: 226474
2015-01-19 17:51:58 +00:00