r312623 - Debug info: Fixed faulty debug locations for attributed statements
Karl-Johan Karlsson via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 6 01:47:19 PDT 2017
Author: karka
Date: Wed Sep 6 01:47:18 2017
New Revision: 312623
URL: http://llvm.org/viewvc/llvm-project?rev=312623&view=rev
Log:
Debug info: Fixed faulty debug locations for attributed statements
Summary:
As the attributed statements are considered simple statements no
stoppoint was generated before emitting attributed do/while/for/range-
statement. This lead to faulty debug locations.
Reviewers: echristo, aaron.ballman, dblaikie
Reviewed By: dblaikie
Subscribers: bjope, aprantl, cfe-commits
Differential Revision: https://reviews.llvm.org/D37428
Added:
cfe/trunk/test/CodeGen/debug-info-attributed-stmt.c
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=312623&r1=312622&r2=312623&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Wed Sep 6 01:47:18 2017
@@ -45,7 +45,7 @@ void CodeGenFunction::EmitStopPoint(cons
}
}
-void CodeGenFunction::EmitStmt(const Stmt *S) {
+void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs) {
assert(S && "Null statement?");
PGO.setCurrentStmt(S);
@@ -131,16 +131,16 @@ void CodeGenFunction::EmitStmt(const Stm
case Stmt::IndirectGotoStmtClass:
EmitIndirectGotoStmt(cast<IndirectGotoStmt>(*S)); break;
- case Stmt::IfStmtClass: EmitIfStmt(cast<IfStmt>(*S)); break;
- case Stmt::WhileStmtClass: EmitWhileStmt(cast<WhileStmt>(*S)); break;
- case Stmt::DoStmtClass: EmitDoStmt(cast<DoStmt>(*S)); break;
- case Stmt::ForStmtClass: EmitForStmt(cast<ForStmt>(*S)); break;
-
- case Stmt::ReturnStmtClass: EmitReturnStmt(cast<ReturnStmt>(*S)); break;
-
- case Stmt::SwitchStmtClass: EmitSwitchStmt(cast<SwitchStmt>(*S)); break;
- case Stmt::GCCAsmStmtClass: // Intentional fall-through.
- case Stmt::MSAsmStmtClass: EmitAsmStmt(cast<AsmStmt>(*S)); break;
+ case Stmt::IfStmtClass: EmitIfStmt(cast<IfStmt>(*S)); break;
+ case Stmt::WhileStmtClass: EmitWhileStmt(cast<WhileStmt>(*S), Attrs); break;
+ case Stmt::DoStmtClass: EmitDoStmt(cast<DoStmt>(*S), Attrs); break;
+ case Stmt::ForStmtClass: EmitForStmt(cast<ForStmt>(*S), Attrs); break;
+
+ case Stmt::ReturnStmtClass: EmitReturnStmt(cast<ReturnStmt>(*S)); break;
+
+ case Stmt::SwitchStmtClass: EmitSwitchStmt(cast<SwitchStmt>(*S)); break;
+ case Stmt::GCCAsmStmtClass: // Intentional fall-through.
+ case Stmt::MSAsmStmtClass: EmitAsmStmt(cast<AsmStmt>(*S)); break;
case Stmt::CoroutineBodyStmtClass:
EmitCoroutineBody(cast<CoroutineBodyStmt>(*S));
break;
@@ -178,7 +178,7 @@ void CodeGenFunction::EmitStmt(const Stm
EmitCXXTryStmt(cast<CXXTryStmt>(*S));
break;
case Stmt::CXXForRangeStmtClass:
- EmitCXXForRangeStmt(cast<CXXForRangeStmt>(*S));
+ EmitCXXForRangeStmt(cast<CXXForRangeStmt>(*S), Attrs);
break;
case Stmt::SEHTryStmtClass:
EmitSEHTryStmt(cast<SEHTryStmt>(*S));
@@ -555,23 +555,7 @@ void CodeGenFunction::EmitLabelStmt(cons
}
void CodeGenFunction::EmitAttributedStmt(const AttributedStmt &S) {
- const Stmt *SubStmt = S.getSubStmt();
- switch (SubStmt->getStmtClass()) {
- case Stmt::DoStmtClass:
- EmitDoStmt(cast<DoStmt>(*SubStmt), S.getAttrs());
- break;
- case Stmt::ForStmtClass:
- EmitForStmt(cast<ForStmt>(*SubStmt), S.getAttrs());
- break;
- case Stmt::WhileStmtClass:
- EmitWhileStmt(cast<WhileStmt>(*SubStmt), S.getAttrs());
- break;
- case Stmt::CXXForRangeStmtClass:
- EmitCXXForRangeStmt(cast<CXXForRangeStmt>(*SubStmt), S.getAttrs());
- break;
- default:
- EmitStmt(SubStmt);
- }
+ EmitStmt(S.getSubStmt(), S.getAttrs());
}
void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) {
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=312623&r1=312622&r2=312623&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Sep 6 01:47:18 2017
@@ -2534,7 +2534,7 @@ public:
/// This function may clear the current insertion point; callers should use
/// EnsureInsertPoint if they wish to subsequently generate code without first
/// calling EmitBlock, EmitBranch, or EmitStmt.
- void EmitStmt(const Stmt *S);
+ void EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs = None);
/// EmitSimpleStmt - Try to emit a "simple" statement which does not
/// necessarily require an insertion point or debug information; typically
Added: cfe/trunk/test/CodeGen/debug-info-attributed-stmt.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-attributed-stmt.c?rev=312623&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/debug-info-attributed-stmt.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-attributed-stmt.c Wed Sep 6 01:47:18 2017
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
+
+void f(_Bool b)
+{
+#pragma nounroll
+ while (b);
+}
+
+// CHECK: br label %while.cond, !dbg ![[NUM:[0-9]+]]
+// CHECK: br i1 %tobool, label %while.body, label %while.end, !dbg ![[NUM]]
+// CHECK: br label %while.cond, !dbg ![[NUM]], !llvm.loop
+// CHECK: ![[NUM]] = !DILocation(line: 6,
More information about the cfe-commits
mailing list