-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Assertion failed: ("conflicting locations for variable") #32504
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
Comments
Why does the IR have four llvm.dbg.declare calls in it? That's odd. $ grep %aRect t.ll |
Nevermind, they all have different variables from different inlined versions of NSMaxX. |
By the way I haven't looked at this further at all so far. It is entirely possible that your commit just uncovered a bug in the DWARF backend. |
I think this is an uncovered bug, not a bug in the new code. What's happening is that we have two dbg.declares that get code duplicated during loop rotation after inlining and memcpy optimization. These are the ones that matter: They use the same location, variable metadata, DILocation, etc. They don't conflict, they're just code duplicated. Anyway, I would suggest this patch, but it needs more tests. There are more edge cases here. It may be possible to craft a test case that uses parameters declared to live in static allocas that triggers the same assertion and isn't dependent on my change, but I don't have time to find it. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
|
Nice! That patch seems reasonable. As mentioned in the FIXME, it should assert that the FI and expr is identical. Do you know which pass is duplicating the dbg.declare? Can/should that be fixed instead/in addition? |
It was some loop pass, which wasn't apparent from -print-after-all, because it only prints each loop individually. It's hard to see the big picture. This was my attempt to write a manual reduction, but it did not work: @g = external global i32 declare void @llvm.dbg.declare(metadata, metadata, metadata) define void @f(i32* byval %p, i1 %c) !dbg !5 { x: y: done: !llvm.dbg.cu = !{#0} !0 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !1, producer: "clang version 5.0.0 ", isOptimized: true, runtimeVersion: 2, emissionKind: FullDebug) !5 = distinct !DISubprogram(name: "f", isLocal: true, isDefinition: true, scopeLine: 37, flags: DIFlagPrototyped, isOptimized: true, unit: !0, type: !99, scope: !1) !10 = !DILocalVariable(name: "aRect", arg: 1, scope: !98, file: !1, line: 38) !12 = !DILocation(line: 43, scope: !98, inlinedAt: !13) !98 = distinct !DISubprogram(name: "NSMaxX", scope: !1, file: !1, line: 27, isLocal: true, isDefinition: true, scopeLine: 27, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !62, type: !99) !62 = !{#10} |
LoopUnswitch does this! opt -S bah.ll -o - -loop-unswitch | grep dbg.declare I found this because we ran into the same issue in internal testing. If it really is illegal to have duplicated dbg.declare shouldn't the verify-debug-info catch this case? |
Yes. Alternatively, we could also filter out duplicate entries before we we enter them into the MF side-table. In either case we should still fix LoopUnswitch to not duplicate dbg.declare intrinsics as this is a waste of space. |
I wrote a new issue for the LoopUnswitch case: bug 33355. I think it's not the same bug as this because here the dbg.declare is duplicated by LoopRotate if I understood correctly. |
I committed a fix similar to the one Reid was proposing in r305244. |
*** Bug llvm/llvm-bugzilla-archive#33355 has been marked as a duplicate of this bug. *** |
mentioned in issue llvm/llvm-bugzilla-archive#33355 |
Extended Description
Assertion failure when compiling Adium.
$ cat test.mi
typedef signed char BOOL;
@protocol NSObject
@end
typedef double CGFloat;
struct CGPoint {
CGFloat x;
CGFloat y;
};
typedef struct CGPoint CGPoint;
struct CGSize {
CGFloat width;
CGFloat height;
};
typedef struct CGSize CGSize;
struct CGRect {
CGPoint origin;
CGSize size;
};
typedef struct CGRect CGRect;
typedef CGRect NSRect;
CGRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) {
CGRect r;
r.origin.x = x;
r.size.width = w;
return r;
}
CGFloat NSMaxX(NSRect aRect) { return (aRect.origin.x + aRect.size.width); }
@protocol NSAccessibilityElement
@end
@interface NSView
@end
@interface KNShelfSplitView : NSView {
CGSize backgroundSize;
}
@end
@implementation KNShelfSplitView
:(NSRect)aRect active:(BOOL)isActive {
NSRect sourceRect =
NSMakeRect(0, 0, backgroundSize.width, backgroundSize.height);
NSRect destRect = NSMakeRect(aRect.origin.x, aRect.origin.y,
sourceRect.size.width, aRect.size.height);
while ((destRect.origin.x < NSMaxX(aRect)) && destRect.size.width > 0) {
if (NSMaxX(destRect) > NSMaxX(aRect)) {
sourceRect.size.width = NSWidth(destRect);
}
}
}
@end
$ clang -cc1 -triple x86_64-apple-macosx10.6.0 -emit-obj -dwarf-column-info -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb -Os -std=gnu99 -fblocks -x objective-c test.mi 2>&1 | grep all_of
Assertion failed: (all_of(FrameIndexExprs, [](FrameIndexExpr &FIE) { return FIE.Expr && FIE.Expr->isFragment(); }) && "conflicting locations for variable"), function addMMIEntry, file ../lib/CodeGen/AsmPrinter/DwarfDebug.h, line 142.
This started failing with r302544:
Re-land "Use the frame index side table for byval and inalloca arguments"
This re-lands r302483. It was not the cause of #32324 .
git-original-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302544
The text was updated successfully, but these errors were encountered: