[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-26 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:11292
+}
+
+/// Argument's value might be modified, so update the info.

riccibruno wrote:
> Hmm, I don't think that this will work. Suppose that you have an expression 
> like `(a, b) += c`  You want to mark `b` as modified, but not `a`. What is 
> needed I believe is:
> 
> Given an expression `E` find the variable that this expression designate if 
> any, and if it is a function parameter mark it "known to be modified".
> 
> Visiting all of the children just looking for `DeclRefExpr`s is a bit too 
> blunt I believe.
You are right. We thought it is possible implementing this with some basic 
analysis (with low overhead), but in order to support all cases it would take 
much time and it is not good idea.

I tried to use `ExprMutationAnalyzer ` (that @lebedev.ri mentioned) and it 
seems to be useful for this. It seems that it can be used a little bit later 
than in this phase, because it takes ASTContext, but in this stage we have 
ASTContext finished up to node we are currently observing (an expression from 
which we are extracting DeclRef). But, even using it in the right time, it 
seems that `ExprMutationAnalyzer ` does not have support for comma operator. 
I'm trying to extend this analyzer in order to add support for that. ASAP I 
will post new changes.
For the other cases I tried, it works.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-03 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro created this revision.
djtodoro added reviewers: shuaiwang, lebedev.ri.
Herald added subscribers: Charusso, jdoerfert, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.

We should track mutation of a variable within a comma operator expression.
Current code in `ExprMutationAnalyzer `does not handle it.

This will handle cases like:

`(a, b) ++`  < == `b `is modified
`(a, b) = c` < == `b `is modifed


https://reviews.llvm.org/D58894

Files:
  include/clang/AST/Expr.h
  lib/Analysis/ExprMutationAnalyzer.cpp
  unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -881,6 +881,24 @@
   EXPECT_FALSE(isMutated(Results, AST.get()));
 }
 
+TEST(ExprMutationAnalyzerTest, CommaExprWithAnAssigment) {
+  const auto AST =
+  buildASTFromCodeWithArgs("void f() { int x; int y; (x, y) = 5; }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithDecOp) {
+  const auto AST =
+  buildASTFromCodeWithArgs("void f() { int x; int y; (x, y)++; }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
 TEST(ExprMutationAnalyzerTest, LambdaDefaultCaptureByValue) {
   const auto AST = buildASTFromCode("void f() { int x; [=]() { x; }; }");
   const auto Results =
Index: lib/Analysis/ExprMutationAnalyzer.cpp
===
--- lib/Analysis/ExprMutationAnalyzer.cpp
+++ lib/Analysis/ExprMutationAnalyzer.cpp
@@ -14,6 +14,42 @@
 
 namespace {
 
+// Assignment on an expression with comma operator.
+// Match situations like:
+// '(a, b) = c', '(c, (a, b)) = c', etc.
+AST_MATCHER_P(BinaryOperator, isAssigmentWithCommma, const Expr *, E) {
+  if (Node.isAssignmentOp()) {
+const Expr* LHSResult = Node.getLHS();
+while (const auto *BOComma =
+ dyn_cast_or_null(LHSResult->IgnoreParens())) {
+  if (!BOComma->isCommaOp())
+break;
+  LHSResult = BOComma->getRHS();
+}
+if (LHSResult == E)
+  return true;
+  }
+  return false;
+}
+
+// Increment/Decrement on an expression with comma operator.
+// Match situations like:
+// '(a, b)++', '(c, (a, b))++', '(a, b)--', etc.
+AST_MATCHER_P(UnaryOperator, isIncDecOperandWithComma, const Expr *, E) {
+  if (Node.isIncrementDecrementOp()) {
+const Expr* Result = Node.getSubExpr()->IgnoreParens();
+while (const auto *BOComma =
+ dyn_cast_or_null(Result->IgnoreParens())) {
+  if (!BOComma->isCommaOp())
+break;
+  Result = BOComma->getRHS();
+}
+if (Result == E)
+  return true;
+  }
+  return false;
+}
+
 AST_MATCHER_P(LambdaExpr, hasCaptureInit, const Expr *, E) {
   return llvm::is_contained(Node.capture_inits(), E);
 }
@@ -195,11 +231,20 @@
   const auto AsAssignmentLhs =
   binaryOperator(isAssignmentOperator(), hasLHS(equalsNode(Exp)));
 
+  // LHS of assignment is an expression with comma operator.
+  const auto AsAssignmentCommaLhs =
+  binaryOperator(isAssigmentWithCommma(Exp));
+
   // Operand of increment/decrement operators.
   const auto AsIncDecOperand =
   unaryOperator(anyOf(hasOperatorName("++"), hasOperatorName("--")),
 hasUnaryOperand(equalsNode(Exp)));
 
+  // Operand of increment/decrement operators is an expression
+  // with comma operator.
+  const auto AsIncDecOperandWithComma =
+  unaryOperator(isIncDecOperandWithComma(Exp));
+
   // Invoking non-const member function.
   // A member function is assumed to be non-const when it is unresolved.
   const auto NonConstMethod = cxxMethodDecl(unless(isConst()));
@@ -264,10 +309,12 @@
   const auto AsNonConstRefReturn = returnStmt(hasReturnValue(equalsNode(Exp)));
 
   const auto Matches =
-  match(findAll(stmt(anyOf(AsAssignmentLhs, AsIncDecOperand, AsNonConstThis,
-   AsAmpersandOperand, AsPointerFromArrayDecay,
-   AsOperatorArrowThis, AsNonConstRefArg,
-   AsLambdaRefCaptureInit, AsNonConstRefReturn))
+  match(findAll(stmt(anyOf(AsAssignmentLhs, AsAssignmentCommaLhs,
+   AsIncDecOperand, AsIncDecOperandWithComma,
+   AsNonConstThis, AsAmpersandOperand,
+   AsPointerFromArrayDecay, AsOperatorArrowThis,
+   AsNonConstRefArg, AsLambdaRefCaptureInit,
+   AsNonConstRefReturn))
   

[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-04 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

@lebedev.ri Thanks for your comment!

> Is there any way to model this more generically?
> I.e don't duplicate every naive matcher (ignoring possible presence of , op) 
> with an variant that does not ignore ,.
> E.g. will this handle (a,b)+=1 ?

Hmm, I am not sure if there is a place for that, since this is very specific to 
comma operators. Any suggestions ?
It handles the situation (`(a,b)+=1`).

> What about (a,b).callNonConstMethod(), (a,b).callConstMethod() ?

This needs to be extended to support function/method calls. I guess 
`ExprMutationAnalyzer::findFunctionArgMutation` requires an improvement.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-05 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

@lebedev.ri I agree, thank you! I needed to be more precise in my previous 
reply, sorry for that. I thought it will be (somehow) overhead if I change 
existing, very basic, matchers.

I already implemented a static function that skips comma operands, and extended 
this to support member calls, functions, etc.
But, implementing it as a new matcher sounds like better idea.

Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-06 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 189461.
djtodoro added a comment.

-add AST matcher that skips operands in comma expression
-add unit tests for extended support


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894

Files:
  include/clang/AST/Expr.h
  lib/Analysis/ExprMutationAnalyzer.cpp
  unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -881,6 +881,65 @@
   EXPECT_FALSE(isMutated(Results, AST.get()));
 }
 
+TEST(ExprMutationAnalyzerTest, CommaExprWithAnAssigment) {
+  const auto AST =
+  buildASTFromCodeWithArgs("void f() { int x; int y; (x, y) = 5; }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithDecOp) {
+  const auto AST =
+  buildASTFromCodeWithArgs("void f() { int x; int y; (x, y)++; }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithNonConstMemberCall) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem; void f() { mem ++; } };"
+   "void fn() { A o1, o2; (o1, o2).f(); }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o2")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithConstMemberCall) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem; void f() const  { } };"
+   "void fn() { A o1, o2; (o1, o2).f(); }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o2")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprParmRef) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem;};"
+   "extern void fn(A &o1);"
+   "void fn2 () { A o1, o2; fn((o2, o1)); } ",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithAmpersandOp) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem;};"
+   "void fn () { A o1, o2; void *addr = &(o2, o1); } ",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
 TEST(ExprMutationAnalyzerTest, LambdaDefaultCaptureByValue) {
   const auto AST = buildASTFromCode("void f() { int x; [=]() { x; }; }");
   const auto Results =
Index: lib/Analysis/ExprMutationAnalyzer.cpp
===
--- lib/Analysis/ExprMutationAnalyzer.cpp
+++ lib/Analysis/ExprMutationAnalyzer.cpp
@@ -24,6 +24,18 @@
   return InnerMatcher.matches(*Range, Finder, Builder);
 }
 
+AST_MATCHER_P(Expr, skipCommaOps,
+ ast_matchers::internal::Matcher, InnerMatcher) {
+  const Expr* Result = &Node;
+  while (const auto *BOComma =
+   dyn_cast_or_null(Result->IgnoreParens())) {
+if (!BOComma->isCommaOp())
+  break;
+Result = BOComma->getRHS();
+  }
+  return InnerMatcher.matches(*Result, Finder, Builder);
+}
+
 const ast_matchers::internal::VariadicDynCastAllOfMatcher
 cxxTypeidExpr;
 
@@ -193,18 +205,20 @@
 const Stmt *ExprMutationAnalyzer::findDirectMutation(const Expr *Exp) {
   // LHS of any assignment operators.
   const auto AsAssignmentLhs =
-  binaryOperator(isAssignmentOperator(), hasLHS(equalsNode(Exp)));
+  binaryOperator(isAssignmentOperator(),
+ hasLHS(skipCommaOps(equalsNode(Exp;
 
   // Operand of increment/decrement operators.
   const auto AsIncDecOperand =
   unaryOperator(anyOf(hasOperatorName("++"), hasOperatorName("--")),
-hasUnaryOperand(equalsNode(Exp)));
+hasUnaryOperand(skipCommaOps(equalsNode(Exp;
 
   // Invoking non-const member function.
   // A member function is assumed to be non-const when it is unresolved.
   const auto NonConstMethod = cxxMethodDecl(unless(isConst()));
   const auto AsNonConstThis =
-  expr(anyOf(cxxMemberCallExpr(callee(N

[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-06 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

>> @lebedev.ri I agree, thank you! I needed to be more precise in my previous 
>> reply, sorry for that. I thought it will be (somehow) overhead if I change 
>> existing, very basic, matchers.
> 
> I indeed don't think the existing matchers should be changed to ignore these 
> , ops (or implicit casts, like some issue reports propose).
> 
>> I already implemented a static function that skips comma operands, and 
>> extended this to support member calls, functions, etc.
>> But, implementing it as a new matcher sounds like better idea.



> Yes. I think this matcher will be very baseline, and can just be added where 
> needed
> (with appropriate test coverage, of course), without matcher duplication like 
> in this current diff.

@lebedev.ri I agree, we are on the same page! Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-06 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added a comment.

> Nice, i like this!
> I think the test coverage is good.

@lebedev.ri Thanks!

> But what about other equalsNode() that you didn't change?
> Do some of them need this change too?

For sure some of them (maybe all of them) needs usage of the new comma matcher.
I didn't check all of them, for those I checked I've created test cases.
But I agree, it should handle all possible situation.




Comment at: lib/Analysis/ExprMutationAnalyzer.cpp:27
 
+AST_MATCHER_P(Expr, skipCommaOps,
+ ast_matchers::internal::Matcher, InnerMatcher) {

lebedev.ri wrote:
> (Can anyone suggest a better name maybe?
> I'm not sure this is the most correct name, but i can't suggest a better 
> alternative.)
Maybe `evalCommaExpr`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-06 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: lib/Analysis/ExprMutationAnalyzer.cpp:27
 
+AST_MATCHER_P(Expr, skipCommaOps,
+ ast_matchers::internal::Matcher, InnerMatcher) {

lebedev.ri wrote:
> djtodoro wrote:
> > lebedev.ri wrote:
> > > (Can anyone suggest a better name maybe?
> > > I'm not sure this is the most correct name, but i can't suggest a better 
> > > alternative.)
> > Maybe `evalCommaExpr`?
> Ah, yes, `eval` sounds better.
> But, it won't always eval comma op or bailout.
> It will eval if it is there.
> So maybe `maybeEvalCommaExpr` (pun intended!).
Sure, `maybeEvalCommaExpr ` sounds better.
Or, one more suggestion is `tryEvalCommaExpr` ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-07 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added a comment.

> Anyways, this looks good in this state.
> Thank you for working on this!

Thanks!

> If you don't intend to immediately work on fixing the rest of , cases here,
> *please* do file a bug so it won't get lost. (and link it here)

I already extended this in order to support the rest of direct mutations.




Comment at: lib/Analysis/ExprMutationAnalyzer.cpp:27
 
+AST_MATCHER_P(Expr, skipCommaOps,
+ ast_matchers::internal::Matcher, InnerMatcher) {

lebedev.ri wrote:
> djtodoro wrote:
> > lebedev.ri wrote:
> > > djtodoro wrote:
> > > > lebedev.ri wrote:
> > > > > (Can anyone suggest a better name maybe?
> > > > > I'm not sure this is the most correct name, but i can't suggest a 
> > > > > better alternative.)
> > > > Maybe `evalCommaExpr`?
> > > Ah, yes, `eval` sounds better.
> > > But, it won't always eval comma op or bailout.
> > > It will eval if it is there.
> > > So maybe `maybeEvalCommaExpr` (pun intended!).
> > Sure, `maybeEvalCommaExpr ` sounds better.
> > Or, one more suggestion is `tryEvalCommaExpr` ?
> `try`, at least to me, has the same meaning as `evalCommaExpr`, i.e. one 
> might expect that if it fails, it will fail.
> So not sure.
Hmm, I agree. You are right. Let it be `maybeEvalCommaExpr` (for now), if there 
is no better suggestion.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58894: [analyzer] Handle modification of vars inside an expr with comma operator

2019-03-07 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 189661.
djtodoro added a comment.

-add support for the rest of direct mutation cases


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58894/new/

https://reviews.llvm.org/D58894

Files:
  include/clang/AST/Expr.h
  lib/Analysis/ExprMutationAnalyzer.cpp
  unittests/Analysis/ExprMutationAnalyzerTest.cpp

Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -881,6 +881,137 @@
   EXPECT_FALSE(isMutated(Results, AST.get()));
 }
 
+TEST(ExprMutationAnalyzerTest, CommaExprWithAnAssigment) {
+  const auto AST =
+  buildASTFromCodeWithArgs("void f() { int x; int y; (x, y) = 5; }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithDecOp) {
+  const auto AST =
+  buildASTFromCodeWithArgs("void f() { int x; int y; (x, y)++; }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithNonConstMemberCall) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem; void f() { mem ++; } };"
+   "void fn() { A o1, o2; (o1, o2).f(); }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o2")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithConstMemberCall) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem; void f() const  { } };"
+   "void fn() { A o1, o2; (o1, o2).f(); }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o2")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithCallExpr) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem; void f(A &O1) {} };"
+   "void fn() { A o1, o2; o2.f((o2, o1)); }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithCallUnresolved) {
+  auto AST = buildASTFromCodeWithArgs(
+  "template  struct S;"
+  "template  void f() { S s; int x, y; s.mf((y, x)); }",
+  {"-fno-delayed-template-parsing -Wno-unused-value"});
+  auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+
+  AST = buildASTFromCodeWithArgs(
+  "template  void f(T t) { int x, y; g(t, (y, x)); }",
+  {"-fno-delayed-template-parsing -Wno-unused-value"});
+  Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprParmRef) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem;};"
+   "extern void fn(A &o1);"
+   "void fn2 () { A o1, o2; fn((o2, o1)); } ",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprWithAmpersandOp) {
+  const auto AST =
+  buildASTFromCodeWithArgs("class A { public: int mem;};"
+   "void fn () { A o1, o2;"
+   "void *addr = &(o2, o1); } ",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("o1")), AST->getASTContext());
+  EXPECT_TRUE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaExprAsReturnAsValue) {
+  auto AST = buildASTFromCodeWithArgs("int f() { int x, y; return (x, y); }",
+  {"-Wno-unused-value"});
+  auto Results =
+  match(withEnclosingCompound(declRefTo("y")), AST->getASTContext());
+  EXPECT_FALSE(isMutated(Results, AST.get()));
+}
+
+TEST(ExprMutationAnalyzerTest, CommaEpxrAsReturnAsNonConstRef) {
+  const auto AST =
+  buildASTFromCodeWithArgs("int& f() { int x, y; return (y, x); }",
+   {"-Wno-unused-value"});
+  const auto Results =
+  match(withEnclosingCompound(declRefTo("x")), AST->getASTContex

[PATCH] D58033: Add option for emitting dbg info for call sites

2019-04-15 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195188.
djtodoro edited the summary of this revision.
djtodoro added a comment.

-Rebase
-Add all_call_sites flag in the case of GNU extensions


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_emit_param_entry_values_cc1);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3396,6 +3396,10 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  // Enable param entry values functionlaity.
+  if (Args.hasArg(options::OPT_emit_param_entry_values))
+CmdArgs.push_back("-emit-param-entry-values-cc1");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableParamEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -916,6 +916,10 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+def emit_param_entry_values : Joined<["-"], "femit-param-entry-values">,
+   Group,
+   Flags<[CC1Option]>,
+   HelpText<"Enables debug info about call site and call 
site parameters">;
 def fforce_enable_int128 : Flag<["-"], "fforce-enable-int128">,
   Group, Flags<[CC1Option]>,
   HelpText<"Enable support for int128_t type">;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -359,6 +359,9 @@
 def flto_visibility_public_std:
 Flag<["-"], "flto-visibility-public-std">,
 HelpText<"Use public LTO visibility for classes in std and stdext 
namespaces">;
+def emit_param_entry_values_cc1:
+Flag<["-"], "emit-param-entry-values-cc1">,
+HelpText<"Enables debug info about call site and call site parameters">;
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableParamEntryValues, 1, 0) ///< Emit any call site dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_emit_param_entry_

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-04-15 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195192.
djtodoro added a comment.

-Rebase
-Use `ExprMutationAnalyzer` for parameter's modification check


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4532,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableParamEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for(auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = dyn_cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4532,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableParamEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for(auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = dyn_cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58043: Add experimental options for call site related dbg info

2019-04-15 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195198.
djtodoro retitled this revision from "Add option for emitting 
DW_OP_entry_values" to "Add experimental options for call site related dbg 
info".
djtodoro edited the summary of this revision.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58043/new/

https://reviews.llvm.org/D58043

Files:
  lib/Driver/ToolChains/Clang.cpp


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3397,8 +3397,15 @@
 CmdArgs.push_back("-dwarf-explicit-import");
 
   // Enable param entry values functionlaity.
-  if (Args.hasArg(options::OPT_emit_param_entry_values))
+  if (Args.hasArg(options::OPT_emit_param_entry_values) &&
+  areOptimizationsEnabled(Args)) {
 CmdArgs.push_back("-emit-param-entry-values-cc1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-entry-values=1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-call-site-info=1");
+
+  }
 
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3397,8 +3397,15 @@
 CmdArgs.push_back("-dwarf-explicit-import");
 
   // Enable param entry values functionlaity.
-  if (Args.hasArg(options::OPT_emit_param_entry_values))
+  if (Args.hasArg(options::OPT_emit_param_entry_values) &&
+  areOptimizationsEnabled(Args)) {
 CmdArgs.push_back("-emit-param-entry-values-cc1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-entry-values=1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-call-site-info=1");
+
+  }
 
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58033: Add option for emitting dbg info for call sites

2019-04-15 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: include/clang/Driver/Options.td:919
   HelpText<"Do not use jump tables for lowering switches">;
+def emit_param_entry_values : Joined<["-"], "femit-param-entry-values">,
+   Group,

aprantl wrote:
> I assume that this is the same -f option that GCC uses?
Actually in GCC production of call_site and call_site_parameters debug info is 
enabled by default.
Production of entry_values is implemented on top of variable's value tracking 
system and there is no particular option just for entry_values.

Basically, we introduce this option as experimental one. As soon as we test 
everything we should get rid of this or turn it ON by default (and maybe add 
'-fno-emit-param-entry-values' in order to have an option for disabling the 
functionality). That will be ideal scenario.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-04-16 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked 3 inline comments as done.
djtodoro added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4537
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;

aprantl wrote:
> Just looking at the type declarations in CGDebugInfo.h: Why not iterate over 
> the `SPCache`  directly? Shouldn't that contain all Function declarations 
> only?
I tried it, but `SPCache` is empty at this point.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-04-16 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195359.
djtodoro added a comment.

-Run clang-format
-Use `cast` instead of '`dyn_cast`'


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4532,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableParamEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4532,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableParamEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58033: Add option for emitting dbg info for call sites

2019-04-17 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked 2 inline comments as done.
djtodoro added a comment.

@probinson @aprantl Thanks a lot for your comments!

Let's clarify some things. I'm sorry about the confusion.

Initial patch for the functionality can be restricted by this option (like we 
pushed here), since **LLDB** doesn't read this type of debug info (yet).
The plan is, when  **LLDB** has all necessary info and we are sure that 
everything works fine during using this info in debugging sessions, we can turn 
it to `ON` by default.

Does that make sense ? :)




Comment at: include/clang/Driver/Options.td:921
+   Group,
+   Flags<[CC1Option]>,
+   HelpText<"Enables debug info about call site and call 
site parameters">;

probinson wrote:
> I believe that by marking this with `[CC1Option]` cc1 will automatically 
> understand it and you won't need to define a separate option in CC1Options.td.
I can't remember what problem we occurred with this on 4.0, but we definitely 
don't need both definitions.
Thanks for this!  


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-04-17 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195568.
djtodoro retitled this revision from "Add option for emitting dbg info for call 
sites" to "Add option for emitting dbg info for call site parameters".
djtodoro added a comment.

-Refactor
-Remove `CC1` def


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/Options.td
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_femit_param_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3396,6 +3396,10 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  // Enable param entry values functionlaity.
+  if (Args.hasArg(options::OPT_femit_param_entry_values))
+CmdArgs.push_back("-femit-param-entry-values");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableParamEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -916,6 +916,9 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+def femit_param_entry_values : Flag<["-"], "femit-param-entry-values">, 
Group,
+  Flags<[CC1Option]>,
+  HelpText<"Enables debug info about call site parameter's entry values">;
 def fforce_enable_int128 : Flag<["-"], "fforce-enable-int128">,
   Group, Flags<[CC1Option]>,
   HelpText<"Enable support for int128_t type">;
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableParamEntryValues, 1, 0) ///< Emit any call site dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_femit_param_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3396,6 +3396,10 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  // Enable param entry values functionlaity.
+  if (Args.hasArg(options::OPT_femit_param_entry_values))
+CmdArgs.push_back("-femit-param-entry-values");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: lib/CodeG

[PATCH] D58043: Add experimental options for call site related dbg info

2019-04-17 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195569.
djtodoro added a comment.

-Rebase


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58043/new/

https://reviews.llvm.org/D58043

Files:
  lib/Driver/ToolChains/Clang.cpp


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3397,8 +3397,15 @@
 CmdArgs.push_back("-dwarf-explicit-import");
 
   // Enable param entry values functionlaity.
-  if (Args.hasArg(options::OPT_femit_param_entry_values))
+  if (Args.hasArg(options::OPT_femit_param_entry_values) &&
+  areOptimizationsEnabled(Args)) {
 CmdArgs.push_back("-femit-param-entry-values");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-entry-values=1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-call-site-info=1");
+
+  }
 
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3397,8 +3397,15 @@
 CmdArgs.push_back("-dwarf-explicit-import");
 
   // Enable param entry values functionlaity.
-  if (Args.hasArg(options::OPT_femit_param_entry_values))
+  if (Args.hasArg(options::OPT_femit_param_entry_values) &&
+  areOptimizationsEnabled(Args)) {
 CmdArgs.push_back("-femit-param-entry-values");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-entry-values=1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-call-site-info=1");
+
+  }
 
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-04-17 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195571.
djtodoro added a comment.

-Fix comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/Options.td
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_femit_param_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3396,6 +3396,10 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  // Enable param entry values functionality.
+  if (Args.hasArg(options::OPT_femit_param_entry_values))
+CmdArgs.push_back("-femit-param-entry-values");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableParamEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -916,6 +916,9 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+def femit_param_entry_values : Flag<["-"], "femit-param-entry-values">, 
Group,
+  Flags<[CC1Option]>,
+  HelpText<"Enables debug info about call site parameter's entry values">;
 def fforce_enable_int128 : Flag<["-"], "fforce-enable-int128">,
   Group, Flags<[CC1Option]>,
   HelpText<"Enable support for int128_t type">;
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableParamEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_femit_param_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3396,6 +3396,10 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  // Enable param entry values functionality.
+  if (Args.hasArg(options::OPT_femit_param_entry_values))
+CmdArgs.push_back("-femit-param-entry-values");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,

[PATCH] D58043: Add experimental options for call site related dbg info

2019-04-17 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 195572.
djtodoro added a comment.

-Rebase


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58043/new/

https://reviews.llvm.org/D58043

Files:
  lib/Driver/ToolChains/Clang.cpp


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3397,8 +3397,14 @@
 CmdArgs.push_back("-dwarf-explicit-import");
 
   // Enable param entry values functionality.
-  if (Args.hasArg(options::OPT_femit_param_entry_values))
+  if (Args.hasArg(options::OPT_femit_param_entry_values) &&
+  areOptimizationsEnabled(Args)) {
 CmdArgs.push_back("-femit-param-entry-values");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-entry-values=1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-call-site-info=1");
+  }
 
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3397,8 +3397,14 @@
 CmdArgs.push_back("-dwarf-explicit-import");
 
   // Enable param entry values functionality.
-  if (Args.hasArg(options::OPT_femit_param_entry_values))
+  if (Args.hasArg(options::OPT_femit_param_entry_values) &&
+  areOptimizationsEnabled(Args)) {
 CmdArgs.push_back("-femit-param-entry-values");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-entry-values=1");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-emit-call-site-info=1");
+  }
 
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-04-22 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 196053.
djtodoro added a comment.

-Add only cc1 option
-Set up back end


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_femit_param_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3396,6 +3396,10 @@
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
+  // Enable param entry values functionality.
+  if (Args.hasArg(options::OPT_femit_param_entry_values))
+CmdArgs.push_back("-femit-param-entry-values");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableParamEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -463,6 +463,7 @@
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
+  Options.EnableParamEntryValues = CodeGenOpts.EnableParamEntryValues;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -364,6 +364,8 @@
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def femit_param_entry_values : Flag<["-"], "femit-param-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableParamEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_femit_param_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/Driver/ToolChains/Clang.cpp
=

[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-04-23 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

> Is there some kind of testcase?

@aprantl Usage of the option is tested within following patches from the stack. 
I am not sure if we need some additional test here?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-04-25 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked 2 inline comments as done.
djtodoro added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:3402
+CmdArgs.push_back("-femit-param-entry-values");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);

probinson wrote:
> If this is now a cc1-only option, this part goes away right?
Yes, thanks for this!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-04-25 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 196595.
djtodoro marked an inline comment as done.
djtodoro edited the summary of this revision.
djtodoro added a comment.

-Remove unneeded code


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_femit_param_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableParamEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -463,6 +463,7 @@
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
+  Options.EnableParamEntryValues = CodeGenOpts.EnableParamEntryValues;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -364,6 +364,8 @@
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def femit_param_entry_values : Flag<["-"], "femit-param-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableParamEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableParamEntryValues = Args.hasArg(OPT_femit_param_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableParamEntryValues &&
+   CGM.getCodeGenOpts

[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-05-06 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

@probinson @aprantl Thanks!

@vsk Thanks for the comment! Sure, we will add that.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-13 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 186611.
djtodoro added a comment.

- Rename: `VariableNotChanged `===> `ArgumentNotModified`
- Refactor a test case


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  include/clang/AST/Decl.h
  lib/CodeGen/CGDebugInfo.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGen/debug-info-varchange.c

Index: test/CodeGen/debug-info-varchange.c
===
--- /dev/null
+++ test/CodeGen/debug-info-varchange.c
@@ -0,0 +1,35 @@
+// RUN: %clang -femit-param-entry-values -emit-llvm -S -g %s -o - | FileCheck %s
+
+// CHECK: !DILocalVariable(name: "a", arg: 1, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+// CHECK: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "test_s", arg: 3, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+// CHECK: !DILocalVariable(name: "test_s2", arg: 4, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "x", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "y", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+
+typedef struct s {
+  int m;
+  int n;
+}S;
+
+void foo (int a, int b,
+  S test_s, S test_s2)
+{
+  b++;
+  b = a + 1;
+  if (b>4)
+test_s2.m = 434;
+}
+
+int main()
+{
+  S test_s = {4, 5};
+
+  int x = 5;
+  int y = 6;
+
+  foo(x , y, test_s, test_s);
+
+  return 0;
+}
+
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -11276,6 +11277,19 @@
 DiagnoseConstAssignment(S, E, Loc);
 }
 
+/// Argument's value might be modified, so update the info.
+static void EmitArgumentsValueModification(Expr *E) {
+  if (const DeclRefExpr *LHSDeclRef =
+  dyn_cast(E->IgnoreParenCasts()))
+if (const ValueDecl *Decl = LHSDeclRef->getDecl())
+  if (const VarDecl *VD = dyn_cast(Decl)) {
+if (!isa(VD))
+  return;
+if (!VD->getIsArgumentModified())
+  VD->setIsArgumentModified();
+  }
+}
+
 /// CheckForModifiableLvalue - Verify that E is a modifiable lvalue.  If not,
 /// emit an error and return true.  If so, return false.
 static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
@@ -11283,6 +11297,12 @@
 
   S.CheckShadowingDeclModification(E, Loc);
 
+  if (MemberExpr *ME = dyn_cast(E)) {
+if (Expr *BaseExpr = ME->getBase())
+  EmitArgumentsValueModification(BaseExpr);
+  } else
+EmitArgumentsValueModification(E);
+
   SourceLocation OrigLoc = Loc;
   Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(S.Context,
   &Loc);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3778,6 +3778,11 @@
   if (VD->isImplicit())
 Flags |= llvm::DINode::FlagArtificial;
 
+  auto &CGOpts = CGM.getCodeGenOpts();
+  if (CGOpts.EnableParamEntryValues && !VD->getIsArgumentModified())
+Flags |= llvm::DINode::FlagArgumentNotModified;
+
+
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
 
   unsigned AddressSpace = CGM.getContext().getTargetAddressSpace(VD->getType());
Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -840,6 +840,8 @@
   /// It is illegal to call this function with SC == None.
   static const char *getStorageClassSpecifierString(StorageClass SC);
 
+  mutable bool IsArgumentModified = false;
+
 protected:
   // A pointer union of Stmt * and EvaluatedStmt *. When an EvaluatedStmt, we
   // have allocated the auxiliary struct of information there.
@@ -1477,6 +1479,13 @@
   /// Do we need to emit an exit-time destructor for this variable?
   bool isNoDestroy(const ASTContext &) const;
 
+  bool getIsArgumentModified() const {
+return IsArgumentModified;
+  }
+  void setIsArgumentModified() const {
+IsArgumentModified = true;
+  }
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K >= firstVar && K <= lastVar; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-22 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked 2 inline comments as done.
djtodoro added a comment.

> I was under the impression that space inside VarDecl was quite constrained. 
> Pardon the likely naive question, but: is there any way to make the 
> representation more compact (maybe sneak a bit into ParmVarDeclBitfields)?

@vsk  Thanks for the comment! Sure, it is better idea. Initially, we thought 
this could be used even for local variables, but since we are using it only for 
parameters it makes more sense.




Comment at: lib/Sema/SemaExpr.cpp:11282
+static void EmitArgumentsValueModification(Expr *E) {
+  if (const DeclRefExpr *LHSDeclRef =
+  dyn_cast(E->IgnoreParenCasts()))

probinson wrote:
> Does this fit on one line if you use `const auto *LHSDeclRef ...`? Given you 
> have the dyn_cast on the RHS there's no real need to give the type name twice.
>Does this fit on one line if you use const auto *LHSDeclRef ...? Given you 
>have the dyn_cast on the RHS there's no real need to give the type name twice.

@probinson Thanks for the comment! Sure, it will be refactored.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-22 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added a comment.

@riccibruno Thanks for your comments!

> Oh and I think that you will also have to update the serialization 
> code/de-serialization code in ASTReaderDecl.cpp / ASTWriterDecl.cpp. You 
> might also have to update TreeTransform but I am less familiar with this.

I've added `ASTReaderDecl.cpp` / `ASTWriterDecl.cpp`, but looking at 
`TreeTransform ` I'm not sure if there is a place for adding something 
regarding this.

> I am wondering about the semantics of this bit. I don't think that you can 
> know for sure within clang whether a variable has been modified. The best you 
> can do is know for sure that some variable has been modified, but I don't 
> think you can prove that it has not been modified.



> Consequently I am wondering if you should change the name of this flag to 
> something like IsArgumentKnownToBeModified.



> Orthogonal to this you need to also add tests for templates.

I agree! You are right, good idea!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-22 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 187931.
djtodoro added a comment.

- Add a field in `ParmVarDecl` instead of `VarDecl`
- Use a bit in `ParmVarDeclBitfields` to indicate parameter modification
- Add support for the bit in  `ASTReaderDecl.cpp` / `ASTWriterDecl.cpp`
- Add test case for templates


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  include/clang/AST/Decl.h
  lib/CodeGen/CGDebugInfo.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/dbginfo-var-change-templates.cpp
  test/CodeGen/debug-info-varchange.c

Index: test/CodeGen/debug-info-varchange.c
===
--- /dev/null
+++ test/CodeGen/debug-info-varchange.c
@@ -0,0 +1,35 @@
+// RUN: %clang -femit-param-entry-values -emit-llvm -S -g %s -o - | FileCheck %s
+
+// CHECK: !DILocalVariable(name: "a", arg: 1, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+// CHECK: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "test_s", arg: 3, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+// CHECK: !DILocalVariable(name: "test_s2", arg: 4, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "x", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "y", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+
+typedef struct s {
+  int m;
+  int n;
+}S;
+
+void foo (int a, int b,
+  S test_s, S test_s2)
+{
+  b++;
+  b = a + 1;
+  if (b>4)
+test_s2.m = 434;
+}
+
+int main()
+{
+  S test_s = {4, 5};
+
+  int x = 5;
+  int y = 6;
+
+  foo(x , y, test_s, test_s);
+
+  return 0;
+}
+
Index: test/CodeGen/dbginfo-var-change-templates.cpp
===
--- /dev/null
+++ test/CodeGen/dbginfo-var-change-templates.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang -femit-param-entry-values -emit-llvm -S -g %s -o - | FileCheck %s
+// CHECK: !DILocalVariable(name: "a", arg: 1, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+
+template 
+__attribute__((noinline))
+T GetMin (T a, T b) {
+  T result;
+  ++a;
+  result = (a < b) ? a : b;
+  return result;
+}
+
+int baa () {
+  int i=5, j=6, k;
+  k=GetMin(i,j);
+
+  if (i == k)
+++k;
+  else
+--k;
+
+  return k;
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -1033,6 +1033,7 @@
   Record.push_back(D->hasUninstantiatedDefaultArg());
   if (D->hasUninstantiatedDefaultArg())
 Record.AddStmt(D->getUninstantiatedDefaultArg());
+  Record.push_back(D->isArgumentKnownToBeModified());
   Code = serialization::DECL_PARM_VAR;
 
   assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
@@ -1046,6 +1047,7 @@
   !D->isImplicit() &&
   !D->isUsed(false) &&
   !D->isInvalidDecl() &&
+  !D->isArgumentKnownToBeModified() &&
   !D->isReferenced() &&
   D->getAccess() == AS_none &&
   !D->isModulePrivate() &&
@@ -2011,6 +2013,7 @@
   Abv->Add(BitCodeAbbrevOp(0));   // KNRPromoted
   Abv->Add(BitCodeAbbrevOp(0));   // HasInheritedDefaultArg
   Abv->Add(BitCodeAbbrevOp(0));   // HasUninstantiatedDefaultArg
+  Abv->Add(BitCodeAbbrevOp(0));   // IsArgumentKnownToBeModified
   // Type Source Info
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1441,7 +1441,7 @@
   PD->ParmVarDeclBits.HasInheritedDefaultArg = Record.readInt();
   if (Record.readInt()) // hasUninstantiatedDefaultArg.
 PD->setUninstantiatedDefaultArg(Record.readExpr());
-
+  PD->ParmVarDeclBits.IsArgumentKnownToBeModified = Record.readInt();
   // FIXME: If this is a redeclaration of a function from another module, handle
   // inheritance of default arguments.
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -11276,6 +11277,15 @@
 DiagnoseCons

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-25 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added a comment.

> I'm not quite sure what this differential is about, but i feel like 
> mentioning ExprMutationAnalyzer lib in clang-tidy / clang-tools-extra.



>> Alternatively perhaps you could re-use getMemoryLocation() from D57660 
>> . It would handle for you members, 
>> references, structured bindings +more in a relatively self-contained code.

@lebedev.ri, @riccibruno Thanks for your advices! We'll check this also.




Comment at: lib/Sema/SemaExpr.cpp:11301
+EmitArgumentsValueModification(E);
+
   SourceLocation OrigLoc = Loc;

lebedev.ri wrote:
> riccibruno wrote:
> > Comments:
> > 
> > 1. Shouldn't you mark the variable to be modified only if 
> > `CheckForModifiableLvalue` returns true ?
> > 
> > 2. I think that you need to handle way more than just member expressions. 
> > For example are you handling `(x, y)` (comma operator) ? But hard-coding 
> > every cases here is probably not ideal. It would be nice if there was 
> > already some code somewhere that could help you do this.
> > 
> > 3. I believe that a `MemberExpr` has always a base. Similarly 
> > `DeclRefExpr`s always have a referenced declaration (so you can omit the 
> > `if`).
> I'm not quite sure what this differential is about, but i feel like 
> mentioning ExprMutationAnalyzer lib in clang-tidy / clang-tools-extra.
@riccibruno Please find inlined replies:

>1. Shouldn't you mark the variable to be modified only if 
>CheckForModifiableLvalue returns true ?

Hmm, we should avoid marking variables modification if this emits an error. 
But, we should emit it if `CheckForModifiableLvalue ` returns `false`, since in 
the case of returning `true` an error will be emitted.

>2. I think that you need to handle way more than just member expressions. For 
>example are you handling (x, y) (comma operator) ? But hard-coding every cases 
>here is probably not ideal. It would be nice if there was already some code 
>somewhere that could help you do this.

Hard coding all cases is not good idea. I agree. Since we are only looking for 
declaration references, we could make just a function that traverses any `Expr` 
and find declaration ref.

>3. I believe that a MemberExpr has always a base. Similarly DeclRefExprs 
>always have a referenced declaration (so you can omit the if).

I think you are right. Thanks!




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-25 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 188110.
djtodoro added a comment.
Herald added a subscriber: jdoerfert.

- Handle all kinds of expressions when mark a param's modification


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  include/clang/AST/Decl.h
  lib/CodeGen/CGDebugInfo.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/dbginfo-var-change-templates.cpp
  test/CodeGen/debug-info-varchange.c

Index: test/CodeGen/debug-info-varchange.c
===
--- /dev/null
+++ test/CodeGen/debug-info-varchange.c
@@ -0,0 +1,35 @@
+// RUN: %clang -femit-param-entry-values -emit-llvm -S -g %s -o - | FileCheck %s
+
+// CHECK: !DILocalVariable(name: "a", arg: 1, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+// CHECK: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "test_s", arg: 3, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+// CHECK: !DILocalVariable(name: "test_s2", arg: 4, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "x", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "y", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+
+typedef struct s {
+  int m;
+  int n;
+}S;
+
+void foo (int a, int b,
+  S test_s, S test_s2)
+{
+  b++;
+  b = a + 1;
+  if (b>4)
+test_s2.m = 434;
+}
+
+int main()
+{
+  S test_s = {4, 5};
+
+  int x = 5;
+  int y = 6;
+
+  foo(x , y, test_s, test_s);
+
+  return 0;
+}
+
Index: test/CodeGen/dbginfo-var-change-templates.cpp
===
--- /dev/null
+++ test/CodeGen/dbginfo-var-change-templates.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang -femit-param-entry-values -emit-llvm -S -g %s -o - | FileCheck %s
+// CHECK: !DILocalVariable(name: "a", arg: 1, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+
+template 
+__attribute__((noinline))
+T GetMin (T a, T b) {
+  T result;
+  ++a;
+  result = (a < b) ? a : b;
+  return result;
+}
+
+int baa () {
+  int i=5, j=6, k;
+  k=GetMin(i,j);
+
+  if (i == k)
+++k;
+  else
+--k;
+
+  return k;
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -1033,6 +1033,7 @@
   Record.push_back(D->hasUninstantiatedDefaultArg());
   if (D->hasUninstantiatedDefaultArg())
 Record.AddStmt(D->getUninstantiatedDefaultArg());
+  Record.push_back(D->isArgumentKnownToBeModified());
   Code = serialization::DECL_PARM_VAR;
 
   assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
@@ -1046,6 +1047,7 @@
   !D->isImplicit() &&
   !D->isUsed(false) &&
   !D->isInvalidDecl() &&
+  !D->isArgumentKnownToBeModified() &&
   !D->isReferenced() &&
   D->getAccess() == AS_none &&
   !D->isModulePrivate() &&
@@ -2011,6 +2013,7 @@
   Abv->Add(BitCodeAbbrevOp(0));   // KNRPromoted
   Abv->Add(BitCodeAbbrevOp(0));   // HasInheritedDefaultArg
   Abv->Add(BitCodeAbbrevOp(0));   // HasUninstantiatedDefaultArg
+  Abv->Add(BitCodeAbbrevOp(0));   // IsArgumentKnownToBeModified
   // Type Source Info
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1441,7 +1441,7 @@
   PD->ParmVarDeclBits.HasInheritedDefaultArg = Record.readInt();
   if (Record.readInt()) // hasUninstantiatedDefaultArg.
 PD->setUninstantiatedDefaultArg(Record.readExpr());
-
+  PD->ParmVarDeclBits.IsArgumentKnownToBeModified = Record.readInt();
   // FIXME: If this is a redeclaration of a function from another module, handle
   // inheritance of default arguments.
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -11276,6 +11277,30 @@
 DiagnoseConstAssignment(S, E, Loc);
 }
 
+/// Traverse an expression and find declaration ref, if any.
+static bool HasDeclRef(const E

[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-06-06 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 203335.
djtodoro added a comment.

-Explicitly enable the option only in the case of X86


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/dbg-info-all-calls-described.cpp


Index: test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -15,6 +15,19 @@
 // RUN: | FileCheck %s -check-prefix=HAS-ATTR \
 // RUN: -implicit-check-not=DISubprogram 
-implicit-check-not=DIFlagAllCallsDescribed
 
+// Supported: DWARF4 + GDB tuning by using '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O1 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
+// RUN: -implicit-check-not=DIFlagAllCallsDescribed
+
+// Unsupported: -O0 + '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O0 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=NO-ATTR
+
 // Supported: DWARF4 + LLDB tuning, -O1, line-tables only DI
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -O1 -disable-llvm-passes \
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -747,6 +747,13 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+
+  llvm::Triple T(TargetOpts.Triple);
+  llvm::Triple::ArchType Arch = T.getArch();
+  if (Opts.OptimizationLevel > 0 &&
+  (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64))
+Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
+
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4619,7 +4619,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -466,6 +466,7 @@
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
+  Options.EnableDebugEntryValues = CodeGenOpts.EnableDebugEntryValues;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -368,6 +368,8 @@
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit c

[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-06-17 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:755
+  (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64))
+Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
+

probinson wrote:
> You want to disable entry-values for all targets other than X86?
@probinson Thanks for the comment!

>You want to disable entry-values for all targets other than X86?

Yes, for now. Because, if we want to support the entry-values feature for an 
architecture (other than X86), we would need to handle target specifics of call 
arguments lowering for the architecture.

For the initial set of patches, we have accomplished to test and add support 
only for X86. We will work on supporting more architectures.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-06-26 Thread Djordje Todorovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL364399: [CC1Option] Add the option to enable the debug entry 
values (authored by djtodoro, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58033?vs=203335&id=206619#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  cfe/trunk/include/clang/Basic/CodeGenOptions.def
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenCXX/dbg-info-all-calls-described.cpp


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -4659,7 +4659,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -471,6 +471,7 @@
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
+  Options.EnableDebugEntryValues = CodeGenOpts.EnableDebugEntryValues;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -760,6 +760,13 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+
+  llvm::Triple T(TargetOpts.Triple);
+  llvm::Triple::ArchType Arch = T.getArch();
+  if (Opts.OptimizationLevel > 0 &&
+  (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64))
+Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
+
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -386,6 +386,8 @@
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
Index: cfe/trunk/include/clang/Basic/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Basic/CodeGenOptions.def
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
Index: cfe/trunk/test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- cfe/trunk/test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ cfe/trunk/test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -15,6 +15,19 @@
 // RUN: | FileCheck %s -check-prefix=HAS-ATTR \
 // RUN: -implicit-check-not=DISubprogram 
-implicit-check-not=DIFlagAllCallsDescribed
 
+// Supported: DWARF4 + GDB tuning by using '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femi

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-06-26 Thread Djordje Todorovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL364424: [clang/DIVar] Emit the flag for params that have 
unmodified value (authored by djtodoro, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58035?vs=201505&id=206651#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/test/CodeGen/debug-info-param-modification.c

Index: cfe/trunk/test/CodeGen/debug-info-param-modification.c
===
--- cfe/trunk/test/CodeGen/debug-info-param-modification.c
+++ cfe/trunk/test/CodeGen/debug-info-param-modification.c
@@ -0,0 +1,12 @@
+// RUN: %clang -Xclang -femit-debug-entry-values -g -O2 -S -target x86_64-none-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-ENTRY-VAL-OPT
+// CHECK-ENTRY-VAL-OPT: !DILocalVariable(name: "a", arg: 1, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK-ENTRY-VAL-OPT: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+//
+// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
+// CHECK-NOT: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+//
+
+int fn2 (int a, int b) {
+  ++a;
+  return b;
+}
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -134,6 +134,10 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  /// Cache function definitions relevant to use for parameters mutation
+  /// analysis.
+  llvm::DenseMap SPDefCache;
+  llvm::DenseMap ParamCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3588,6 +3589,12 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  // We use the SPDefCache only in the case when the debug entry values option
+  // is set, in order to speed up parameters modification analysis.
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
+  isa(D))
+SPDefCache[cast(D)].reset(SP);
+
   if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
 // Starting with DWARF V5 method declarations are emitted as children of
 // the interface type.
@@ -3964,6 +3971,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && ArgNo) {
+if (auto *PD = dyn_cast(VD))
+  ParamCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4555,6 +4567,29 @@
   TheCU->setDWOId(Signature);
 }
 
+/// Analyzes each function parameter to determine whether it is constant
+/// throughout the function body.
+static void analyzeParametersModification(
+ASTContext &Ctx,
+llvm::DenseMap &SPDefCache,
+llvm::DenseMap &ParamCache) {
+  for (auto &SP : SPDefCache) {
+auto *FD = SP.first;
+assert(FD->hasBody() && "Functions must have body here");
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, Ctx);
+  if (FuncAnalyzer.isMutated(Parm))
+continue;
+
+  auto I = ParamCache.find(Parm);
+  assert(I != ParamCache.end() && "Parameters should be already cached");
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+
 void CGDebugInfo::finalize() {
   // Creating types might create further types - invalidating the current
   // element and the size(), so don't cache/reference them.
@@ -4627,6 +4662,10 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues)
+// This will be used to emit debug entry values.
+analyzeParametersModification(CGM.getContext(), SPDefCache, ParamCache);
+
   DBuilder.finalize();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64540: [CGDebugInfo] Simplfiy EmitFunctionDecl parameters, NFC

2019-07-11 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro accepted this revision.
djtodoro added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks @vsk!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64540/new/

https://reviews.llvm.org/D64540



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-05-13 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 199213.
djtodoro edited the summary of this revision.
djtodoro added a comment.

-Add an input in test/CodeGenCXX/dbg-info-all-calls-described.cpp
-Rename the option


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/dbg-info-all-calls-described.cpp


Index: test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -15,6 +15,13 @@
 // RUN: | FileCheck %s -check-prefix=HAS-ATTR \
 // RUN: -implicit-check-not=DISubprogram 
-implicit-check-not=DIFlagAllCallsDescribed
 
+// Supported: DWARF4 + GDB tuning by using '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O1 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
+// RUN: -implicit-check-not=DIFlagAllCallsDescribed
+
 // Supported: DWARF4 + LLDB tuning, -O1, line-tables only DI
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -O1 -disable-llvm-passes \
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,7 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -463,6 +463,7 @@
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
+  Options.EnableDebugEntryValues = CodeGenOpts.EnableDebugEntryValues;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -364,6 +364,8 @@
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- test/CodeGenCXX/dbg-info-all-calls-describe

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-13 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 199214.
djtodoro added a comment.

-Rebase


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4532,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4532,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-16 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:3885
+  if (ArgNo) {
+auto *PD = dyn_cast(VD);
+ParmCache[PD].reset(D);

aprantl wrote:
> A `dyn_cast` followed by an unconditional use seems strange. I would expect 
> either a `cast` or an `if (PD)` check.
Yes, thanks for this!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-16 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 199788.
djtodoro added a comment.

-Careful use of `dyn_cast`
-Fill the `ParamCache` only in the case of `EnableDebugEntryValues` option


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,12 @@
  llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+  CGM.getLangOpts().Optimize && ArgNo) {
+if (auto *PD = dyn_cast(VD))
+  ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4533,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParmCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3880,6 +3881,12 @@
  llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+  CGM.getLangOpts().Optimize && ArgNo) {
+if (auto *PD = dyn_cast(VD))
+  ParmCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4526,6 +4533,25 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;
+  if (const auto *FD = dyn_cast_or_null(D)) {
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, CGM.getContext());
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParmCache.find(Parm);
+if (I != ParmCache.end()) {
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+  }
   DBuilder.finalize();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-17 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked 3 inline comments as done.
djtodoro added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4537
+  CGM.getLangOpts().Optimize) {
+for (auto &SP : DeclCache) {
+  auto *D = SP.first;

aprantl wrote:
> djtodoro wrote:
> > aprantl wrote:
> > > Just looking at the type declarations in CGDebugInfo.h: Why not iterate 
> > > over the `SPCache`  directly? Shouldn't that contain all Function 
> > > declarations only?
> > I tried it, but `SPCache` is empty at this point.
> Where is it emptied? Just grepping through CGDebugInfo did not make this 
> obvious to me.
The `SPCache` actually gets filled only in the case of `CXXMemberFunction`.
In the other cases of `SP` production there is only filling of `DeclCache`.
Should we use it like this or ?



Comment at: lib/CodeGen/CGDebugInfo.cpp:3885
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+  CGM.getLangOpts().Optimize && ArgNo) {
+if (auto *PD = dyn_cast(VD))

aprantl wrote:
> We shouldn't query CGM.getLangOpts().Optimize. If we don't want this to 
> happen at -O0, we shouldn't set EnableDebugEntryValues at a higher level 
> (Driver, CompilerInvocation, ...) ..Otherwise inevitably someone will query 
> one but not the other and things will go out of sync.
I agree. Thanks!



Comment at: lib/CodeGen/CGDebugInfo.cpp:4535
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues &&

aprantl wrote:
> Please add either a top-level comment about what this block is doing or 
> perhaps factor this out into a descriptively named static function.
Sure.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-05-21 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 200485.
djtodoro added a comment.

-Set `EnableDebugEntryValues` only for a higher level of optimizations (-O1 and 
higher)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/dbg-info-all-calls-described.cpp


Index: test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -15,6 +15,13 @@
 // RUN: | FileCheck %s -check-prefix=HAS-ATTR \
 // RUN: -implicit-check-not=DISubprogram 
-implicit-check-not=DIFlagAllCallsDescribed
 
+// Supported: DWARF4 + GDB tuning by using '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O1 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
+// RUN: -implicit-check-not=DIFlagAllCallsDescribed
+
 // Supported: DWARF4 + LLDB tuning, -O1, line-tables only DI
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -O1 -disable-llvm-passes \
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,8 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  if (Opts.OptimizationLevel > 0)
+Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -463,6 +463,7 @@
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
+  Options.EnableDebugEntryValues = CodeGenOpts.EnableDebugEntryValues;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -364,6 +364,8 @@
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- test/CodeGenCXX/dbg-info-all-calls-described.cpp

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-21 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 200486.
djtodoro added a comment.

-Use `SPCache` instead of `DeclCache`
-Refactor the code by addressing suggestions


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParamCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3515,6 +3516,12 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  // We use the SPCache only in the case when the debug entry values option is
+  // set, in order to speed up parameters modification analysis.
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
+  isa(D))
+SPCache[cast(D)->getCanonicalDecl()].reset(SP);
+
   if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
 // Starting with DWARF V5 method declarations are emitted as children of
 // the interface type.
@@ -3880,6 +3887,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && ArgNo) {
+if (auto *PD = dyn_cast(VD))
+  ParamCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4454,6 +4466,26 @@
   TheCU->setDWOId(Signature);
 }
 
+static void analyzeParametersModification(
+ASTContext &Ctx,
+llvm::DenseMap &SPCache,
+llvm::DenseMap &ParamCache) {
+  for (auto &SP : SPCache) {
+auto *FD = SP.first;
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, Ctx);
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParamCache.find(Parm);
+if (I != ParamCache.end()) {
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+
 void CGDebugInfo::finalize() {
   // Creating types might create further types - invalidating the current
   // element and the size(), so don't cache/reference them.
@@ -4526,6 +4558,10 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues)
+// This will be used to emit debug entry values.
+analyzeParametersModification(CGM.getContext(), SPCache, ParamCache);
+
   DBuilder.finalize();
 }
 


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParamCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3515,6 +3516,12 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  // We use the SPCache only in the case when the debug entry values option is
+  // set, in order to speed up parameters modification analysis.
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
+  isa(D))
+SPCache[cast(D)->getCanonicalDecl()].reset(SP);
+
   if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
 // Starting with DWARF V5 method declarations are emitted as children of
 // the interface type.
@@ -3880,6 +3887,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && ArgNo) {
+if (auto *PD = dyn_cast(VD))
+  ParamCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4454,6 +4466,26 @@
   TheCU->setDWOId(Signature);
 }
 
+static void analyzeParametersMo

[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-05-23 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 200943.
djtodoro added a comment.

-Add a negative test for -O0


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/dbg-info-all-calls-described.cpp


Index: test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -15,6 +15,19 @@
 // RUN: | FileCheck %s -check-prefix=HAS-ATTR \
 // RUN: -implicit-check-not=DISubprogram 
-implicit-check-not=DIFlagAllCallsDescribed
 
+// Supported: DWARF4 + GDB tuning by using '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O1 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
+// RUN: -implicit-check-not=DIFlagAllCallsDescribed
+
+// Unsupported: -O0 + '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O0 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=NO-ATTR
+
 // Supported: DWARF4 + LLDB tuning, -O1, line-tables only DI
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -O1 -disable-llvm-passes \
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,8 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  if (Opts.OptimizationLevel > 0)
+Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -463,6 +463,7 @@
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
+  Options.EnableDebugEntryValues = CodeGenOpts.EnableDebugEntryValues;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -364,6 +364,8 @@
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTai

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-23 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 200950.
djtodoro added a comment.

-Add `SPDefCache` to speed up the process
-Add additional assertions that will improve quality of the code


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,10 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  /// Cache function definitions relevant to use for parameters mutation
+  /// analysis.
+  llvm::DenseMap SPDefCache;
+  llvm::DenseMap ParamCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3515,6 +3516,12 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  // We use the SPDefCache only in the case when the debug entry values option
+  // is set, in order to speed up parameters modification analysis.
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
+  isa(D))
+SPDefCache[cast(D)].reset(SP);
+
   if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
 // Starting with DWARF V5 method declarations are emitted as children of
 // the interface type.
@@ -3880,6 +3887,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && ArgNo) {
+if (auto *PD = dyn_cast(VD))
+  ParamCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4454,6 +4466,29 @@
   TheCU->setDWOId(Signature);
 }
 
+/// Analyzes each function parameter to determine whether it is constant
+/// throughout the function body.
+static void analyzeParametersModification(
+ASTContext &Ctx,
+llvm::DenseMap &SPDefCache,
+llvm::DenseMap &ParamCache) {
+  for (auto &SP : SPDefCache) {
+auto *FD = SP.first;
+assert(FD->hasBody() && "Functions must have body here");
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, Ctx);
+  if (FuncAnalyzer.isMutated(Parm))
+continue;
+
+  auto I = ParamCache.find(Parm);
+  assert(I != ParamCache.end() && "Parameters should be already cached");
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+
 void CGDebugInfo::finalize() {
   // Creating types might create further types - invalidating the current
   // element and the size(), so don't cache/reference them.
@@ -4526,6 +4561,10 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues)
+// This will be used to emit debug entry values.
+analyzeParametersModification(CGM.getContext(), SPDefCache, ParamCache);
+
   DBuilder.finalize();
 }
 


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,10 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  /// Cache function definitions relevant to use for parameters mutation
+  /// analysis.
+  llvm::DenseMap SPDefCache;
+  llvm::DenseMap ParamCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3515,6 +3516,12 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  // We use the SPDefCache only in the case when the debug entry values option
+  // is set, in order to speed up parameters modification analysis.
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
+  isa(D))
+SPDefCache[cast(D)].reset(SP);
+
   if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
 // Starting with DWARF V5 method declarations are emitte

[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-05-27 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 201503.
djtodoro added a comment.

-Rebase


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58033/new/

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/dbg-info-all-calls-described.cpp


Index: test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -15,6 +15,19 @@
 // RUN: | FileCheck %s -check-prefix=HAS-ATTR \
 // RUN: -implicit-check-not=DISubprogram 
-implicit-check-not=DIFlagAllCallsDescribed
 
+// Supported: DWARF4 + GDB tuning by using '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O1 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
+// RUN: -implicit-check-not=DIFlagAllCallsDescribed
+
+// Unsupported: -O0 + '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O0 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=NO-ATTR
+
 // Supported: DWARF4 + LLDB tuning, -O1, line-tables only DI
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -O1 -disable-llvm-passes \
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -747,6 +747,8 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  if (Opts.OptimizationLevel > 0)
+Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4619,7 +4619,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -466,6 +466,7 @@
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
+  Options.EnableDebugEntryValues = CodeGenOpts.EnableDebugEntryValues;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -368,6 +368,8 @@
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< 

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-27 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 201505.
djtodoro added a comment.

-Rebase
-Add a test


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGen/debug-info-param-modification.c

Index: test/CodeGen/debug-info-param-modification.c
===
--- /dev/null
+++ test/CodeGen/debug-info-param-modification.c
@@ -0,0 +1,12 @@
+// RUN: %clang -Xclang -femit-debug-entry-values -g -O2 -S -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-ENTRY-VAL-OPT
+// CHECK-ENTRY-VAL-OPT: !DILocalVariable(name: "a", arg: 1, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK-ENTRY-VAL-OPT: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+//
+// RUN: %clang -g -O2 -S -emit-llvm %s -o - | FileCheck %s
+// CHECK-NOT: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+//
+
+int fn2 (int a, int b) {
+  ++a;
+  return b;
+}
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -134,6 +134,10 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  /// Cache function definitions relevant to use for parameters mutation
+  /// analysis.
+  llvm::DenseMap SPDefCache;
+  llvm::DenseMap ParamCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3577,6 +3578,12 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  // We use the SPDefCache only in the case when the debug entry values option
+  // is set, in order to speed up parameters modification analysis.
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
+  isa(D))
+SPDefCache[cast(D)].reset(SP);
+
   if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
 // Starting with DWARF V5 method declarations are emitted as children of
 // the interface type.
@@ -3942,6 +3949,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && ArgNo) {
+if (auto *PD = dyn_cast(VD))
+  ParamCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4515,6 +4527,29 @@
   TheCU->setDWOId(Signature);
 }
 
+/// Analyzes each function parameter to determine whether it is constant
+/// throughout the function body.
+static void analyzeParametersModification(
+ASTContext &Ctx,
+llvm::DenseMap &SPDefCache,
+llvm::DenseMap &ParamCache) {
+  for (auto &SP : SPDefCache) {
+auto *FD = SP.first;
+assert(FD->hasBody() && "Functions must have body here");
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, Ctx);
+  if (FuncAnalyzer.isMutated(Parm))
+continue;
+
+  auto I = ParamCache.find(Parm);
+  assert(I != ParamCache.end() && "Parameters should be already cached");
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+
 void CGDebugInfo::finalize() {
   // Creating types might create further types - invalidating the current
   // element and the size(), so don't cache/reference them.
@@ -4587,6 +4622,10 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues)
+// This will be used to emit debug entry values.
+analyzeParametersModification(CGM.getContext(), SPDefCache, ParamCache);
+
   DBuilder.finalize();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80369: [DebugInfo] Remove decl subprograms from 'retainedTypes:'

2020-05-21 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro created this revision.
djtodoro added reviewers: dblaikie, aprantl, vsk.
djtodoro added projects: LLVM, debug-info.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

After the D70350 , the `retainedTypes:` isn't 
being used for the purpose of call site debug info for extern calls, so it is 
safe to delete it from IR representation.
We are also adding a test to ensure the subprogram isn't stored within the 
`retainedTypes:` from corresponding `DICompileUnit`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80369

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-call.c


Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug-info-extern-call.c
@@ -1,6 +1,10 @@
 // When entry values are emitted, expect a subprogram for extern decls so that
 // the dwarf generator can describe call site parameters at extern call sites.
 //
+// Initial implementation relied on the 'retainedTypes:' from the corresponding
+// DICompileUnit, so we also ensure that we do not store the extern declaration
+// subprogram into the 'retainedTypes:'.
+//
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
 
@@ -17,6 +21,8 @@
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o 
- \
 // RUN:   | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
 
+// DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: 
![[RETTYPES:[0-9]+]]
+// DECLS-FOR-EXTERN-NOT: ![[RETTYPES]] = !{
 // DECLS-FOR-EXTERN: !DISubprogram(name: "fn1"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3870,8 +3870,6 @@
 
   if (IsDeclForCallSite)
 Fn->setSubprogram(SP);
-
-  DBuilder.retainType(SP);
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,


Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug-info-extern-call.c
@@ -1,6 +1,10 @@
 // When entry values are emitted, expect a subprogram for extern decls so that
 // the dwarf generator can describe call site parameters at extern call sites.
 //
+// Initial implementation relied on the 'retainedTypes:' from the corresponding
+// DICompileUnit, so we also ensure that we do not store the extern declaration
+// subprogram into the 'retainedTypes:'.
+//
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
 
@@ -17,6 +21,8 @@
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
 
+// DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: ![[RETTYPES:[0-9]+]]
+// DECLS-FOR-EXTERN-NOT: ![[RETTYPES]] = !{
 // DECLS-FOR-EXTERN: !DISubprogram(name: "fn1"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3870,8 +3870,6 @@
 
   if (IsDeclForCallSite)
 Fn->setSubprogram(SP);
-
-  DBuilder.retainType(SP);
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80369: WIP: [DebugInfo] Remove decl subprograms from 'retainedTypes:'

2020-05-21 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 265481.
djtodoro retitled this revision from "[DebugInfo] Remove decl subprograms from 
'retainedTypes:'" to "WIP: [DebugInfo] Remove decl subprograms from 
'retainedTypes:'".
djtodoro added a comment.

Still have test failing:

  Clang :: Modules/DebugInfoTransitiveImport.m
  Clang :: Modules/ModuleDebugInfo.cpp
  Clang :: Modules/ModuleDebugInfo.m

I haven't looked into the failures, but I guess something Objective-C++ related 
should be handled with some additional work here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80369/new/

https://reviews.llvm.org/D80369

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-call.c


Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug-info-extern-call.c
@@ -1,6 +1,10 @@
 // When entry values are emitted, expect a subprogram for extern decls so that
 // the dwarf generator can describe call site parameters at extern call sites.
 //
+// Initial implementation relied on the 'retainedTypes:' from the corresponding
+// DICompileUnit, so we also ensure that we do not store the extern declaration
+// subprogram into the 'retainedTypes:'.
+//
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
 
@@ -17,6 +21,8 @@
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o 
- \
 // RUN:   | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
 
+// DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: 
![[RETTYPES:[0-9]+]]
+// DECLS-FOR-EXTERN-NOT: ![[RETTYPES]] = !{
 // DECLS-FOR-EXTERN: !DISubprogram(name: "fn1"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3871,7 +3871,7 @@
   if (IsDeclForCallSite)
 Fn->setSubprogram(SP);
 
-  DBuilder.retainType(SP);
+  DBuilder.finalizeSubprogram(SP);
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,


Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug-info-extern-call.c
@@ -1,6 +1,10 @@
 // When entry values are emitted, expect a subprogram for extern decls so that
 // the dwarf generator can describe call site parameters at extern call sites.
 //
+// Initial implementation relied on the 'retainedTypes:' from the corresponding
+// DICompileUnit, so we also ensure that we do not store the extern declaration
+// subprogram into the 'retainedTypes:'.
+//
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
 
@@ -17,6 +21,8 @@
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
 
+// DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: ![[RETTYPES:[0-9]+]]
+// DECLS-FOR-EXTERN-NOT: ![[RETTYPES]] = !{
 // DECLS-FOR-EXTERN: !DISubprogram(name: "fn1"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3871,7 +3871,7 @@
   if (IsDeclForCallSite)
 Fn->setSubprogram(SP);
 
-  DBuilder.retainType(SP);
+  DBuilder.finalizeSubprogram(SP);
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80369: [DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

2020-05-22 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 265722.
djtodoro retitled this revision from "WIP: [DebugInfo] Remove decl subprograms 
from 'retainedTypes:'" to "[DebugInfo][CallSites] Remove decl subprograms from 
'retainedTypes:'".
djtodoro added a comment.

-Remove the decls only in the case of call-site debug info


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80369/new/

https://reviews.llvm.org/D80369

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-call.c


Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug-info-extern-call.c
@@ -1,6 +1,10 @@
 // When entry values are emitted, expect a subprogram for extern decls so that
 // the dwarf generator can describe call site parameters at extern call sites.
 //
+// Initial implementation relied on the 'retainedTypes:' from the corresponding
+// DICompileUnit, so we also ensure that we do not store the extern declaration
+// subprogram into the 'retainedTypes:'.
+//
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
 
@@ -17,6 +21,8 @@
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o 
- \
 // RUN:   | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
 
+// DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: 
![[RETTYPES:[0-9]+]]
+// DECLS-FOR-EXTERN-NOT: ![[RETTYPES]] = !{
 // DECLS-FOR-EXTERN: !DISubprogram(name: "fn1"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3868,10 +3868,14 @@
   getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
   TParamsArray.get(), getFunctionDeclaration(D));
 
-  if (IsDeclForCallSite)
-Fn->setSubprogram(SP);
+  // ObjC expects declarations within retained types.
+  if (!IsDeclForCallSite) {
+DBuilder.retainType(SP);
+return;
+  }
 
-  DBuilder.retainType(SP);
+  Fn->setSubprogram(SP);
+  DBuilder.finalizeSubprogram(SP);
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,


Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug-info-extern-call.c
@@ -1,6 +1,10 @@
 // When entry values are emitted, expect a subprogram for extern decls so that
 // the dwarf generator can describe call site parameters at extern call sites.
 //
+// Initial implementation relied on the 'retainedTypes:' from the corresponding
+// DICompileUnit, so we also ensure that we do not store the extern declaration
+// subprogram into the 'retainedTypes:'.
+//
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
 
@@ -17,6 +21,8 @@
 // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
 
+// DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: ![[RETTYPES:[0-9]+]]
+// DECLS-FOR-EXTERN-NOT: ![[RETTYPES]] = !{
 // DECLS-FOR-EXTERN: !DISubprogram(name: "fn1"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
 // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3868,10 +3868,14 @@
   getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
   TParamsArray.get(), getFunctionDeclaration(D));
 
-  if (IsDeclForCallSite)
-Fn->setSubprogram(SP);
+  // ObjC expects declarations within retained types.
+  if (!IsDeclForCallSite) {
+DBuilder.retainType(SP);
+return;
+  }
 
-  DBuilder.retainType(SP);
+  Fn->setSubprogram(SP);
+  DBuilder.finalizeSubprogram(SP);
 }
 
 void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80369: [DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

2020-05-22 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D80369#2050022 , @dblaikie wrote:

> In D80369#2048932 , @djtodoro wrote:
>
> > Still have test failing:
> >
> >   Clang :: Modules/DebugInfoTransitiveImport.m
> >   Clang :: Modules/ModuleDebugInfo.cpp
> >   Clang :: Modules/ModuleDebugInfo.m
> >   
> >
> > I haven't looked into the failures, but I guess something Objective-C++ 
> > related should be handled with some additional work here.
>
>
> These look like over-constrained/accidental tests. At least the 
> ModuleDEbugInfo.m test - the type being tested for won't be emitted, because 
> the type itself isn't in the retained types list nor is it reachable from any 
> other metadata that is going to be emitted.
>
> I think it'd probably be good to clean these tests up - and leave it to 
> @aprantl to look into if this has exposed other bugs - but the bugs are 
> already there, and this IR/debug info metadata isn't working around the bugs, 
> since the IR is going unused anyway.


Looks like ObjC expects the declarations within retained types  (based on some 
tests failures), so I left it as is (I think @aprantl can help us with that).
Therefore, this patch will remove the declarations only in the case of call 
site debug info for now.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80369/new/

https://reviews.llvm.org/D80369



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80369: [DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

2020-05-27 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

>> @dblaikie wrote:
> 
> ... At least for the C++ test, this change makes it pass:
> 
>   diff --git clang/test/Modules/ModuleDebugInfo.cpp 
> clang/test/Modules/ModuleDebugInfo.cpp
>   index 26369c89605..b1ffe27ec22 100644
>   --- clang/test/Modules/ModuleDebugInfo.cpp
>   +++ clang/test/Modules/ModuleDebugInfo.cpp
>   @@ -51,15 +51,6 @@
>// CHECK-SAME: )
>// CHECK: !DIEnumerator(name: "e5", value: 5, isUnsigned: true)
>
>   -// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
>   -// no mangled name here yet.
>   -
>   -// This type is anchored by a function parameter.
>   -// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
>   -// CHECK-SAME: elements:
>   -// CHECK-SAME: templateParams:
>   -// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
>   -
>// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
>// CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
>
>   @@ -85,6 +76,12 @@
>// CHECK-SAME: templateParams:
>// CHECK-SAME: identifier: 
> "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl")
>
>   +// This type is anchored by a function parameter.
>   +// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
>   +// CHECK-SAME: elements:
>   +// CHECK-SAME: templateParams:
>   +// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
>   +
>// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstantiation"
>// no mangled name here yet.
>
>   @@ -93,6 +90,9 @@
>// CHECK-SAME: flags: DIFlagFwdDecl
>// CHECK-SAME: identifier: 
> "_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
>
>   +// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
>   +// no mangled name here yet.
>   +
>// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Virtual"
>// CHECK-SAME: elements:
>// CHECK-SAME: identifier: "_ZTS7Virtual")

I've also faced this scenario, but the problem was with the 
`Modules/ModuleDebugInfo.m` (Objective-C) test, since after applying previous 
version of the patch [0] (plus refacotred Modules/DebugInfoTransitiveImport.m & 
Modules/ModuleDebugInfo.cpp) there wasn't any `DISubprogram` at all, and that 
was the reason I made this version of the patch.

[0]: F12010783: debuginfo-remove-decls-from-ret-types.patch 



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80369/new/

https://reviews.llvm.org/D80369



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80369: [DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

2020-05-28 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D80369#2057866 , @dblaikie wrote:

> Not sure I follow - why was it a problem that there was no DISubprogram at 
> all?


Actually, since the DISubprograms from the retained types don't affect the 
final DWARF, it's not a problem at all. :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80369/new/

https://reviews.llvm.org/D80369



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80369: [DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

2020-05-28 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 266776.
djtodoro added a comment.

-Tests clean up


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80369/new/

https://reviews.llvm.org/D80369

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-call.c
  clang/test/Modules/DebugInfoTransitiveImport.m
  clang/test/Modules/ModuleDebugInfo.cpp
  clang/test/Modules/ModuleDebugInfo.m

Index: clang/test/Modules/ModuleDebugInfo.m
===
--- clang/test/Modules/ModuleDebugInfo.m
+++ clang/test/Modules/ModuleDebugInfo.m
@@ -36,19 +36,13 @@
 // CHECK-NOT:  name:
 // CHECK-SAME: elements:
 
-// CHECK: !DISubprogram(name: "+[ObjCClass classMethod]",
-// CHECK-SAME:  scope: ![[MODULE]],
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
+// CHECK-SAME: scope: ![[MODULE]],
 
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
 // CHECK-SAME: scope: ![[MODULE]],
 // CHECK-SAME: elements
 
-// The forward declaration should not be in the module scope.
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file
-
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
-// CHECK-SAME: scope: ![[MODULE]],
-
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars",
 // CHECK-SAME: scope: ![[MODULE]],
 // CHECK-SAME: elements
@@ -85,11 +79,8 @@
 // The output order is sublty different for module vs. pch,
 // so these are checked separately:
 //
-// CHECK2: !DISubprogram(name: "+[ObjCClass classMethod]"
-// CHECK2: !DISubprogram(name: "-[ObjCClass instanceMethodWithInt:]"
+// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
 // CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
 // CHECK2: !DIObjCProperty(name: "property",
 // CHECK2: !DIDerivedType(tag: DW_TAG_member, name: "ivar"
-// CHECK2: !DISubprogram(name: "-[Category(Category) categoryMethod]"
-// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
 // CHECK2: !DIDerivedType(tag: DW_TAG_typedef, name: "InnerEnum"
Index: clang/test/Modules/ModuleDebugInfo.cpp
===
--- clang/test/Modules/ModuleDebugInfo.cpp
+++ clang/test/Modules/ModuleDebugInfo.cpp
@@ -51,15 +51,6 @@
 // CHECK-SAME: )
 // CHECK: !DIEnumerator(name: "e5", value: 5, isUnsigned: true)
 
-// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
-// no mangled name here yet.
-
-// This type is anchored by a function parameter.
-// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
-// CHECK-SAME: elements:
-// CHECK-SAME: templateParams:
-// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
-
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
 
@@ -85,6 +76,12 @@
 // CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl")
 
+// This type is anchored by a function parameter.
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
+// CHECK-SAME: elements:
+// CHECK-SAME: templateParams:
+// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
+
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstantiation"
 // no mangled name here yet.
 
@@ -93,6 +90,9 @@
 // CHECK-SAME: flags: DIFlagFwdDecl
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
 
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
+// no mangled name here yet.
+
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Virtual"
 // CHECK-SAME: elements:
 // CHECK-SAME: identifier: "_ZTS7Virtual")
Index: clang/test/Modules/DebugInfoTransitiveImport.m
===
--- clang/test/Modules/DebugInfoTransitiveImport.m
+++ clang/test/Modules/DebugInfoTransitiveImport.m
@@ -12,10 +12,10 @@
 
 // Definition of left:
 // CHECK: !DICompileUnit({{.*}}dwoId:
-// CHECK: ![[LEFT:[0-9]+]] = !DIFile({{.*}}diamond_left.h
 // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration,
-// CHECK-SAME:  entity: ![[MODULE:.*]], file: ![[LEFT]], line: 3)
+// CHECK-SAME:  entity: ![[MODULE:.*]], file: ![[LEFT:.*]], line: 3)
 // CHECK: ![[MODULE]] = !DIModule(scope: null, name: "diamond_top"
+// CHECK: ![[LEFT]] = !DIFile({{.*}}diamond_left.h
 
 // Skeleton for top:
 // CHECK: !DICompileUnit({{.*}}splitDebugFilename: {{.*}}diamond_top{{.*}}dwoId:
Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug

[PATCH] D80369: [DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

2020-05-29 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: clang/test/Modules/ModuleDebugInfo.m:46-47
 
-// The forward declaration should not be in the module scope.
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file
-

dblaikie wrote:
> Did this type go missing with this change? (ie: was this type /only/ 
> accessible via a subprogram in the retained types list?)
Yes, it was **only** accessible via that subprogram we removed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80369/new/

https://reviews.llvm.org/D80369



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80369: [DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

2020-06-01 Thread Djordje Todorovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG40a3fcb05c83: [DebugInfo][CallSites] Remove decl subprograms 
from 'retainedTypes:' (authored by djtodoro).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80369/new/

https://reviews.llvm.org/D80369

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-call.c
  clang/test/Modules/DebugInfoTransitiveImport.m
  clang/test/Modules/ModuleDebugInfo.cpp
  clang/test/Modules/ModuleDebugInfo.m

Index: clang/test/Modules/ModuleDebugInfo.m
===
--- clang/test/Modules/ModuleDebugInfo.m
+++ clang/test/Modules/ModuleDebugInfo.m
@@ -36,19 +36,13 @@
 // CHECK-NOT:  name:
 // CHECK-SAME: elements:
 
-// CHECK: !DISubprogram(name: "+[ObjCClass classMethod]",
-// CHECK-SAME:  scope: ![[MODULE]],
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
+// CHECK-SAME: scope: ![[MODULE]],
 
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
 // CHECK-SAME: scope: ![[MODULE]],
 // CHECK-SAME: elements
 
-// The forward declaration should not be in the module scope.
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file
-
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
-// CHECK-SAME: scope: ![[MODULE]],
-
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars",
 // CHECK-SAME: scope: ![[MODULE]],
 // CHECK-SAME: elements
@@ -85,11 +79,8 @@
 // The output order is sublty different for module vs. pch,
 // so these are checked separately:
 //
-// CHECK2: !DISubprogram(name: "+[ObjCClass classMethod]"
-// CHECK2: !DISubprogram(name: "-[ObjCClass instanceMethodWithInt:]"
+// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
 // CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
 // CHECK2: !DIObjCProperty(name: "property",
 // CHECK2: !DIDerivedType(tag: DW_TAG_member, name: "ivar"
-// CHECK2: !DISubprogram(name: "-[Category(Category) categoryMethod]"
-// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
 // CHECK2: !DIDerivedType(tag: DW_TAG_typedef, name: "InnerEnum"
Index: clang/test/Modules/ModuleDebugInfo.cpp
===
--- clang/test/Modules/ModuleDebugInfo.cpp
+++ clang/test/Modules/ModuleDebugInfo.cpp
@@ -51,15 +51,6 @@
 // CHECK-SAME: )
 // CHECK: !DIEnumerator(name: "e5", value: 5, isUnsigned: true)
 
-// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
-// no mangled name here yet.
-
-// This type is anchored by a function parameter.
-// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
-// CHECK-SAME: elements:
-// CHECK-SAME: templateParams:
-// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
-
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
 
@@ -85,6 +76,12 @@
 // CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIl")
 
+// This type is anchored by a function parameter.
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
+// CHECK-SAME: elements:
+// CHECK-SAME: templateParams:
+// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
+
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstantiation"
 // no mangled name here yet.
 
@@ -93,6 +90,9 @@
 // CHECK-SAME: flags: DIFlagFwdDecl
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
 
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
+// no mangled name here yet.
+
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Virtual"
 // CHECK-SAME: elements:
 // CHECK-SAME: identifier: "_ZTS7Virtual")
Index: clang/test/Modules/DebugInfoTransitiveImport.m
===
--- clang/test/Modules/DebugInfoTransitiveImport.m
+++ clang/test/Modules/DebugInfoTransitiveImport.m
@@ -12,10 +12,10 @@
 
 // Definition of left:
 // CHECK: !DICompileUnit({{.*}}dwoId:
-// CHECK: ![[LEFT:[0-9]+]] = !DIFile({{.*}}diamond_left.h
 // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration,
-// CHECK-SAME:  entity: ![[MODULE:.*]], file: ![[LEFT]], line: 3)
+// CHECK-SAME:  entity: ![[MODULE:.*]], file: ![[LEFT:.*]], line: 3)
 // CHECK: ![[MODULE]] = !DIModule(scope: null, name: "diamond_top"
+// CHECK: ![[LEFT]] = !DIFile({{.*}}diamond_left.h
 
 // Skeleton for top:
 // CHECK: !DICompileUnit({{.*}}splitDebugFilename: {{.*}}diamond_top{{.*}}dwoId:
Index: clang/test/CodeGen/debug-info-extern-ca

[PATCH] D80369: [DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

2020-06-01 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Thanks for the reviews!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80369/new/

https://reviews.llvm.org/D80369



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83048: [LiveDebugValues] 3/4 Add Xclang and CodeGen options for using instr-ref variable locations

2020-07-02 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Please add a test case for the Driver option (you can take a look into existing 
ones within `clang/test/Driver/`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83048/new/

https://reviews.llvm.org/D83048



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-07-06 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked 2 inline comments as done.
djtodoro added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:855
 
+class ClangCustomPassManager : public legacy::PassManager {
+public:

vsk wrote:
> Please factor out OptCustomPassManager from opt and generalize it so it can 
> be used by both opt and clang. That should help ensure that extensions and 
> bug fixes are only made to one custom 'debugify' pass manager.
I'll try that with the latest code. I remember I've tried it once, but I ended 
up moving it into the IR library (since we need to link it within legacy pass 
manager).



Comment at: clang/lib/CodeGen/BackendUtil.cpp:893
+
+  void enableDebugifyEachOriginal() { DebugifyEachOriginalEnabled = true; }
+

vsk wrote:
> I don't think the discussion from 'RFC: Introduce LLVM DI Checker utility' is 
> complete, and I'd ask that you split off changes for 'original mode' from 
> this patch until there's some consensus about what that mode should look like.
> 
> There are open questions about to what extent a new mode is needed (e.g., it 
> may be that the interesting questions compiler developers need to answer 
> about debug info loss are simpler to determine some other way (which is not 
> to say that that's true -- just that we haven't explored the space much 
> yet)). Or what its output should look like.
OK, I'll split off this and notify you/resend a message on the RFC.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-07-08 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:855
 
+class ClangCustomPassManager : public legacy::PassManager {
+public:

djtodoro wrote:
> vsk wrote:
> > Please factor out OptCustomPassManager from opt and generalize it so it can 
> > be used by both opt and clang. That should help ensure that extensions and 
> > bug fixes are only made to one custom 'debugify' pass manager.
> I'll try that with the latest code. I remember I've tried it once, but I 
> ended up moving it into the IR library (since we need to link it within 
> legacy pass manager).
Hi @vsk, I've posted the patch as D83391. Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-07-08 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 276398.
djtodoro added a comment.

- Rebase on top of D83391 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/debugify-each-original.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -317,6 +317,16 @@
 
   $ llvm-debugify-original.py sample.json sample.html
 
+The `original` mode can be invoked from front-end level as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fenable-debugify-each-original -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fenable-debugify-each-original -Xclang -fenable-debugify-original-export=sample.json -g -O2 sample.c
+
 Using ``debugify``
 ^^
 
Index: clang/test/Driver/debugify-each-original.c
===
--- /dev/null
+++ clang/test/Driver/debugify-each-original.c
@@ -0,0 +1,14 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fenable-debugify-each-original -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEBUGIFY %s
+
+// DEBUGIFY: "-fenable-debugify-each-original"
+
+// RUN: %clang -g -Xclang -fenable-debugify-each-original \
+// RUN: -Xclang -fenable-debugify-original-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEBUGIFY-JSON-EXPORT %s
+
+// DEBUGIFY-JSON-EXPORT: "-fenable-debugify-each-original"
+// DEBUGIFY-JSON-EXPORT: "-fenable-debugify-original-export={{.*}}"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -791,6 +791,16 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDebugifyEachOriginal =
+  Args.hasArg(OPT_fenable_debugify_each_original);
+  // Ignore the option if the -fenable-debugify-each-original wasn't enabled.
+  if (Opts.EnableDebugifyEachOriginal &&
+  Args.hasArg(OPT_fenable_debugify_original_export)) {
+  Opts.DIBugsReportFilePath =
+  std::string(
+  Args.getLastArgValue(OPT_fenable_debugify_original_export));
+  }
+
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -76,6 +76,7 @@
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/Debugify.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
@@ -867,7 +868,14 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  legacy::PassManager PerModulePasses;
+  llvm::legacy::DebugifyCustomPassManager PerModulePasses;
+  if (CodeGenOpts.EnableDebugifyEachOriginal) {
+PerModulePasses.enableDebugifyEachOriginal();
+
+if (!CodeGenOpts.DIBugsReportFilePath.empty())
+  PerModulePasses.setDebugifyOriginalBugsReportFilePath(
+  CodeGenOpts.DIBugsReportFilePath);
+  }
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -389,6 +389,16 @@
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
 HelpText<"Disables debug printing for the new pass manager">;
+def fenable_debugify_each_original
+: Flag<["-"], "fenable-debugify-each-original">,
+  HelpText<"Enable Debug Info Metadata preservation testing in "
+   "optimizations.">;
+def fenable_debugify_original_export
+: Joined<["-"], "fenable-debugify-original-export=">,
+  MetaVarName<"">,
+  HelpText<"Export debugify (by testing original Debug Info) failures into "
+   "specified (JSON) file (should be abs path as we use "
+   "append

[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-07-14 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 277781.
djtodoro added a comment.
Herald added a subscriber: dang.

- Rebase


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/debugify-each-original.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -317,6 +317,16 @@
 
   $ llvm-debugify-original.py sample.json sample.html
 
+The `original` mode can be invoked from front-end level as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fenable-debugify-each-original -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fenable-debugify-each-original -Xclang -fenable-debugify-original-export=sample.json -g -O2 sample.c
+
 Using ``debugify``
 ^^
 
Index: clang/test/Driver/debugify-each-original.c
===
--- /dev/null
+++ clang/test/Driver/debugify-each-original.c
@@ -0,0 +1,14 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fenable-debugify-each-original -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEBUGIFY %s
+
+// DEBUGIFY: "-fenable-debugify-each-original"
+
+// RUN: %clang -g -Xclang -fenable-debugify-each-original \
+// RUN: -Xclang -fenable-debugify-original-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEBUGIFY-JSON-EXPORT %s
+
+// DEBUGIFY-JSON-EXPORT: "-fenable-debugify-each-original"
+// DEBUGIFY-JSON-EXPORT: "-fenable-debugify-original-export={{.*}}"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -791,6 +791,16 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDebugifyEachOriginal =
+  Args.hasArg(OPT_fenable_debugify_each_original);
+  // Ignore the option if the -fenable-debugify-each-original wasn't enabled.
+  if (Opts.EnableDebugifyEachOriginal &&
+  Args.hasArg(OPT_fenable_debugify_original_export)) {
+  Opts.DIBugsReportFilePath =
+  std::string(
+  Args.getLastArgValue(OPT_fenable_debugify_original_export));
+  }
+
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -76,6 +76,7 @@
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/Debugify.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
@@ -867,7 +868,14 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  legacy::PassManager PerModulePasses;
+  DebugifyCustomPassManager PerModulePasses;
+  if (CodeGenOpts.EnableDebugifyEachOriginal) {
+PerModulePasses.enableDebugifyEachOriginal();
+
+if (!CodeGenOpts.DIBugsReportFilePath.empty())
+  PerModulePasses.setDebugifyOriginalBugsReportFilePath(
+  CodeGenOpts.DIBugsReportFilePath);
+  }
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -389,6 +389,16 @@
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
 HelpText<"Disables debug printing for the new pass manager">;
+def fenable_debugify_each_original
+: Flag<["-"], "fenable-debugify-each-original">,
+  HelpText<"Enable Debug Info Metadata preservation testing in "
+   "optimizations.">;
+def fenable_debugify_original_export
+: Joined<["-"], "fenable-debugify-original-export=">,
+  MetaVarName<"">,
+  HelpText<"Export debugify (by testing original Debug Info) failures into "
+   "specified (JSON) file (should be abs path as we use "
+   "append mode to insert new JSON objects

[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-06-25 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro created this revision.
djtodoro added reviewers: vsk, aprantl, dblaikie, probinson.
djtodoro added projects: debug-info, LLVM.
Herald added a project: clang.
Herald added subscribers: llvm-commits, cfe-commits.
djtodoro added a parent revision: D82546: [Debugify][OriginalMode] Export the 
report into JSON file.

In order to test the preservation of the original Debug Info metadata in your 
projects, a front end option could be very useful, since users usually report 
that a concrete entity (e.g. variable `x`, or function `fn2()`) is missing 
debug info. The [0] is an example of running the utility on GDB Project.

[0] https://djolertrk.github.io/di-checker-html-report-example/


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/DebugInfo/debugify-each-original.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -317,6 +317,16 @@
 
   $ llvm-debugify-original.py sample.json sample.html
 
+The `original` mode can be invoked from front-end level as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fenable-debugify-each-original -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fenable-debugify-each-original -Xclang -fenable-debugify-original-export=sample.json -g -O2 sample.c
+
 Using ``debugify``
 ^^
 
Index: clang/test/DebugInfo/debugify-each-original.c
===
--- /dev/null
+++ clang/test/DebugInfo/debugify-each-original.c
@@ -0,0 +1,57 @@
+// RUN: %clang -g -Xclang -fenable-debugify-each-original -emit-llvm -S \
+// RUN: -O1 -o - %s 2>&1 | FileCheck %s
+
+int main()
+{
+  int x = 1;
+  int y = 2;
+  return x + y;
+}
+
+// CHECK: Force set function attributes: PASS
+// CHECK-NEXT: Infer set function attributes: PASS
+// CHECK-NEXT: Interprocedural Sparse Conditional Constant Propagation: PASS
+// CHECK-NEXT: Called Value Propagation: PASS
+// CHECK-NEXT: Global Variable Optimizer: PASS
+// CHECK-NEXT: Promote Memory to Register: PASS
+// CHECK-NEXT: Dead Argument Elimination: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Globals Alias Analysis: PASS
+// CHECK-NEXT: SROA: PASS
+// CHECK-NEXT: Early CSE w/ MemorySSA: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: Conditionally eliminate dead library calls: PASS
+// CHECK-NEXT: PGOMemOPSize: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Reassociate expressions: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: MemCpy Optimization: PASS
+// CHECK-NEXT: Sparse Conditional Constant Propagation: PASS
+// CHECK-NEXT: Bit-Tracking Dead Code Elimination: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: Aggressive Dead Code Elimination: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: A No-Op Barrier Pass: PASS
+// CHECK-NEXT: Deduce function attributes in RPO: PASS
+// CHECK-NEXT: Global Variable Optimizer: PASS
+// CHECK-NEXT: Dead Global Elimination: PASS
+// CHECK-NEXT: Globals Alias Analysis: PASS
+// CHECK-NEXT: Float to int: PASS
+// CHECK-NEXT: Lower constant intrinsics: PASS
+// CHECK-NEXT: Loop Distribution: PASS
+// CHECK-NEXT: Loop Vectorization: PASS
+// CHECK-NEXT: Loop Load Elimination: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
+// CHECK-NEXT: Optimize scalar/vector ops: PASS
+// CHECK-NEXT: Combine redundant instructions: PASS
+// CHECK-NEXT: Warn about non-applied transformations: PASS
+// CHECK-NEXT: Alignment from assumptions: PASS
+// CHECK-NEXT: Strip Unused Function Prototypes: PASS
+// CHECK-NEXT: Remove redundant instructions: PASS
+// CHECK-NEXT: Hoist/decompose integer division and remainder: PASS
+// CHECK-NEXT: Simplify the CFG: PASS
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -791,6 +791,16 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDebugifyEachOriginal =
+  Args.hasArg(OPT_fenable_debugify_each_original);
+  // Ignore the option if the -fenable-debugify-each-original wasn't enabled.
+  if (Opts.EnableDebugifyEachOriginal &&
+  Args.hasArg(OPT_fenable

[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-06-29 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: clang/test/DebugInfo/debugify-each-original.c:57
+// CHECK-NEXT: Hoist/decompose integer division and remainder: PASS
+// CHECK-NEXT: Simplify the CFG: PASS

aprantl wrote:
> aprantl wrote:
> > We probably shouldn't check the effects of LLVM passes in the Clang test 
> > suite. When someone breaks one of those LLVM passes and that shouldn't 
> > cause an error in the Clang *frontend* test suite. It's sufficient to check 
> > that the pass is passed on to LLVM here. The operation of it should be 
> > checked either in LLVM or in an end-to-end test, e.g., inside 
> > debug-info-tests.
> I probably should emphasize that an end-to-end test will probably just cause 
> us trouble: Someone will make an unrelated change to a pass, that pushes a 
> subsequent pass into a behavior that doesn't pass the debugify verifier, and 
> now the author of the unrelated patch is on the hook to fix that other pass. 
> I think that will make everyone unhappy. Maybe it should be treated more like 
> the debug info statistics?
@aprantl Thanks for your comments!

I agree with this... I refactored the test a bit, please take look.

>Maybe it should be treated more like the debug info statistics?
The final goal of this is to be used either from the python script that should 
process the JSON objects (shared within previous patch), or the JSON objects 
could be used from 
http://green.lab.llvm.org/green/view/LLDB/job/clang-3.4-debuginfo-statistics/ 
as well with some additional (groovy) scripts.



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-06-29 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 274054.
djtodoro added a comment.

-Update the test


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/DebugInfo/debugify-each-original.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -317,6 +317,16 @@
 
   $ llvm-debugify-original.py sample.json sample.html
 
+The `original` mode can be invoked from front-end level as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fenable-debugify-each-original -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fenable-debugify-each-original -Xclang -fenable-debugify-original-export=sample.json -g -O2 sample.c
+
 Using ``debugify``
 ^^
 
Index: clang/test/DebugInfo/debugify-each-original.c
===
--- /dev/null
+++ clang/test/DebugInfo/debugify-each-original.c
@@ -0,0 +1,61 @@
+// Ensure that we tested each pass with the feature, but we do not
+// check the final result here. It is up to LLVM test suite to check the real
+// logic of the functionality.
+
+// RUN: %clang -g -Xclang -fenable-debugify-each-original -emit-llvm -S \
+// RUN: -O1 -o - %s 2>&1 | FileCheck %s
+
+int main()
+{
+  int x = 1;
+  int y = 2;
+  return x + y;
+}
+
+// CHECK: Force set function attributes: {{.*}}
+// CHECK-NEXT: Infer set function attributes: {{.*}}
+// CHECK-NEXT: Interprocedural Sparse Conditional Constant Propagation: {{.*}}
+// CHECK-NEXT: Called Value Propagation: {{.*}}
+// CHECK-NEXT: Global Variable Optimizer: {{.*}}
+// CHECK-NEXT: Promote Memory to Register: {{.*}}
+// CHECK-NEXT: Dead Argument Elimination: {{.*}}
+// CHECK-NEXT: Combine redundant instructions: {{.*}}
+// CHECK-NEXT: Simplify the CFG: {{.*}}
+// CHECK-NEXT: Globals Alias Analysis: {{.*}}
+// CHECK-NEXT: SROA: {{.*}}
+// CHECK-NEXT: Early CSE w/ MemorySSA: {{.*}}
+// CHECK-NEXT: Simplify the CFG: {{.*}}
+// CHECK-NEXT: Combine redundant instructions: {{.*}}
+// CHECK-NEXT: Conditionally eliminate dead library calls: {{.*}}
+// CHECK-NEXT: PGOMemOPSize: {{.*}}
+// CHECK-NEXT: Simplify the CFG: {{.*}}
+// CHECK-NEXT: Reassociate expressions: {{.*}}
+// CHECK-NEXT: Simplify the CFG: {{.*}}
+// CHECK-NEXT: Combine redundant instructions: {{.*}}
+// CHECK-NEXT: MemCpy Optimization: {{.*}}
+// CHECK-NEXT: Sparse Conditional Constant Propagation: {{.*}}
+// CHECK-NEXT: Bit-Tracking Dead Code Elimination: {{.*}}
+// CHECK-NEXT: Combine redundant instructions: {{.*}}
+// CHECK-NEXT: Aggressive Dead Code Elimination: {{.*}}
+// CHECK-NEXT: Simplify the CFG: {{.*}}
+// CHECK-NEXT: Combine redundant instructions: {{.*}}
+// CHECK-NEXT: A No-Op Barrier {{.*}}: {{.*}}
+// CHECK-NEXT: Deduce function attributes in RPO: {{.*}}
+// CHECK-NEXT: Global Variable Optimizer: {{.*}}
+// CHECK-NEXT: Dead Global Elimination: {{.*}}
+// CHECK-NEXT: Globals Alias Analysis: {{.*}}
+// CHECK-NEXT: Float to int: {{.*}}
+// CHECK-NEXT: Lower constant intrinsics: {{.*}}
+// CHECK-NEXT: Loop Distribution: {{.*}}
+// CHECK-NEXT: Loop Vectorization: {{.*}}
+// CHECK-NEXT: Loop Load Elimination: {{.*}}
+// CHECK-NEXT: Combine redundant instructions: {{.*}}
+// CHECK-NEXT: Simplify the CFG: {{.*}}
+// CHECK-NEXT: Optimize scalar/vector ops: {{.*}}
+// CHECK-NEXT: Combine redundant instructions: {{.*}}
+// CHECK-NEXT: Warn about non-applied transformations: {{.*}}
+// CHECK-NEXT: Alignment from assumptions: {{.*}}
+// CHECK-NEXT: Strip Unused Function Prototypes: {{.*}}
+// CHECK-NEXT: Remove redundant instructions: {{.*}}
+// CHECK-NEXT: Hoist/decompose integer division and remainder: {{.*}}
+// CHECK-NEXT: Simplify the CFG: {{.*}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -791,6 +791,16 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDebugifyEachOriginal =
+  Args.hasArg(OPT_fenable_debugify_each_original);
+  // Ignore the option if the -fenable-debugify-each-original wasn't enabled.
+  if (Opts.EnableDebugifyEachOriginal &&
+  Args.hasArg(OPT_fenable_debugify_original_export)) {
+  Opts.DIOriginalBugsReportFilePath =
+  std::string(
+  Args.getLastArgValue(OPT_fenable_debugify_original_export));
+  }
+
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_re

[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-06-30 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: clang/test/DebugInfo/debugify-each-original.c:16
+// CHECK: Force set function attributes: {{.*}}
+// CHECK-NEXT: Infer set function attributes: {{.*}}
+// CHECK-NEXT: Interprocedural Sparse Conditional Constant Propagation: {{.*}}

aprantl wrote:
> I think this is still implicitly hardcoding the pass pipeline just through 
> the order of CHECK lines. If there were a way to dump the flags Clang is 
> passing to LLVM and check that, or get the pass manager to dump its 
> configuration, that would be better. I'm not sure if there is such an 
> affordance.
I see... It is hard to test it that way, but as far as I can see, it is enough 
to test only the `Driver` in situations like this, so I am adding a new test 
case and getting rid of this one.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-06-30 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 274433.
djtodoro added a comment.

- Add the Driver test
- Remove the old high level test in order to avoid troubles when someone 
updates an LLVM pass with the impact on Debugify output (e.g. a new debug info 
bugs)
- clang-formatted


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/debugify-each-original.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -317,6 +317,16 @@
 
   $ llvm-debugify-original.py sample.json sample.html
 
+The `original` mode can be invoked from front-end level as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fenable-debugify-each-original -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fenable-debugify-each-original -Xclang -fenable-debugify-original-export=sample.json -g -O2 sample.c
+
 Using ``debugify``
 ^^
 
Index: clang/test/Driver/debugify-each-original.c
===
--- /dev/null
+++ clang/test/Driver/debugify-each-original.c
@@ -0,0 +1,15 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fenable-debugify-each-original -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEBUGIFY %s
+
+// DEBUGIFY: "-fenable-debugify-each-original"
+
+// RUN: rm -rf %t.json
+// RUN: %clang -g -Xclang -fenable-debugify-each-original \
+// RUN: -Xclang -fenable-debugify-original-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEBUGIFY-JSON-EXPORT %s
+
+// DEBUGIFY-JSON-EXPORT: "-fenable-debugify-each-original"
+// DEBUGIFY-JSON-EXPORT: "-fenable-debugify-original-export={{.*}}"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -791,6 +791,16 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDebugifyEachOriginal =
+  Args.hasArg(OPT_fenable_debugify_each_original);
+  // Ignore the option if the -fenable-debugify-each-original wasn't enabled.
+  if (Opts.EnableDebugifyEachOriginal &&
+  Args.hasArg(OPT_fenable_debugify_original_export)) {
+  Opts.DIOriginalBugsReportFilePath =
+  std::string(
+  Args.getLastArgValue(OPT_fenable_debugify_original_export));
+  }
+
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -76,6 +76,7 @@
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/Debugify.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
@@ -851,6 +852,61 @@
   return true;
 }
 
+class ClangCustomPassManager : public legacy::PassManager {
+public:
+  void add(Pass *P) override {
+bool WrapWithDebugifyOriginal = DebugifyEachOriginalEnabled &&
+!P->getAsImmutablePass() &&
+!isIRPrintingPass(P);
+if (!WrapWithDebugifyOriginal) {
+  PassManager::add(P);
+  return;
+}
+
+PassKind Kind = P->getPassKind();
+StringRef Name = P->getPassName();
+
+// TODO: Implement Debugify for LoopPass.
+switch (Kind) {
+case PT_Function:
+  PassManager::add(createDebugifyFunctionPass(
+  DebugifyMode::OriginalDebugInfo, Name, &DIPreservationMap));
+  PassManager::add(P);
+  PassManager::add(createCheckDebugifyFunctionPass(
+  false, Name, nullptr, DebugifyMode::OriginalDebugInfo,
+  &DIPreservationMap, getDebugifyEachOriginalPath()));
+  break;
+case PT_Module:
+  PassManager::add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo,
+Name, &DIPreservationMap));
+  PassManager::add(P);
+  PassManager::add(createCheckDebugifyModulePass(
+  false, Name, nullptr, DebugifyMode::OriginalDebugInfo,
+  &DIPreserva

[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-07-01 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 274690.
djtodoro added a comment.

- Remove redundant line from the test


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/debugify-each-original.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -317,6 +317,16 @@
 
   $ llvm-debugify-original.py sample.json sample.html
 
+The `original` mode can be invoked from front-end level as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fenable-debugify-each-original -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fenable-debugify-each-original -Xclang -fenable-debugify-original-export=sample.json -g -O2 sample.c
+
 Using ``debugify``
 ^^
 
Index: clang/test/Driver/debugify-each-original.c
===
--- /dev/null
+++ clang/test/Driver/debugify-each-original.c
@@ -0,0 +1,14 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fenable-debugify-each-original -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEBUGIFY %s
+
+// DEBUGIFY: "-fenable-debugify-each-original"
+
+// RUN: %clang -g -Xclang -fenable-debugify-each-original \
+// RUN: -Xclang -fenable-debugify-original-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEBUGIFY-JSON-EXPORT %s
+
+// DEBUGIFY-JSON-EXPORT: "-fenable-debugify-each-original"
+// DEBUGIFY-JSON-EXPORT: "-fenable-debugify-original-export={{.*}}"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -791,6 +791,16 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDebugifyEachOriginal =
+  Args.hasArg(OPT_fenable_debugify_each_original);
+  // Ignore the option if the -fenable-debugify-each-original wasn't enabled.
+  if (Opts.EnableDebugifyEachOriginal &&
+  Args.hasArg(OPT_fenable_debugify_original_export)) {
+  Opts.DIOriginalBugsReportFilePath =
+  std::string(
+  Args.getLastArgValue(OPT_fenable_debugify_original_export));
+  }
+
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -76,6 +76,7 @@
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/Debugify.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
@@ -851,6 +852,61 @@
   return true;
 }
 
+class ClangCustomPassManager : public legacy::PassManager {
+public:
+  void add(Pass *P) override {
+bool WrapWithDebugifyOriginal = DebugifyEachOriginalEnabled &&
+!P->getAsImmutablePass() &&
+!isIRPrintingPass(P);
+if (!WrapWithDebugifyOriginal) {
+  PassManager::add(P);
+  return;
+}
+
+PassKind Kind = P->getPassKind();
+StringRef Name = P->getPassName();
+
+// TODO: Implement Debugify for LoopPass.
+switch (Kind) {
+case PT_Function:
+  PassManager::add(createDebugifyFunctionPass(
+  DebugifyMode::OriginalDebugInfo, Name, &DIPreservationMap));
+  PassManager::add(P);
+  PassManager::add(createCheckDebugifyFunctionPass(
+  false, Name, nullptr, DebugifyMode::OriginalDebugInfo,
+  &DIPreservationMap, getDebugifyEachOriginalPath()));
+  break;
+case PT_Module:
+  PassManager::add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo,
+Name, &DIPreservationMap));
+  PassManager::add(P);
+  PassManager::add(createCheckDebugifyModulePass(
+  false, Name, nullptr, DebugifyMode::OriginalDebugInfo,
+  &DIPreservationMap, getDebugifyEachOriginalPath()));
+  break;
+default:
+  PassManager::add(P);
+  break;
+}
+  }
+
+  void enableDebugifyEachOriginal() { DebugifyEachOriginalE

[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-07-01 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: clang/test/Driver/debugify-each-original.c:9
+
+// RUN: rm -rf %t.json
+// RUN: %clang -g -Xclang -fenable-debugify-each-original \

aprantl wrote:
> I think this is redundant?
It is, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78105: [CSInfo][ISEL] Call site info generation support for Mips

2020-05-15 Thread Djordje Todorovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG170ac4be3392: [CSInfo][ISEL] Call site info generation 
support for Mips (authored by djtodoro).
Herald added subscribers: cfe-commits, jrtc27.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78105/new/

https://reviews.llvm.org/D78105

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/lib/Target/Mips/MipsISelLowering.cpp
  llvm/lib/Target/Mips/MipsTargetMachine.cpp
  llvm/test/CodeGen/Mips/call-site-info-output.ll
  llvm/test/CodeGen/Mips/dbg-call-site-info-reg-d-split.ll
  llvm/test/DebugInfo/Mips/dw_op_entry_value_32bit.ll
  llvm/test/DebugInfo/Mips/dw_op_entry_value_64bit.ll

Index: llvm/test/DebugInfo/Mips/dw_op_entry_value_64bit.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/Mips/dw_op_entry_value_64bit.ll
@@ -0,0 +1,77 @@
+;; Test mips64:
+; RUN: llc -emit-call-site-info -stop-after=livedebugvalues -mtriple=mips64-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK64
+;; Test mips64el:
+; RUN: llc -emit-call-site-info -stop-after=livedebugvalues -mtriple=mips64el-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK64el
+
+;; Built from source:
+;; extern long fn1(long,long,long);
+;; long fn2(long a, long b, long c) {
+;;   long local = fn1(a+b, c, b+10);
+;;   if (local > 10)
+;; return local + 10;
+;;   return b;
+;; }
+;; Using command:
+;; clang -g -O2 -target mips64-linux-gnu m.c -c -S -emit-llvm
+;; Confirm that info from callSites attribute is used as entry_value in DIExpression.
+
+;; Test mips64:
+; CHECK64: $a0_64 = nsw DADDu $a1_64, killed renamable $a0_64,
+; CHECK64-NEXT: DBG_VALUE $a0_64, $noreg, !15, !DIExpression(DW_OP_LLVM_entry_value, 1)
+
+;; Test mips64el:
+; CHECK64el: $a0_64 = nsw DADDu $a1_64, killed renamable $a0_64,
+; CHECK64el-NEXT: DBG_VALUE $a0_64, $noreg, !15, !DIExpression(DW_OP_LLVM_entry_value, 1)
+
+; ModuleID = 'm.c'
+source_filename = "m.c"
+target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+target triple = "mips64-unknown-linux-gnu"
+
+; Function Attrs: nounwind
+define i64 @fn2(i64 signext %a, i64 signext %b, i64 signext %c) local_unnamed_addr !dbg !13 {
+entry:
+  call void @llvm.dbg.value(metadata i64 %a, metadata !15, metadata !DIExpression()), !dbg !19
+  call void @llvm.dbg.value(metadata i64 %b, metadata !16, metadata !DIExpression()), !dbg !19
+  call void @llvm.dbg.value(metadata i64 %c, metadata !17, metadata !DIExpression()), !dbg !19
+  %add = add nsw i64 %b, %a, !dbg !19
+  %add1 = add nsw i64 %b, 10, !dbg !19
+  %call = tail call i64 @fn1(i64 signext %add, i64 signext %c, i64 signext %add1), !dbg !19
+  call void @llvm.dbg.value(metadata i64 %call, metadata !18, metadata !DIExpression()), !dbg !19
+  %cmp = icmp sgt i64 %call, 10, !dbg !23
+  %add2 = add nsw i64 %call, 10, !dbg !19
+  %retval.0 = select i1 %cmp, i64 %add2, i64 %b, !dbg !19
+  ret i64 %retval.0, !dbg !19
+}
+
+declare !dbg !4 i64 @fn1(i64 signext, i64 signext, i64 signext) local_unnamed_addr
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!8, !9, !10, !11}
+!llvm.ident = !{!12}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "m.c", directory: "/dir")
+!2 = !{}
+!3 = !{!4}
+!4 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7, !7, !7, !7}
+!7 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
+!8 = !{i32 7, !"Dwarf Version", i32 4}
+!9 = !{i32 2, !"Debug Info Version", i32 3}
+!10 = !{i32 1, !"wchar_size", i32 4}
+!11 = !{i32 7, !"PIC Level", i32 1}
+!12 = !{!"clang version 11.0.0"}
+!13 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 2, type: !5, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
+!14 = !{!15, !16, !17, !18}
+!15 = !DILocalVariable(name: "a", arg: 1, scope: !13, file: !1, line: 2, type: !7)
+!16 = !DILocalVariable(name: "b", arg: 2, scope: !13, file: !1, line: 2, type: !7)
+!17 = !DILocalVariable(name: "c", arg: 3, scope: !13, file: !1, line: 2, type: !7)
+!18 = !DILocalVariable(name: "local", scope: !13, file: !1, line: 3, type: !7)
+!19 = !DILocation(line: 0, scope: !13)
+!23 = !DILocation(line: 4, column: 13, scope: !24)
+!24 = distinct !DILexicalBlock(scope: !13, file: !1, line: 4, column: 7)
Index: llvm/test/DebugInfo/Mips/dw_op_entry_value_32bit.ll
=

[PATCH] D79967: Fix debug info for NoDebug attr

2020-05-19 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

This seems reasonable, so this change looks good to me!

@dblaikie Thanks for pointing out to the potential problems of the usage of the 
func decl !dbg in the purpose of call sites debug info. It is currently being 
stored into CU's retainedTypes field.

> That's why DISubprogram moved to be attached to an llvm::Function (previously 
> all DISubprograms were listed on the CU and DISubprograms pointed to 
> llvm::Functions) to aid in LTO

Is it only one patch or a set of patches? I'll try to find these changes in the 
log history.

I am open for the discussion about redesigning it (please wait for a comment 
from @vsk as well). :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79967/new/

https://reviews.llvm.org/D79967



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115351: [Debugify] Port verify-debuginfo-preserve to NewPM

2022-07-06 Thread Djordje Todorovic via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb5b6d3a41b4e: [Debugify] Port verify-debuginfo-preserve to 
NewPM (authored by ntesic, committed by djtodoro).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115351/new/

https://reviews.llvm.org/D115351

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Utils/Debugify.h
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/test/DebugInfo/debugify-original-no-dbg-info.ll
  llvm/test/DebugInfo/verify-di-preserve.ll
  llvm/test/Transforms/Util/Debugify/loc-only-original-mode.ll
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/NewPMDriver.h
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -206,18 +206,6 @@
 cl::desc("Start the pipeline with collecting and end it with checking of "
  "debug info preservation."));
 
-static cl::opt VerifyEachDebugInfoPreserve(
-"verify-each-debuginfo-preserve",
-cl::desc("Start each pass with collecting and end it with checking of "
- "debug info preservation."));
-
-static cl::opt
-VerifyDIPreserveExport("verify-di-preserve-export",
-   cl::desc("Export debug info preservation failures into "
-"specified (JSON) file (should be abs path as we use"
-" append mode to insert new JSON objects)"),
-   cl::value_desc("filename"), cl::init(""));
-
 static cl::opt
 PrintBreakpoints("print-breakpoints-for-testing",
  cl::desc("Print select breakpoints location for testing"));
@@ -823,7 +811,8 @@
ThinLinkOut.get(), RemarksFile.get(), Pipeline,
Passes, PluginList, OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
-   EmitModuleHash, EnableDebugify)
+   EmitModuleHash, EnableDebugify,
+   VerifyDebugInfoPreserve)
? 0
: 1;
   }
Index: llvm/tools/opt/NewPMDriver.h
===
--- llvm/tools/opt/NewPMDriver.h
+++ llvm/tools/opt/NewPMDriver.h
@@ -33,6 +33,9 @@
 extern cl::opt DebugifyEach;
 extern cl::opt DebugifyExport;
 
+extern cl::opt VerifyEachDebugInfoPreserve;
+extern cl::opt VerifyDIPreserveExport;
+
 namespace opt_tool {
 enum OutputKind {
   OK_NoOutput,
@@ -74,7 +77,7 @@
  bool ShouldPreserveAssemblyUseListOrder,
  bool ShouldPreserveBitcodeUseListOrder,
  bool EmitSummaryIndex, bool EmitModuleHash,
- bool EnableDebugify);
+ bool EnableDebugify, bool VerifyDIPreserve);
 } // namespace llvm
 
 #endif
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -49,6 +49,19 @@
 DebugifyExport("debugify-export",
cl::desc("Export per-pass debugify statistics to this file"),
cl::value_desc("filename"));
+
+cl::opt VerifyEachDebugInfoPreserve(
+"verify-each-debuginfo-preserve",
+cl::desc("Start each pass with collecting and end it with checking of "
+ "debug info preservation."));
+
+cl::opt
+VerifyDIPreserveExport("verify-di-preserve-export",
+   cl::desc("Export debug info preservation failures into "
+"specified (JSON) file (should be abs path as we use"
+" append mode to insert new JSON objects)"),
+   cl::value_desc("filename"), cl::init(""));
+
 } // namespace llvm
 
 enum class DebugLogging { None, Normal, Verbose, Quiet };
@@ -280,7 +293,7 @@
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash,
-   bool EnableDebugify) {
+   bool EnableDebugify, bool VerifyDIPreserve) {
   bool VerifyEachPass = VK == VK_VerifyEachPass;
 
   Optional P;
@@ -337,8 +350,19 @@
   PrintPassOpts);
   SI.registerCallbacks(PIC, &FAM);
   DebugifyEachInstrumentation Debugify;
-  if (DebugifyEach)
+  DebugifyStatsMap DIStatsMap;
+  DebugInfoPerPass DebugInfoBeforePass;
+  if (DebugifyEach) {
+Debugify.setDIStatsMap(DIStatsMap);
+Debugify.setDebugifyMode(DebugifyMode::SyntheticDebugInfo);
+Debugify.registerCallbacks(PIC);
+  } else if (VerifyEachDebugInfoPreserve) {
+Debugi

[PATCH] D121100: [clang][DebugInfo] clang should not generate DW_TAG_subprogram entry without DW_AT_name

2022-03-10 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Hmmm... if this should be done within compiler side, I am wondering whether 
this should be resolved in AsmPrinter/DwarfDebug instead.
@aprantl please let me know wyt?

However, it looks like that after this hack the `name` here isn't the 
appropriate one... and it looks like something that debuggers should know how 
to workout ...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121100/new/

https://reviews.llvm.org/D121100

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115622: [Debugify] Optimize debugify original mode

2022-03-18 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 416438.
djtodoro added a comment.
Herald added a project: All.

- Move the skipping into the for-loop since we want to collect metadata for the 
functions that are not observed in the previous Pass (for example the function 
wasn't of interest due to having an attribute attached that wasn't relevant for 
the previous Pass) -- the improvement is still ~2x

Again, Sorry for delay here and, @Orlando @StephenTozer thank you a lot for 
your comments!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115622/new/

https://reviews.llvm.org/D115622

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Utils/Debugify.h
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/opt/opt.cpp
  llvm/unittests/Transforms/Utils/DebugifyTest.cpp

Index: llvm/unittests/Transforms/Utils/DebugifyTest.cpp
===
--- llvm/unittests/Transforms/Utils/DebugifyTest.cpp
+++ llvm/unittests/Transforms/Utils/DebugifyTest.cpp
@@ -121,15 +121,15 @@
 
   DebugInfoDrop *P = new DebugInfoDrop();
 
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DIBeforePass;
   DebugifyCustomPassManager Passes;
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DIBeforePass);
   Passes.add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo, "",
-  &(Passes.getDebugInfoPerPassMap(;
+  &(Passes.getDebugInfoPerPass(;
   Passes.add(P);
   Passes.add(createCheckDebugifyModulePass(false, "", nullptr,
DebugifyMode::OriginalDebugInfo,
-   &(Passes.getDebugInfoPerPassMap(;
+   &(Passes.getDebugInfoPerPass(;
 
   testing::internal::CaptureStderr();
   Passes.run(*M);
@@ -172,15 +172,15 @@
 
   DebugValueDrop *P = new DebugValueDrop();
 
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DIBeforePass;
   DebugifyCustomPassManager Passes;
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DIBeforePass);
   Passes.add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo, "",
-  &(Passes.getDebugInfoPerPassMap(;
+  &(Passes.getDebugInfoPerPass(;
   Passes.add(P);
   Passes.add(createCheckDebugifyModulePass(false, "", nullptr,
DebugifyMode::OriginalDebugInfo,
-   &(Passes.getDebugInfoPerPassMap(;
+   &(Passes.getDebugInfoPerPass(;
 
   testing::internal::CaptureStderr();
   Passes.run(*M);
@@ -225,15 +225,15 @@
 
   DebugInfoDummyAnalysis *P = new DebugInfoDummyAnalysis();
 
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DIBeforePass;
   DebugifyCustomPassManager Passes;
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DIBeforePass);
   Passes.add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo, "",
-  &(Passes.getDebugInfoPerPassMap(;
+  &(Passes.getDebugInfoPerPass(;
   Passes.add(P);
   Passes.add(createCheckDebugifyModulePass(false, "", nullptr,
DebugifyMode::OriginalDebugInfo,
-   &(Passes.getDebugInfoPerPassMap(;
+   &(Passes.getDebugInfoPerPass(;
 
   testing::internal::CaptureStderr();
   Passes.run(*M);
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -829,13 +829,13 @@
   // the (-check)-debugify passes.
   DebugifyCustomPassManager Passes;
   DebugifyStatsMap DIStatsMap;
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DebugInfoBeforePass;
   if (DebugifyEach) {
 Passes.setDebugifyMode(DebugifyMode::SyntheticDebugInfo);
 Passes.setDIStatsMap(DIStatsMap);
   } else if (VerifyEachDebugInfoPreserve) {
 Passes.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
-Passes.setDIPreservationMap(DIPreservationMap);
+Passes.setDebugInfoBeforePass(DebugInfoBeforePass);
 if (!VerifyDIPreserveExport.empty())
   Passes.setOrigDIVerifyBugsReportFilePath(VerifyDIPreserveExport);
   }
@@ -855,10 +855,10 @@
   Passes.setDIStatsMap(DIStatsMap);
   Passes.add(createDebugifyModulePass());
 } else if (VerifyDebugInfoPreserve) {
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DebugInfoBeforePass);
   Passes.add(createDebugifyModulePass(
   DebugifyMode::OriginalDebugInfo, "",
-  &(Passes.getDebugInfoPerPassMap(;
+  &(Passes.getDebugInfoPerPass(;
 }

[PATCH] D115622: [Debugify] Optimize debugify original mode

2022-03-22 Thread Djordje Todorovic via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG73777b4c35a3: [Debugify] Optimize debugify original mode 
(authored by djtodoro).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115622/new/

https://reviews.llvm.org/D115622

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Utils/Debugify.h
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/opt/opt.cpp
  llvm/unittests/Transforms/Utils/DebugifyTest.cpp

Index: llvm/unittests/Transforms/Utils/DebugifyTest.cpp
===
--- llvm/unittests/Transforms/Utils/DebugifyTest.cpp
+++ llvm/unittests/Transforms/Utils/DebugifyTest.cpp
@@ -121,15 +121,15 @@
 
   DebugInfoDrop *P = new DebugInfoDrop();
 
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DIBeforePass;
   DebugifyCustomPassManager Passes;
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DIBeforePass);
   Passes.add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo, "",
-  &(Passes.getDebugInfoPerPassMap(;
+  &(Passes.getDebugInfoPerPass(;
   Passes.add(P);
   Passes.add(createCheckDebugifyModulePass(false, "", nullptr,
DebugifyMode::OriginalDebugInfo,
-   &(Passes.getDebugInfoPerPassMap(;
+   &(Passes.getDebugInfoPerPass(;
 
   testing::internal::CaptureStderr();
   Passes.run(*M);
@@ -172,15 +172,15 @@
 
   DebugValueDrop *P = new DebugValueDrop();
 
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DIBeforePass;
   DebugifyCustomPassManager Passes;
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DIBeforePass);
   Passes.add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo, "",
-  &(Passes.getDebugInfoPerPassMap(;
+  &(Passes.getDebugInfoPerPass(;
   Passes.add(P);
   Passes.add(createCheckDebugifyModulePass(false, "", nullptr,
DebugifyMode::OriginalDebugInfo,
-   &(Passes.getDebugInfoPerPassMap(;
+   &(Passes.getDebugInfoPerPass(;
 
   testing::internal::CaptureStderr();
   Passes.run(*M);
@@ -225,15 +225,15 @@
 
   DebugInfoDummyAnalysis *P = new DebugInfoDummyAnalysis();
 
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DIBeforePass;
   DebugifyCustomPassManager Passes;
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DIBeforePass);
   Passes.add(createDebugifyModulePass(DebugifyMode::OriginalDebugInfo, "",
-  &(Passes.getDebugInfoPerPassMap(;
+  &(Passes.getDebugInfoPerPass(;
   Passes.add(P);
   Passes.add(createCheckDebugifyModulePass(false, "", nullptr,
DebugifyMode::OriginalDebugInfo,
-   &(Passes.getDebugInfoPerPassMap(;
+   &(Passes.getDebugInfoPerPass(;
 
   testing::internal::CaptureStderr();
   Passes.run(*M);
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -858,13 +858,13 @@
   // the (-check)-debugify passes.
   DebugifyCustomPassManager Passes;
   DebugifyStatsMap DIStatsMap;
-  DebugInfoPerPassMap DIPreservationMap;
+  DebugInfoPerPass DebugInfoBeforePass;
   if (DebugifyEach) {
 Passes.setDebugifyMode(DebugifyMode::SyntheticDebugInfo);
 Passes.setDIStatsMap(DIStatsMap);
   } else if (VerifyEachDebugInfoPreserve) {
 Passes.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
-Passes.setDIPreservationMap(DIPreservationMap);
+Passes.setDebugInfoBeforePass(DebugInfoBeforePass);
 if (!VerifyDIPreserveExport.empty())
   Passes.setOrigDIVerifyBugsReportFilePath(VerifyDIPreserveExport);
   }
@@ -884,10 +884,10 @@
   Passes.setDIStatsMap(DIStatsMap);
   Passes.add(createDebugifyModulePass());
 } else if (VerifyDebugInfoPreserve) {
-  Passes.setDIPreservationMap(DIPreservationMap);
+  Passes.setDebugInfoBeforePass(DebugInfoBeforePass);
   Passes.add(createDebugifyModulePass(
   DebugifyMode::OriginalDebugInfo, "",
-  &(Passes.getDebugInfoPerPassMap(;
+  &(Passes.getDebugInfoPerPass(;
 }
   }
 
@@ -1026,7 +1026,7 @@
 Passes.setOrigDIVerifyBugsReportFilePath(VerifyDIPreserveExport);
   Passes.add(createCheckDebugifyModulePass(
   false, "", nullptr, DebugifyMode::OriginalDebugInfo,
- 

[PATCH] D69970: [CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood (reland with fixes)

2020-01-13 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

I guess this should be closed? :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69970/new/

https://reviews.llvm.org/D69970



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option

2020-09-17 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 292469.
djtodoro added a comment.

- Rebasing


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/verify-debug-info-preservation.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -317,6 +317,16 @@
 
   $ llvm-original-di-preservation.py sample.json sample.html
 
+The `original-di-check` mode can be invoked from front-end level as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fverify-debuginfo-preserve -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fverify-debuginfo-preserve -Xclang -fverify-debuginfo-preserve-export=sample.json -g -O2 sample.c
+
 Using ``VerifyDIPreserve``
 ^^
 
Index: clang/test/Driver/verify-debug-info-preservation.c
===
--- /dev/null
+++ clang/test/Driver/verify-debug-info-preservation.c
@@ -0,0 +1,14 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE %s
+
+// VERIFYDIPRESERVE: "-fverify-debuginfo-preserve"
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve \
+// RUN: -Xclang -fverify-debuginfo-preserve-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE-JSON-EXPORT %s
+
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve"
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve-export={{.*}}"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -835,6 +835,16 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDIPreservationVerify =
+  Args.hasArg(OPT_fverify_debuginfo_preserve);
+  // Ignore the option if the -fverify-debuginfo-preserve wasn't enabled.
+  if (Opts.EnableDIPreservationVerify &&
+  Args.hasArg(OPT_fverify_debuginfo_preserve_export)) {
+ Opts.DIBugsReportFilePath =
+  std::string(
+  Args.getLastArgValue(OPT_fverify_debuginfo_preserve_export));
+  }
+
   Opts.ValueTrackingVariableLocations =
   Args.hasArg(OPT_fexperimental_debug_variable_locations);
 
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -82,6 +82,7 @@
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include "llvm/Transforms/Utils/UniqueInternalLinkageNames.h"
+#include "llvm/Transforms/Utils/VerifyDIPreserve.h"
 #include 
 using namespace clang;
 using namespace llvm;
@@ -893,7 +894,17 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  legacy::PassManager PerModulePasses;
+  VerifyDIPreserveCustomPassManager PerModulePasses;
+  DebugInfoPerPassMap DIPreservationMap;
+  if (CodeGenOpts.EnableDIPreservationVerify) {
+PerModulePasses.setVerifyDIPreserveMode(
+VerifyDIPreserveMode::OriginalDebugInfo);
+PerModulePasses.setDIPreservationMap(DIPreservationMap);
+
+if (!CodeGenOpts.DIBugsReportFilePath.empty())
+  PerModulePasses.setOrigDIVerifyBugsReportFilePath(
+  CodeGenOpts.DIBugsReportFilePath);
+  }
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3894,6 +3894,16 @@
 def fexperimental_debug_variable_locations : Flag<["-"],
 "fexperimental-debug-variable-locations">,
 HelpText<"Use experimental new value-tracking variable locations">;
+def fverify_debuginfo_preserve
+: Flag<["-"], "fverify-debuginfo-preserve">,
+  HelpText<"Enable Debug Info Metadata preservation testing in "
+   "optimizations.">;
+def fverify_debuginfo_preserve_export
+: Joined<["-"], "fverify-debuginfo-preserve-export=">,
+  MetaVarName<"">,
+  HelpText<"Export debug info (by testing original Debug Info) failures "
+   "into specified (JSON) file (should be abs path as we use "
+   "append mode to insert new JSON objects)."

[PATCH] D82547: [VerifyDIPreserve] Expose original debuginfo preservation check as CC1 option

2020-09-28 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 294658.
djtodoro added a comment.

-Rebasing


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/verify-debug-info-preservation.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -317,6 +317,16 @@
 
   $ llvm-original-di-preservation.py sample.json sample.html
 
+The `original-di-check` mode can be invoked from front-end level as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fverify-debuginfo-preserve -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fverify-debuginfo-preserve -Xclang -fverify-debuginfo-preserve-export=sample.json -g -O2 sample.c
+
 Using ``VerifyDIPreserve``
 ^^
 
Index: clang/test/Driver/verify-debug-info-preservation.c
===
--- /dev/null
+++ clang/test/Driver/verify-debug-info-preservation.c
@@ -0,0 +1,14 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE %s
+
+// VERIFYDIPRESERVE: "-fverify-debuginfo-preserve"
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve \
+// RUN: -Xclang -fverify-debuginfo-preserve-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE-JSON-EXPORT %s
+
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve"
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve-export={{.*}}"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -835,6 +835,16 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDIPreservationVerify =
+  Args.hasArg(OPT_fverify_debuginfo_preserve);
+  // Ignore the option if the -fverify-debuginfo-preserve wasn't enabled.
+  if (Opts.EnableDIPreservationVerify &&
+  Args.hasArg(OPT_fverify_debuginfo_preserve_export)) {
+ Opts.DIBugsReportFilePath =
+  std::string(
+  Args.getLastArgValue(OPT_fverify_debuginfo_preserve_export));
+  }
+
   Opts.ValueTrackingVariableLocations =
   Args.hasArg(OPT_fexperimental_debug_variable_locations);
 
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -82,6 +82,7 @@
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include "llvm/Transforms/Utils/UniqueInternalLinkageNames.h"
+#include "llvm/Transforms/Utils/VerifyDIPreserve.h"
 #include 
 using namespace clang;
 using namespace llvm;
@@ -894,7 +895,17 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  legacy::PassManager PerModulePasses;
+  VerifyDIPreserveCustomPassManager PerModulePasses;
+  DebugInfoPerPassMap DIPreservationMap;
+  if (CodeGenOpts.EnableDIPreservationVerify) {
+PerModulePasses.setVerifyDIPreserveMode(
+VerifyDIPreserveMode::OriginalDebugInfo);
+PerModulePasses.setDIPreservationMap(DIPreservationMap);
+
+if (!CodeGenOpts.DIBugsReportFilePath.empty())
+  PerModulePasses.setOrigDIVerifyBugsReportFilePath(
+  CodeGenOpts.DIBugsReportFilePath);
+  }
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3911,6 +3911,16 @@
 def fexperimental_debug_variable_locations : Flag<["-"],
 "fexperimental-debug-variable-locations">,
 HelpText<"Use experimental new value-tracking variable locations">;
+def fverify_debuginfo_preserve
+: Flag<["-"], "fverify-debuginfo-preserve">,
+  HelpText<"Enable Debug Info Metadata preservation testing in "
+   "optimizations.">;
+def fverify_debuginfo_preserve_export
+: Joined<["-"], "fverify-debuginfo-preserve-export=">,
+  MetaVarName<"">,
+  HelpText<"Export debug info (by testing original Debug Info) failures "
+   "into specified (JSON) file (should be abs path as we use "
+   "append mode to insert new JSON objects).">

[PATCH] D83048: [LiveDebugValues] 3/4 Add Xclang and CodeGen options for using instr-ref variable locations

2020-08-24 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro accepted this revision.
djtodoro added a comment.
This revision is now accepted and ready to land.

nit included, otherwise lgtm, thanks!




Comment at: llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp:45
+  ~LiveDebugValues()
+  {
+if (TheImpl)

is this clang-formatted?




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83048/new/

https://reviews.llvm.org/D83048

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-02-24 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 326005.
djtodoro retitled this revision from "[VerifyDIPreserve] Expose original 
debuginfo preservation check as CC1 option" to "[Debugify] Expose original 
debug info preservation check as CC1 option".
djtodoro added a comment.
Herald added subscribers: jansvoboda11, dexonsmith.

- Rebase on top of trunk


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/verify-debug-info-preservation.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -376,6 +376,17 @@
 
   $ llvm-original-di-preservation.py sample.json sample.html
 
+Testing of original debug info preservation can be invoked from front-end level
+as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fverify-debuginfo-preserve -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fverify-debuginfo-preserve -Xclang -fverify-debuginfo-preserve-export=sample.json -g -O2 sample.c
+
 Mutation testing for MIR-level transformations
 --
 
Index: clang/test/Driver/verify-debug-info-preservation.c
===
--- /dev/null
+++ clang/test/Driver/verify-debug-info-preservation.c
@@ -0,0 +1,14 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE %s
+
+// VERIFYDIPRESERVE: "-fverify-debuginfo-preserve"
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve \
+// RUN: -Xclang -fverify-debuginfo-preserve-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE-JSON-EXPORT %s
+
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve"
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve-export={{.*}}"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1634,6 +1634,16 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDIPreservationVerify =
+  Args.hasArg(OPT_fverify_debuginfo_preserve);
+  // Ignore the option if the -fverify-debuginfo-preserve wasn't enabled.
+  if (Opts.EnableDIPreservationVerify &&
+  Args.hasArg(OPT_fverify_debuginfo_preserve_export)) {
+ Opts.DIBugsReportFilePath =
+  std::string(
+  Args.getLastArgValue(OPT_fverify_debuginfo_preserve_export));
+  }
+
   Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
Args.hasArg(OPT_new_struct_path_tbaa);
   Opts.OptimizeSize = getOptimizationLevelSize(Args);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -85,6 +85,7 @@
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include "llvm/Transforms/Utils/UniqueInternalLinkageNames.h"
+#include "llvm/Transforms/Utils/Debugify.h"
 #include 
 using namespace clang;
 using namespace llvm;
@@ -926,7 +927,17 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  legacy::PassManager PerModulePasses;
+  DebugifyCustomPassManager PerModulePasses;
+  DebugInfoPerPassMap DIPreservationMap;
+  if (CodeGenOpts.EnableDIPreservationVerify) {
+PerModulePasses.setDebugifyMode(
+DebugifyMode::OriginalDebugInfo);
+PerModulePasses.setDIPreservationMap(DIPreservationMap);
+
+if (!CodeGenOpts.DIBugsReportFilePath.empty())
+  PerModulePasses.setOrigDIVerifyBugsReportFilePath(
+  CodeGenOpts.DIBugsReportFilePath);
+  }
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4788,6 +4788,16 @@
 "fexperimental-debug-variable-locations">,
 HelpText<"Use experimental new value-tracking variable locations">,
 MarshallingInfoFlag>;
+def fverify_debuginfo_preserve
+: Flag<["-"], "fverify-debuginfo-preserve">,
+  HelpText<"Enable Debug Info Metadata preservation testing in "
+   "optimizations

[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-02-26 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Ping :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-03-11 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 329972.
djtodoro added a comment.

- rebase on top of trunk
- refactor the code

ping :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/verify-debug-info-preservation.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -376,6 +376,17 @@
 
   $ llvm-original-di-preservation.py sample.json sample.html
 
+Testing of original debug info preservation can be invoked from front-end level
+as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fverify-debuginfo-preserve -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fverify-debuginfo-preserve -Xclang -fverify-debuginfo-preserve-export=sample.json -g -O2 sample.c
+
 Mutation testing for MIR-level transformations
 --
 
Index: clang/test/Driver/verify-debug-info-preservation.c
===
--- /dev/null
+++ clang/test/Driver/verify-debug-info-preservation.c
@@ -0,0 +1,14 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE %s
+
+// VERIFYDIPRESERVE: "-fverify-debuginfo-preserve"
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve \
+// RUN: -Xclang -fverify-debuginfo-preserve-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE-JSON-EXPORT %s
+
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve"
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve-export={{.*}}"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1641,6 +1641,14 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  Opts.EnableDIPreservationVerify = Args.hasArg(OPT_fverify_debuginfo_preserve);
+  // Ignore the option if the -fverify-debuginfo-preserve wasn't enabled.
+  if (Opts.EnableDIPreservationVerify &&
+  Args.hasArg(OPT_fverify_debuginfo_preserve_export)) {
+Opts.DIBugsReportFilePath = std::string(
+Args.getLastArgValue(OPT_fverify_debuginfo_preserve_export));
+  }
+
   Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
Args.hasArg(OPT_new_struct_path_tbaa);
   Opts.OptimizeSize = getOptimizationLevelSize(Args);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -81,6 +81,7 @@
 #include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/Debugify.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
@@ -945,7 +946,16 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  legacy::PassManager PerModulePasses;
+  DebugifyCustomPassManager PerModulePasses;
+  DebugInfoPerPassMap DIPreservationMap;
+  if (CodeGenOpts.EnableDIPreservationVerify) {
+PerModulePasses.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
+PerModulePasses.setDIPreservationMap(DIPreservationMap);
+
+if (!CodeGenOpts.DIBugsReportFilePath.empty())
+  PerModulePasses.setOrigDIVerifyBugsReportFilePath(
+  CodeGenOpts.DIBugsReportFilePath);
+  }
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4865,6 +4865,16 @@
 "fexperimental-debug-variable-locations">,
 HelpText<"Use experimental new value-tracking variable locations">,
 MarshallingInfoFlag>;
+def fverify_debuginfo_preserve
+: Flag<["-"], "fverify-debuginfo-preserve">,
+  HelpText<"Enable Debug Info Metadata preservation testing in "
+   "optimizations.">;
+def fverify_debuginfo_preserve_export
+: Joined<["-"], "fverify-debuginfo-preserve-export=">,
+  MetaVarName<"">,
+  HelpText<"Export debug info (by

[PATCH] D114504: [clang][DebugInfo] Debug support for private variables inside an OpenMP task construct

2021-11-24 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Thanks for doing this! Can you please update the summary, since it hard to read 
with the format like this (at least, just try to reformat the debugger output 
properly with the Phabricator formatters)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114504/new/

https://reviews.llvm.org/D114504

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114504: [clang][DebugInfo] Debug support for private variables inside an OpenMP task construct

2021-11-25 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

This looks reasonable to me (some nits included).




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:4513
 Scope.addPrivate(Pair.first, [Replacement]() { return Replacement; });
+if (auto *DI = CGF.getDebugInfo()) {
+  DI->EmitDeclareOfAutoVariable(Pair.first, Pair.second.getPointer(),

I think we can get rid of curly brackets.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:4515
+  DI->EmitDeclareOfAutoVariable(Pair.first, Pair.second.getPointer(),
+CGF.Builder, true);
+}




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114504/new/

https://reviews.llvm.org/D114504

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114504: [clang][DebugInfo] Debug support for private variables inside an OpenMP task construct

2021-11-25 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro accepted this revision.
djtodoro added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114504/new/

https://reviews.llvm.org/D114504

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114631: [DebugInfo][InstrRef] Turn instruction referencing on by default for x86

2021-11-30 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro accepted this revision.
djtodoro added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114631/new/

https://reviews.llvm.org/D114631

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-20 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D73534#1934105 , @vsk wrote:

> In D73534#1933988 , @djtodoro wrote:
>
> > In D73534#1933985 , @djtodoro 
> > wrote:
> >
> > > Oh sorry, I thought it all has been fixed, since all the tests pass.
> > >
> > > We should revert the D75036  until we 
> > > fix all the issues.
> >
> >
> > @dstenb do you agree?
>
>
> This was an oversight on my part, the fix from D76164 
>  was not complete. I need a few more minutes 
> to write a test, but I should be able to fix this very soon. If we can 
> fix-forward, that would be easier.


@vsk That would be great. Thanks a lot!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73534/new/

https://reviews.llvm.org/D73534



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-20 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D73534#1933985 , @djtodoro wrote:

> Oh sorry, I thought it all has been fixed, since all the tests pass.
>
> We should revert the D75036  until we fix 
> all the issues.


@dstenb do you agree?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73534/new/

https://reviews.llvm.org/D73534



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-20 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Oh sorry, I thought it all has been fixed, since all the tests pass.

We should revert the D75036  until we fix all 
the issues.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73534/new/

https://reviews.llvm.org/D73534



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-19 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 245345.
djtodoro added a comment.

- Address the issue with ARM `describeLoadedValue()` (thanks to @vsk, I've 
reduced the test 
`llvm/test/DebugInfo/MIR/ARM/dbgcallsite-noreg-is-imm-check.mir`)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73534/new/

https://reviews.llvm.org/D73534

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-extern-call.c
  clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
  lldb/packages/Python/lldbsuite/test/decorators.py
  
lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
  llvm/include/llvm/CodeGen/CommandFlags.inc
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
  llvm/lib/CodeGen/LiveDebugValues.cpp
  llvm/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
  llvm/lib/CodeGen/TargetOptionsImpl.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/AArch64/arm64-anyregcc.ll
  llvm/test/CodeGen/AArch64/arm64-patchpoint.ll
  llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
  llvm/test/CodeGen/ARM/smml.ll
  llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error3.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
  llvm/test/CodeGen/X86/call-site-info-output.ll
  llvm/test/CodeGen/X86/hoist-invariant-load.ll
  llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
  llvm/test/CodeGen/X86/statepoint-allocas.ll
  llvm/test/CodeGen/X86/tail-dup-repeat.ll
  llvm/test/CodeGen/X86/xray-custom-log.ll
  llvm/test/CodeGen/X86/xray-typed-event-log.ll
  llvm/test/DebugInfo/AArch64/call-site-info-output.ll
  llvm/test/DebugInfo/ARM/call-site-info-output.ll
  llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcallsite-noreg-is-imm-check.mir
  llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
  llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
  llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
  llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
  llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
  llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
  llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg-multiple-defs.mir
  llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
  llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
  llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
  llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
  llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
  llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
  llvm/test/DebugInfo/X86/dbg-value-range.ll
  llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
  llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
  llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
  llvm/test/DebugInfo/X86/loclists-dwp.ll
  llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll
  llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
  llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
  llvm/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll
  llvm/test/tools/llvm-locstats/locstats.ll

Index: llvm/test/tools/llvm-locs

[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-19 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D73534#1882118 , @dstenb wrote:

> In D73534#1881353 , @nickdesaulniers 
> wrote:
>
> > As a heads up, Linaro's ToolChain Working Group's Linux kernel CI lit up on 
> > this change. I see it's been reverted (thank you). Please cc me on the 
> > updated patch and I can help test it against the Linux kernel.
> >
> > Edit: Link: 
> > https://ci.linaro.org/job/tcwg_kernel-bisect-llvm-master-arm-mainline-allyesconfig/25/artifact/artifacts/build-a82d3e8a6e67473c94a5ce6345372748e9b61718/03-build_linux/console.log
>
>
> Its hard to tell from the backtrace, but looking at the code, I think this 
> might be a bug that sneaked in when I did D70431 
> . Sorry if that is the case!
>
> `ARMBaseInstrInfo::isAddImmediate()` does a `getReg()` without any `isReg()` 
> guard:
>
>   Optional ARMBaseInstrInfo::isAddImmediate(const MachineInstr 
> &MI,  
>   
>   
> 
> Register Reg) const { 
>   
>   
>   
>  
>   [...]
> // TODO: Handle cases where Reg is a super- or sub-register of the
>   
>   
>   
>  
> // destination register.
> if (Reg != MI.getOperand(0).getReg())
>   return None;
>


@dstenb No problem, we have already addressed the issue. Thanks to @vsk and 
@nickdesaulniers! I'll update the patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73534/new/

https://reviews.llvm.org/D73534



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-19 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D73534#1883022 , @nickdesaulniers 
wrote:

> In D73534#1882136 , @djtodoro wrote:
>
> > - Address the issue with ARM `describeLoadedValue()` (thanks to @vsk, I've 
> > reduced the test 
> > `llvm/test/DebugInfo/MIR/ARM/dbgcallsite-noreg-is-imm-check.mir`)
>
>
> I'd like to help test this, but `arc patch D73534` is now failing with merge 
> conflicts. Can you please rebase this on master?


I’ve already pushed this. Please rebase on the latest commits.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73534/new/

https://reviews.llvm.org/D73534



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-20 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Reverted again with rG2f215cf36adc 
. The 
investigation is needed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73534/new/

https://reviews.llvm.org/D73534



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-20 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Nice! Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73534/new/

https://reviews.llvm.org/D73534



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-20 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

@ostannard Thanks for reporting that! Please share the case.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73534/new/

https://reviews.llvm.org/D73534



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69743: [CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood

2019-11-04 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro accepted this revision.
djtodoro added a comment.
This revision is now accepted and ready to land.

@vsk Thanks for this!
(lgtm)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69743/new/

https://reviews.llvm.org/D69743



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5

2019-11-11 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:803
 
+  if (Tag == dwarf::DW_TAG_typedef && DD->getDwarfVersion() >= 5) {
+uint32_t AlignInBytes = DTy->getAlignInBytes();

Please add a comment here.



Comment at: llvm/test/DebugInfo/X86/debug-info-template-align.ll:26
+; ModuleID = 
'/home/awpandey/tools/llvm/tools/clang/test/CodeGenCXX/debug-info-template-align.cpp'
+source_filename = 
"/home/awpandey/tools/llvm/tools/clang/test/CodeGenCXX/debug-info-template-align.cpp"
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

I guess you don't want to share your local path. It is enough to write 
'test.cpp' only.



Comment at: llvm/test/DebugInfo/X86/debug-info-template-align.ll:39
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+

So, we can get rid of the `#N`.



Comment at: llvm/test/DebugInfo/X86/debug-info-template-align.ll:41
+
+attributes #0 = { noinline norecurse nounwind optnone uwtable 
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
"frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" 
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false" 
"stack-protector-buffer-size"="8" "target-cpu"="x86-64" 
"target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" 
"use-soft-float"="false" }
+attributes #1 = { nounwind readnone speculatable willreturn }

Usually, you don't need the attributes.



Comment at: llvm/test/DebugInfo/X86/debug-info-template-align.ll:48
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, 
producer: "clang version 10.0.0 
(ssh://awpan...@idcvgits02.amd.com:29418/perfcompiler/er/llvm/cpu/clang 
8b3533f5560dd219a0e6d346be2190623822bada) (llvm/cpu/llvm 
61a342a7f3320d5517ba0bd012edc7cc908b36b7)", isOptimized: false, runtimeVersion: 
0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: 
"/home/awpandey/tools/llvm/tools/clang/test/CodeGenCXX/debug-info-template-align.cpp",
 directory: "/home/awpandey/tools/llvm/test/DebugInfo", checksumkind: CSK_MD5, 
checksum: "872e252efdfcb9480b4bfaf8437f58ab")

`producer: "clang version 10.0.0"` is enough.



Comment at: llvm/test/DebugInfo/X86/debug-info-template-align.ll:49
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, 
producer: "clang version 10.0.0 
(ssh://awpan...@idcvgits02.amd.com:29418/perfcompiler/er/llvm/cpu/clang 
8b3533f5560dd219a0e6d346be2190623822bada) (llvm/cpu/llvm 
61a342a7f3320d5517ba0bd012edc7cc908b36b7)", isOptimized: false, runtimeVersion: 
0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: 
"/home/awpandey/tools/llvm/tools/clang/test/CodeGenCXX/debug-info-template-align.cpp",
 directory: "/home/awpandey/tools/llvm/test/DebugInfo", checksumkind: CSK_MD5, 
checksum: "872e252efdfcb9480b4bfaf8437f58ab")
+!2 = !{}

Usually, we put an artificial name for the dir, e.g. `/dir`.



Comment at: llvm/test/DebugInfo/X86/debug-info-template-align.ll:54
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 10.0.0 
(ssh://awpan...@idcvgits02.amd.com:29418/perfcompiler/er/llvm/cpu/clang 
8b3533f5560dd219a0e6d346be2190623822bada) (llvm/cpu/llvm 
61a342a7f3320d5517ba0bd012edc7cc908b36b7)"}
+!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 12, type: 
!9, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: 
!0, retainedNodes: !2)

` "clang version 10.0.0"` is enough.



Comment at: llvm/test/DebugInfo/X86/debug-info-template-align.ll:56
+!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 12, type: 
!9, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: 
!0, retainedNodes: !2)
+!8 = !DIFile(filename: 
"tools/clang/test/CodeGenCXX/debug-info-template-align.cpp", directory: 
"/home/awpandey/tools/llvm", checksumkind: CSK_MD5, checksum: 
"872e252efdfcb9480b4bfaf8437f58ab")
+!9 = !DISubroutineType(types: !10)

`filename: test.c, directory: "/dir"`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70111/new/

https://reviews.llvm.org/D70111



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5

2019-11-11 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

@awpandey Thanks for the patch!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70111/new/

https://reviews.llvm.org/D70111



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69970: [CGDebugInfo] Emit subprograms for decls when AT_tail_call is understood (reland with fixes)

2019-11-14 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

I think that it sounds reasonable to avoid declaration subprograms for 
functions with reserved names, so that part looks good to me.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69970/new/

https://reviews.llvm.org/D69970



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >