[PATCH] D82446: [clang] Fix duplicate warning

2020-06-24 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added reviewers: rsmith, aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes duplicate warning emitted by clang when 
char16_t/char32_t is used in the catch block.

Fixes this
https://bugs.llvm.org/show_bug.cgi?id=46425


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82446

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/cxx98-char.cpp


Index: clang/test/Parser/cxx98-char.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx98-char.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++11 -Wc++98-compat -verify=cxx11 -fcxx-exceptions %s
+void foo() 
+{ 
+try  { }
+catch (char16_t b) {} // cxx11-warning {{'char16_t' type specifier is 
incompatible with C++98}}
+catch (char32_t c) {} // cxx11-warning {{'char32_t' type specifier is 
incompatible with C++98}}
+} 
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -2270,7 +2270,6 @@
 ///
 bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) {
   ParseSpecifierQualifierList(DS, AS_none, 
DeclSpecContext::DSC_type_specifier);
-  DS.Finish(Actions, Actions.getASTContext().getPrintingPolicy());
   return false;
 }
 


Index: clang/test/Parser/cxx98-char.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx98-char.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++11 -Wc++98-compat -verify=cxx11 -fcxx-exceptions %s
+void foo() 
+{ 
+try  { }
+catch (char16_t b) {} // cxx11-warning {{'char16_t' type specifier is incompatible with C++98}}
+catch (char32_t c) {} // cxx11-warning {{'char32_t' type specifier is incompatible with C++98}}
+} 
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -2270,7 +2270,6 @@
 ///
 bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) {
   ParseSpecifierQualifierList(DS, AS_none, DeclSpecContext::DSC_type_specifier);
-  DS.Finish(Actions, Actions.getASTContext().getPrintingPolicy());
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82446: [clang] Fix duplicate warning

2020-06-24 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui marked an inline comment as done.
kamleshbhalui added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:2273
   ParseSpecifierQualifierList(DS, AS_none, 
DeclSpecContext::DSC_type_specifier);
-  DS.Finish(Actions, Actions.getASTContext().getPrintingPolicy());
   return false;

aaron.ballman wrote:
> This change is incorrect -- `Finish` is what ensures the `DeclSpec` is in a 
> consistent state (even in the presence of errors), so removing it would be 
> bad.
you are right but ParseSpecifierQualifierList ->(calls) 
ParseDeclarationSpecifiers
and it makes a call to 
Finish(https://github.com/llvm/llvm-project/blob/master/clang/lib/Parse/ParseDecl.cpp#L2962).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82446



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


[PATCH] D79504: [Clang] Wrong return type of atomic_is_lock_free

2020-05-06 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added reviewers: aaron.ballman, rsmith.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.
kamleshbhalui added a reviewer: rnk.

Fixing the return type of atomic_is_lock_free as per
https://en.cppreference.com/w/c/atomic/atomic_is_lock_free


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79504

Files:
  clang/include/clang/Basic/Builtins.def
  clang/test/CodeGen/atomic-ops.c
  clang/test/CodeGen/big-atomic-ops.c


Index: clang/test/CodeGen/big-atomic-ops.c
===
--- clang/test/CodeGen/big-atomic-ops.c
+++ clang/test/CodeGen/big-atomic-ops.c
@@ -198,20 +198,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 16, i8* 
{{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 17, i8* 
{{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 
   // CHECK-NOT: call
Index: clang/test/CodeGen/atomic-ops.c
===
--- clang/test/CodeGen/atomic-ops.c
+++ clang/test/CodeGen/atomic-ops.c
@@ -343,20 +343,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK-LABEL: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 16, i8* 
{{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 17, i8* 
{{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 
   // CHECK-NOT: call
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -724,7 +724,7 @@
 ATOMIC_BUILTIN(__c11_atomic_fetch_min, "v.", "t")
 BUILTIN(__c11_atomic_thread_fence, "vi", "n")
 BUILTIN(__c11_atomic_signal_fence, "vi", "n")
-BUILTIN(__c11_atomic_is_lock_free, "iz", "n")
+BUILTIN(__c11_atomic_is_lock_free, "bz", "n")
 
 // GNU atomic builtins.
 ATOMIC_BUILTIN(__atomic_load, "v.", "t")
@@ -754,7 +754,7 @@
 BUILTIN(__atomic_thread_fence, "vi", "n")
 BUILTIN(__atomic_signal_fence, "vi", "n")
 BUILTIN(__atomic_always_lock_free, "izvCD*", "n")
-BUILTIN(__atomic_is_lock_free, "izvCD*", "n")
+BUILTIN(__atomic_is_lock_free, "bzvCD*", "n")
 
 // OpenCL 2.0 atomic builtins.
 ATOMIC_BUILTIN(__opencl_atomic_init, "v.", "t")


Index: clang/test/CodeGen/big-atomic-ops.c
===
--- clang/test/CodeGen/big-atomic-ops.c
+++ clang/test/CodeGen/big-atomic-ops.c
@@ -198,20 +198,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: cal

[PATCH] D79504: [Clang] Wrong return type of atomic_is_lock_free

2020-05-06 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 262518.
kamleshbhalui added a comment.

Addressed @rsmith concerns.


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

https://reviews.llvm.org/D79504

Files:
  clang/include/clang/Basic/Builtins.def
  clang/test/CodeGen/atomic-ops.c
  clang/test/CodeGen/big-atomic-ops.c


Index: clang/test/CodeGen/big-atomic-ops.c
===
--- clang/test/CodeGen/big-atomic-ops.c
+++ clang/test/CodeGen/big-atomic-ops.c
@@ -198,20 +198,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 16, i8* 
{{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 17, i8* 
{{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 
   // CHECK-NOT: call
Index: clang/test/CodeGen/atomic-ops.c
===
--- clang/test/CodeGen/atomic-ops.c
+++ clang/test/CodeGen/atomic-ops.c
@@ -343,20 +343,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK-LABEL: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 16, i8* 
{{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 17, i8* 
{{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 
   // CHECK-NOT: call
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -724,7 +724,7 @@
 ATOMIC_BUILTIN(__c11_atomic_fetch_min, "v.", "t")
 BUILTIN(__c11_atomic_thread_fence, "vi", "n")
 BUILTIN(__c11_atomic_signal_fence, "vi", "n")
-BUILTIN(__c11_atomic_is_lock_free, "iz", "n")
+BUILTIN(__c11_atomic_is_lock_free, "bz", "n")
 
 // GNU atomic builtins.
 ATOMIC_BUILTIN(__atomic_load, "v.", "t")
@@ -753,8 +753,8 @@
 BUILTIN(__atomic_clear, "vvD*i", "n")
 BUILTIN(__atomic_thread_fence, "vi", "n")
 BUILTIN(__atomic_signal_fence, "vi", "n")
-BUILTIN(__atomic_always_lock_free, "izvCD*", "n")
-BUILTIN(__atomic_is_lock_free, "izvCD*", "n")
+BUILTIN(__atomic_always_lock_free, "bzvCD*", "n")
+BUILTIN(__atomic_is_lock_free, "bzvCD*", "n")
 
 // OpenCL 2.0 atomic builtins.
 ATOMIC_BUILTIN(__opencl_atomic_init, "v.", "t")


Index: clang/test/CodeGen/big-atomic-ops.c
===
--- clang/test/CodeGen/big-atomic-ops.c
+++ clang/test/CodeGen/big-atomic-ops.c
@@ -198,20 +198,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, &sixteen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, &seventeen);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 

[PATCH] D79504: [Clang] Wrong return type of atomic_is_lock_free

2020-05-08 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

I do not have commit access.


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

https://reviews.llvm.org/D79504



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


[PATCH] D79504: [Clang] Wrong return type of atomic_is_lock_free

2020-05-11 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D79504#2029267 , @ldionne wrote:

> What name and email do you want this committed with?


Kamlesh Kumar
kamleshbha...@gmail.com


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

https://reviews.llvm.org/D79504



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


[PATCH] D72565: adding __has_feature support for left c++ type_traits

2020-01-12 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added reviewers: rsmith, aaron.ballman, dblaikie, ldionne.
kamleshbhalui added a project: clang.
Herald added subscribers: cfe-commits, dexonsmith.

adding __has_feature support for left c++ type_traits.

fixes this
https://bugs.llvm.org/show_bug.cgi?id=44517


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72565

Files:
  clang/include/clang/Basic/Features.def


Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -216,6 +216,10 @@
 FEATURE(is_trivially_constructible, LangOpts.CPlusPlus)
 FEATURE(is_trivially_copyable, LangOpts.CPlusPlus)
 FEATURE(is_union, LangOpts.CPlusPlus)
+FEATURE(is_same, LangOpts.CPlusPlus)
+FEATURE(is_function, LangOpts.CPlusPlus)
+FEATURE(is_assignable, LangOpts.CPlusPlus)
+FEATURE(is_nothrow_constructible, LangOpts.CPlusPlus)
 FEATURE(modules, LangOpts.Modules)
 FEATURE(safe_stack, LangOpts.Sanitize.has(SanitizerKind::SafeStack))
 FEATURE(shadow_call_stack,


Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -216,6 +216,10 @@
 FEATURE(is_trivially_constructible, LangOpts.CPlusPlus)
 FEATURE(is_trivially_copyable, LangOpts.CPlusPlus)
 FEATURE(is_union, LangOpts.CPlusPlus)
+FEATURE(is_same, LangOpts.CPlusPlus)
+FEATURE(is_function, LangOpts.CPlusPlus)
+FEATURE(is_assignable, LangOpts.CPlusPlus)
+FEATURE(is_nothrow_constructible, LangOpts.CPlusPlus)
 FEATURE(modules, LangOpts.Modules)
 FEATURE(safe_stack, LangOpts.Sanitize.has(SanitizerKind::SafeStack))
 FEATURE(shadow_call_stack,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72565: adding __has_feature support for left c++ type_traits

2020-01-12 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui abandoned this revision.
kamleshbhalui added a comment.

not an issue since __has_builtin does the work.
i.e. __has_builtin(__is_same)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72565



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


[PATCH] D103131: support debug info for alias variable

2021-05-25 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added reviewers: dblaikie, aprantl, probinson.
kamleshbhalui added a project: LLVM.
Herald added a subscriber: jeroen.dobbelaere.
kamleshbhalui requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

consider below test demonstration
$cat test.c
int oldname = 1;
extern int newname __attribute__((alias("oldname")));

$clang -g -O0 test.c

$gdb a.out
(gdb) pt oldname
type = int
(gdb) pt newname
type = 
(gdb) p newname
'newname' has unknown type; cast it to its declared type

debugger is unable to print newname types and value because clang does not emit 
debug info for newname.
This patch supports having debug info for alias variable as imported entity.

Fixes PR50052.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103131

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/debug-info-alias.c


Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-linux-unknown %s -o - | FileCheck %s
+
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope:{{.*}}, 
entity: ![[VAR:[0-9]+]]
+// CHECK: ![[VAR]] = !DIGlobalVariable(name: "newname"
+
+int oldname = 1;
+extern int newname __attribute__((alias("oldname")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4922,6 +4922,13 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  if (getCodeGenOpts().hasReducedDebugInfo())
+DI->EmitGlobalAlias(GA, VD);
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -493,6 +493,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global alias.
+  void EmitGlobalAlias(llvm::GlobalAlias *GA, const VarDecl *Decl);
+
   /// Emit C++ using directive.
   void EmitUsingDirective(const UsingDirectiveDecl &UD);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4945,6 +4945,19 @@
   Var->addDebugInfo(GVE);
 }
 
+void CGDebugInfo::EmitGlobalAlias(llvm::GlobalAlias *Var, const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
+return;
+
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+  llvm::DIScope *DContext = getDeclContextDescriptor(D);
+  if (llvm::DINode *Target = getDeclarationOrDefinition(D)) {
+auto Loc = D->getLocation();
+DBuilder.createImportedDeclaration(DContext, Target, Unit,
+   getLineNumber(Loc));
+  }
+}
+
 llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
   if (!LexicalBlockStack.empty())
 return LexicalBlockStack.back();


Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-linux-unknown %s -o - | FileCheck %s
+
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope:{{.*}}, entity: ![[VAR:[0-9]+]]
+// CHECK: ![[VAR]] = !DIGlobalVariable(name: "newname"
+
+int oldname = 1;
+extern int newname __attribute__((alias("oldname")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4922,6 +4922,13 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  if (getCodeGenOpts().hasReducedDebugInfo())
+DI->EmitGlobalAlias(GA, VD);
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -493,6 +493,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global alias.
+  vo

[PATCH] D103131: support debug info for alias variable

2021-05-25 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D103131#2780997 , @dblaikie wrote:

> Looks like GCC emits aliases as a `DW_TAG_variable` without a location, not 
> as a `DW_TAG_imported_declaration` - what gave you the inspiration to do it 
> in this way? (I think it's probably good, but DWARF doesn't lend itself to 
> novelty so much... can be good to stick with how other folks already do 
> things since it'll be what consumers already know how to handle)
>
> How's this work if the alias target isn't declared in the source - but in 
> inline assembly instead? (I guess GCC probably handles that OK, but the Clang 
> strategy here might not cope with it)



> what gave you the inspiration to do it in this way?

Actually, I got the idea from the discussion in the defect.

> How's this work if the alias target isn't declared in the source

gcc spec says that alias target has to be in the same source.
https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
it would be great if you share an example if I misunderstood you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[PATCH] D103131: support debug info for alias variable

2021-05-26 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 347883.
kamleshbhalui retitled this revision from "support debug info for alias 
variable " to "support debug info for alias variable".
kamleshbhalui added a comment.

removed unnecessary code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/debug-info-alias.c


Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-linux-unknown %s -o - | FileCheck %s
+
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope:{{.*}}, 
entity: ![[VAR:[0-9]+]]
+// CHECK: ![[VAR]] = !DIGlobalVariable(name: "newname"
+
+int oldname = 1;
+extern int newname __attribute__((alias("oldname")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4922,6 +4922,12 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  DI->EmitGlobalAlias(VD);
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -493,6 +493,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global alias.
+  void EmitGlobalAlias(const VarDecl *Decl);
+
   /// Emit C++ using directive.
   void EmitUsingDirective(const UsingDirectiveDecl &UD);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4945,6 +4945,19 @@
   Var->addDebugInfo(GVE);
 }
 
+void CGDebugInfo::EmitGlobalAlias(const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
+return;
+
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+  llvm::DIScope *DContext = getDeclContextDescriptor(D);
+  if (llvm::DINode *Target = getDeclarationOrDefinition(D)) {
+auto Loc = D->getLocation();
+DBuilder.createImportedDeclaration(DContext, Target, Unit,
+   getLineNumber(Loc));
+  }
+}
+
 llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
   if (!LexicalBlockStack.empty())
 return LexicalBlockStack.back();


Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-linux-unknown %s -o - | FileCheck %s
+
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope:{{.*}}, entity: ![[VAR:[0-9]+]]
+// CHECK: ![[VAR]] = !DIGlobalVariable(name: "newname"
+
+int oldname = 1;
+extern int newname __attribute__((alias("oldname")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4922,6 +4922,12 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  DI->EmitGlobalAlias(VD);
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -493,6 +493,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global alias.
+  void EmitGlobalAlias(const VarDecl *Decl);
+
   /// Emit C++ using directive.
   void EmitUsingDirective(const UsingDirectiveDecl &UD);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4945,6 +4945,19 @@
   Var->addDebugInfo(GVE);
 }
 
+void CGDebugInfo::EmitGlobalAlias(const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
+return;
+
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+  llvm::DIScope *DContext = getDeclContextDescriptor(D);
+  if (llvm::DINode

[PATCH] D103131: support debug info for alias variable

2021-05-26 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 348160.
kamleshbhalui added a comment.

match gcc behavior


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/debug-info-alias.c


Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-linux-unknown %s -o - | FileCheck %s
+
+// CHECK: !DIGlobalVariable(name: "newname"
+
+int oldname = 1;
+extern int newname __attribute__((alias("oldname")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4922,6 +4922,12 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  DI->EmitGlobalAlias(VD);
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -493,6 +493,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global alias.
+  void EmitGlobalAlias(const VarDecl *Decl);
+
   /// Emit C++ using directive.
   void EmitUsingDirective(const UsingDirectiveDecl &UD);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4945,6 +4945,20 @@
   Var->addDebugInfo(GVE);
 }
 
+void CGDebugInfo::EmitGlobalAlias(const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
+return;
+
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+  StringRef Name = D->getName();
+  llvm::DIType *Ty = getOrCreateType(D->getType(), Unit);
+  llvm::DIScope *DContext = getDeclContextDescriptor(D);
+  auto Loc = getLineNumber(D->getLocation());
+  DBuilder.createGlobalVariableExpression(
+  DContext, Name, StringRef(), Unit, Loc, Ty,
+  !D->hasExternalFormalLinkage(), false);
+}
+
 llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
   if (!LexicalBlockStack.empty())
 return LexicalBlockStack.back();


Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-linux-unknown %s -o - | FileCheck %s
+
+// CHECK: !DIGlobalVariable(name: "newname"
+
+int oldname = 1;
+extern int newname __attribute__((alias("oldname")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4922,6 +4922,12 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  DI->EmitGlobalAlias(VD);
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -493,6 +493,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global alias.
+  void EmitGlobalAlias(const VarDecl *Decl);
+
   /// Emit C++ using directive.
   void EmitUsingDirective(const UsingDirectiveDecl &UD);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4945,6 +4945,20 @@
   Var->addDebugInfo(GVE);
 }
 
+void CGDebugInfo::EmitGlobalAlias(const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
+return;
+
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+  StringRef Name = D->getName();
+  llvm::DIType *Ty = getOrCreateType(D->getType(), Unit);
+  llvm::DIScope *DContext = getDeclContextDescriptor(D);
+  auto Loc = getLineNumber(D->getLocation());
+  DBuilder.createGlobalVariableExpression(
+  DContext, Name, StringRef(), Unit, Loc, Ty,
+  !D->hasExternalFormalLinkage(), false);
+}
+
 llvm::DIScope *CGDebugInfo::getCurre

[PATCH] D103131: support debug info for alias variable

2021-05-28 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 348501.
kamleshbhalui added a comment.

matching gcc behavior


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/debug-info-alias.c


Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-linux-unknown %s -o - | FileCheck %s
+
+// CHECK: !DIGlobalVariable(name: "newname"
+
+int oldname = 1;
+extern int newname __attribute__((alias("oldname")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4927,6 +4927,12 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  DI->EmitGlobalAlias(VD);
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -493,6 +493,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global alias.
+  void EmitGlobalAlias(const VarDecl *Decl);
+
   /// Emit C++ using directive.
   void EmitUsingDirective(const UsingDirectiveDecl &UD);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4945,6 +4945,20 @@
   Var->addDebugInfo(GVE);
 }
 
+void CGDebugInfo::EmitGlobalAlias(const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
+return;
+
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+  StringRef Name = D->getName();
+  llvm::DIType *Ty = getOrCreateType(D->getType(), Unit);
+  llvm::DIScope *DContext = getDeclContextDescriptor(D);
+  auto Loc = getLineNumber(D->getLocation());
+  DBuilder.createGlobalVariableExpression(
+  DContext, Name, StringRef(), Unit, Loc, Ty,
+  !D->hasExternalFormalLinkage());
+}
+
 llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
   if (!LexicalBlockStack.empty())
 return LexicalBlockStack.back();


Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-linux-unknown %s -o - | FileCheck %s
+
+// CHECK: !DIGlobalVariable(name: "newname"
+
+int oldname = 1;
+extern int newname __attribute__((alias("oldname")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4927,6 +4927,12 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  DI->EmitGlobalAlias(VD);
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -493,6 +493,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global alias.
+  void EmitGlobalAlias(const VarDecl *Decl);
+
   /// Emit C++ using directive.
   void EmitUsingDirective(const UsingDirectiveDecl &UD);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4945,6 +4945,20 @@
   Var->addDebugInfo(GVE);
 }
 
+void CGDebugInfo::EmitGlobalAlias(const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
+return;
+
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+  StringRef Name = D->getName();
+  llvm::DIType *Ty = getOrCreateType(D->getType(), Unit);
+  llvm::DIScope *DContext = getDeclContextDescriptor(D);
+  auto Loc = getLineNumber(D->getLocation());
+  DBuilder.createGlobalVariableExpression(
+  DContext, Name, StringRef(), Unit, Loc, Ty,
+  !D->hasExternalFormalLinkage());
+}
+
 llvm::DIScope *CGDebugInfo::getCurrentContextDe

[PATCH] D103131: support debug info for alias variable

2021-05-28 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

$cat test.h
int oldname;

$cat test.c

#include "test.h"
int oldname;
__asm__  (

  "movq oldname, %rsp\n\t"

);

extern int newname __attribute__((alias("oldname")));

debug info from gcc:

test.o: file format elf64-x86-64

.debug_info contents:
0x: Compile Unit: length = 0x0044, format = DWARF32, version = 
0x0005, unit_type = DW_UT_compile, abbr_offset = 0x, addr_size = 0x08 (next 
unit at 0x0048)

0x000c: DW_TAG_compile_unit

  DW_AT_producer("GNU C17 12.0.0 20210529 (experimental) -g")
  DW_AT_language(DW_LANG_C11)
  DW_AT_name("test.c")
  DW_AT_comp_dir("/folk/kkumar/tcgcc/build/")
  DW_AT_stmt_list   (0x)

0x001e:   DW_TAG_variable

  DW_AT_name  ("oldname")
  DW_AT_decl_file ("test.h")
  DW_AT_decl_line (1)
  DW_AT_decl_column   (0x05)
  DW_AT_type  (0x0034 "int")
  DW_AT_external  (true)
  DW_AT_location  (DW_OP_addr 0x0)

0x0034:   DW_TAG_base_type

  DW_AT_byte_size (0x04)
  DW_AT_encoding  (DW_ATE_signed)
  DW_AT_name  ("int")

0x003b:   DW_TAG_variable

  DW_AT_name  ("newname")
  DW_AT_decl_file ("test.c")
  DW_AT_decl_line (7)
  DW_AT_decl_column   (0x0c)
  DW_AT_type  (0x0034 "int")
  DW_AT_external  (true)

0x0047:   NULL

debug info from clang:

test1.o:file format elf64-x86-64

.debug_info contents:
0x: Compile Unit: length = 0x0042, format = DWARF32, version = 
0x0004, abbr_offset = 0x, addr_size = 0x08 (next unit at 0x0046)

0x000b: DW_TAG_compile_unit

  DW_AT_producer("clang version 13.0.0 
(g...@github.com:llvm/llvm-project.git 
b22ff948a94edc7573d226fe404a77b9a7380398)")
  DW_AT_language(DW_LANG_C99)
  DW_AT_name("test.c")
  DW_AT_stmt_list   (0x)
  DW_AT_comp_dir("/folk/kkumar/tcgcc/build")

0x001e:   DW_TAG_variable

  DW_AT_name  ("newname")
  DW_AT_type  (0x0029 "int")
  DW_AT_external  (true)
  DW_AT_decl_file ("test.c")
  DW_AT_decl_line (7)

0x0029:   DW_TAG_base_type

  DW_AT_name  ("int")
  DW_AT_encoding  (DW_ATE_signed)
  DW_AT_byte_size (0x04)

0x0030:   DW_TAG_variable

  DW_AT_name  ("oldname")
  DW_AT_type  (0x0029 "int")
  DW_AT_external  (true)
  DW_AT_decl_file ("test.c")
  DW_AT_decl_line (2)
  DW_AT_location  (DW_OP_addr 0x0)

0x0045:   NULL

so debug info looks same to me in gcc and clang .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[PATCH] D103131: support debug info for alias variable

2021-06-09 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D103131#2791881 , @dblaikie wrote:

> In D103131#2789493 , @probinson 
> wrote:
>
>>> Mixed feelings - somewhat in favor of "do the thing that's probably already 
>>> fairly tested/known to work" (GCC's thing). But open to the idea that that 
>>> approach has problems, for sure.
>>
>> "Known to work" for whom?  gdb, sure, because gcc/gdb cooperate on many 
>> things.
>
> Yep. Given the diversity of ways of expressing things in DWARF, no consumer 
> will handle everything that could be produced in the way a producer might 
> intend - so we do sort of have a defacto standard of "what would GCC do/what 
> does GDB understand".
>
> But also GCC/GDB has had more implementation experience with DWARF in 
> general, and with any feature we haven't implemented yet in particular - that 
> I wouldn't throw out their representational choice too quickly - there may be 
> important tradeoffs that were considered, implemented, and discarded due to 
> limitations.
>
>> I'll have to check with my debugger guys whether this would work for us; and 
>> I'll just reiterate that it's certainly not what the DWARF spec suggests 
>> should be done.
>
> I don't agree that it's "certainly not what the DWARF spec suggests should be 
> done" - the spec's pretty generous and exactly how a C or ELF level alias 
> should be rendered in DWARF seems pretty unclear to me. For instance an alias 
> is a symbol in the ELF file, arguably different from a source level alias 
> like a typedef or using declaration that DW_TAG_imported_declaration seems to 
> be promoted for.
>
> I doubt gdb would have trouble with DW_TAG_imported_declaration
>
> In D103131#2791373 , @probinson 
> wrote:
>
>> In D103131#2789493 , @probinson 
>> wrote:
>>
 Mixed feelings - somewhat in favor of "do the thing that's probably 
 already fairly tested/known to work" (GCC's thing). But open to the idea 
 that that approach has problems, for sure.
>>>
>>> "Known to work" for whom?  gdb, sure, because gcc/gdb cooperate on many 
>>> things.  I'll have to check with my debugger guys whether this would work 
>>> for us; and I'll just reiterate that it's certainly not what the DWARF spec 
>>> suggests should be done.
>>
>> The Sony debugger will not be able to figure out the address of "newname" 
>> given the DWARF as emitted by gcc (because it looks like an external 
>> declaration with no address).  We'd much rather have the 
>> DW_TAG_imported_declaration that the original patch had.
>
> Good to know - any interest in the debugger supporting declarations without 
> addresses? I guess there's no need for GCC compatibility? Clang might emit 
> them under some circumstances... let's see... Hmm, can't find a case now. But 
> there are cases where it would be desirable (such as when compiling some code 
> at -g0 and some with debug info - when you only have the declaration on the 
> debug info side, and no debug info on the definition side (eg: GCC produces a 
> declaration of 'i' in this code: `extern int i; int main() { return i; }`))
>
> @kamleshbhalui  - perhaps you could run the gdb and lldb test suites without 
> either change, then with both the variable declaration and imported 
> declaration versions to see how the results vary? (Well, I guess the lldb 
> test suite probably won't show any changes - but maybe worth running anyway) 
> - along with the manual test you've described in the patch description, to 
> demonstrate that both solutions address that?

@dblaikie I have ran gdb and lldb regression here is details.Please let me know 
if we should go to original fix(imported decl).

**case 1) Without any change in clang:**

 

| === gdb Summary === |
|



1. of expected passes75531
2. of unexpected failures695
3. of expected failures  125
4. of known failures 74
5. of unresolved testcases   7
6. of untested testcases 98
7. of unsupported tests  326
8. of duplicate test names   202

| ===lldb summary=== |
|

Failed Tests (3):

  lldb-shell :: Breakpoint/jit-loader_jitlink_elf.test
  lldb-shell :: Breakpoint/jit-loader_rtdyld_elf.test
  lldb-shell :: Reproducer/TestDiscard.test

Testing Time: 60.57s

  Unsupported: 1095
  Passed : 1202
  Failed :3

|
|

**case 2) with imported decl change in clang**

| === gdb Summary === |
|



1. of expected passes75531
2. of unexpected failures695
3. of expected failures  125
4. of known failures 74
5. of unresolved testcases   7
6. of untested testcases 98
7. of unsupported tests  326
8. of duplicate test names   202

| ===lldb summary=== |
|

Failed Tests (3):

  lldb-shell :: Breakpoint/jit-loader_jitlink_elf.test
  lldb-shell :: Breakpoint/jit-loader_rtdyld_elf.test
  lldb-shell 

[PATCH] D103131: support debug info for alias variable

2021-06-10 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D103131#2811220 , @dblaikie wrote:

> Any idea if the GDB test suite covers this functionality? I'd hope so, but 
> maybe it doesn't.
>
> But yeah, at the moment I don't have any great reason to avoid the imported 
> declaration form - so happy to go with that.

Hi David,

with imported declaration patch and with current patch(in review or say gcc 
way) this case works ok(we can print type and value of newname)
$cat test.c
int oldname = 1;
extern int newname attribute((alias("oldname")));

but when we make newname static it works with current patch(in review or say 
gcc way) but it does not work with imported decl 
patch(https://reviews.llvm.org/D103131?id=347883).

Should we go with gcc way or am I missing something?
note: used gdb debugger.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[PATCH] D103131: support debug info for alias variable

2021-06-11 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D103131#2814015 , @dblaikie wrote:

> In D103131#2811969 , @kamleshbhalui 
> wrote:
>
>> In D103131#2811220 , @dblaikie 
>> wrote:
>>
>>> Any idea if the GDB test suite covers this functionality? I'd hope so, but 
>>> maybe it doesn't.
>>>
>>> But yeah, at the moment I don't have any great reason to avoid the imported 
>>> declaration form - so happy to go with that.
>>
>> Hi David,
>>
>> with imported declaration patch and with current patch(in review or say gcc 
>> way) this case works ok(we can print type and value of newname)
>> $cat test.c
>> int oldname = 1;
>> extern int newname attribute((alias("oldname")));
>>
>> but when we make newname static it works with current patch(in review or say 
>> gcc way) but it does not work with imported decl 
>> patch(https://reviews.llvm.org/D103131?id=347883).
>>
>> Should we go with gcc way or am I missing something?
>> note: used gdb debugger.
>
> An ideas what's happening when `newname` is static? Is the DWARF any 
> different/interesting there? (since the DWARF for imported decl seems like it 
> would have nothing to do with the linkange of the alias - since it doesn't 
> refer to the actual alias in the object file, etc)

There not much different apart from extern has external attribute.
**case 1) when `newname` is static**

.debug_info contents:
0x: Compile Unit: length = 0x0072, format = DWARF32, version = 
0x0004, abbr_offset = 0x, addr_size = 0x08 (next unit at 0x0076)

0x000b: DW_TAG_compile_unit

  DW_AT_producer("clang version 13.0.0 
(g...@github.com:llvm/llvm-project.git 
4cd7169f5517167ef456e82c6dcae669bde6c725)")
  DW_AT_language(DW_LANG_C99)
  DW_AT_name("test.c")
  DW_AT_stmt_list   (0x)
  DW_AT_comp_dir("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin")
  DW_AT_low_pc  (0x)
  DW_AT_high_pc (0x0008)

0x002a:   DW_TAG_variable

  DW_AT_name  ("oldname")
  DW_AT_type  (0x003f "int")
  DW_AT_external  (true)
  DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
  DW_AT_decl_line (1)
  DW_AT_location  (DW_OP_addr 0x0)

0x003f:   DW_TAG_base_type

  DW_AT_name  ("int")
  DW_AT_encoding  (DW_ATE_signed)
  DW_AT_byte_size (0x04)

0x0046:   DW_TAG_variable

  DW_AT_name  ("newname")
  DW_AT_type  (0x003f "int")
  DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
  DW_AT_decl_line (2)
  DW_AT_declaration   (true)

0x0051:   DW_TAG_imported_declaration

  DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
  DW_AT_decl_line (2)
  DW_AT_import(0x0046)
  DW_AT_name  ("newname")

0x005c:   DW_TAG_subprogram

  DW_AT_low_pc(0x)
  DW_AT_high_pc   (0x0008)
  DW_AT_frame_base(DW_OP_reg6 RBP)
  DW_AT_name  ("main")
  DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
  DW_AT_decl_line (3)
  DW_AT_type  (0x003f "int")
  DW_AT_external  (true)

0x0075:   NULL

**case 2) when `newname` is extern**

.debug_info contents:
0x: Compile Unit: length = 0x0072, format = DWARF32, version = 
0x0004, abbr_offset = 0x, addr_size = 0x08 (next unit at 0x0076)

0x000b: DW_TAG_compile_unit

  DW_AT_producer("clang version 13.0.0 
(g...@github.com:llvm/llvm-project.git 
4cd7169f5517167ef456e82c6dcae669bde6c725)")
  DW_AT_language(DW_LANG_C99)
  DW_AT_name("test.c")
  DW_AT_stmt_list   (0x)
  DW_AT_comp_dir("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin")
  DW_AT_low_pc  (0x)
  DW_AT_high_pc (0x0008)

0x002a:   DW_TAG_variable

  DW_AT_name  ("oldname")
  DW_AT_type  (0x003f "int")
  DW_AT_external  (true)
  DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
  DW_AT_decl_line (1)
  DW_AT_location  (DW_OP_addr 0x0)

0x003f:   DW_TAG_base_type

  DW_AT_name  ("int")
  DW_AT_encoding  (DW_ATE_signed)
  DW_AT_byte_size (0x04)

0x0046:   DW_TAG_variable

  DW_AT_name  ("newname")
  DW_AT_type  (0x003f "int")
  DW_AT_external  (true)
  DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
  DW_AT_decl_line (2)
  DW_AT_declaration   (true)

0x0051:   DW_TAG_imported_declaration

  DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
  DW_AT_decl_line (2)
  DW_AT_import(0x0046)
  DW_AT_name  ("newname")

0x005c:   DW_TAG_subprogram

  DW_AT_low_pc(0x)
  DW_AT_high_pc   (0x0008)
  DW_AT_frame_base(DW_OP_reg6 RBP)
  DW_AT_name  ("main")
  DW_AT_decl_file ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
  DW_AT_decl_line (3)
  DW_AT_type  (0x003f "int")
  DW_AT_external  (true)

0x0075:   NULL



[PATCH] D103131: support debug info for alias variable

2021-06-22 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D103131#2815386 , @probinson wrote:

>>>   0x002a:   DW_TAG_variable
>>>   DW_AT_name  ("oldname")
>>>   DW_AT_type  (0x003f "int")
>>>   DW_AT_external  (true)
>>>   DW_AT_decl_file 
>>> ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
>>>   DW_AT_decl_line (1)
>>>   DW_AT_location  (DW_OP_addr 0x0)
>>>   
>>>   0x003f:   DW_TAG_base_type
>>>   DW_AT_name  ("int")
>>>   DW_AT_encoding  (DW_ATE_signed)
>>>   DW_AT_byte_size (0x04)
>>>   
>>>   0x0046:   DW_TAG_variable
>>>   DW_AT_name  ("newname")
>>>   DW_AT_type  (0x003f "int")
>>>   DW_AT_decl_file 
>>> ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
>>>   DW_AT_decl_line (2)
>>>   DW_AT_declaration   (true)
>>>   
>>>   0x0051:   DW_TAG_imported_declaration
>>>   DW_AT_decl_file 
>>> ("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
>>>   DW_AT_decl_line (2)
>>>   DW_AT_import(0x0046)
>>>   DW_AT_name  ("newname")
>
> I agree with David, this sequence doesn't seem to do what's desired.
> There's nothing that ties "newname" to "oldname" here.  What you 
> want is something more like this:
>
>   0x002a: DW_TAG_variable
>  DW_AT_name ("oldname")
>  ...
>   0x003a: DW_TAG_imported_declaration
>  DW_AT_import (0x002a)
>  DW_AT_name ("newname")
>
> That is, there would not be a separate DW_TAG_variable for "newname";
> instead, the imported_declaration would import the DIE for "oldname"
> giving it the name "newname".
>
> --paulr

Even this does not work with gdb.
Here is what gdb says,

   (gdb) ptype newname
  type = 
   (gdb) p newname
  'newname' has unknown type; cast it to its declared type
   (gdb) p oldname
   $1 = 1
   (gdb) ptype oldname
   type = int
   (gdb)  
   --
   dumped debug info (using llvm-dwarfdump)
   test.o: file format elf64-x86-64
   
   .debug_info contents:
   0x: Compile Unit: length = 0x0067, format = DWARF32, version = 
0x0004, abbr_offset = 0x, addr_size = 0x08 (next unit at 0x006b)
   
   0x000b: DW_TAG_compile_unit
 DW_AT_producer("clang version 13.0.0 
(g...@github.com:llvm/llvm-project.git 
4cd7169f5517167ef456e82c6dcae669bde6c725)")
 DW_AT_language(DW_LANG_C99)
 DW_AT_name("test.c")
 DW_AT_stmt_list   (0x)
 DW_AT_comp_dir
("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin")
 DW_AT_low_pc  (0x)
 DW_AT_high_pc (0x0008)
   
   0x002a:   DW_TAG_variable
   DW_AT_name  ("oldname")
   DW_AT_type  (0x003f "int")
   DW_AT_external  (true)
   DW_AT_decl_file 
("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
   DW_AT_decl_line (1)
   DW_AT_location  (DW_OP_addr 0x0)
   
   0x003f:   DW_TAG_base_type
   DW_AT_name  ("int")
   DW_AT_encoding  (DW_ATE_signed)
   DW_AT_byte_size (0x04)
   
   0x0046:   DW_TAG_imported_declaration
   DW_AT_decl_file 
("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
   DW_AT_decl_line (2)
   DW_AT_import(0x002a)
   DW_AT_name  ("newname")
   
   0x0051:   DW_TAG_subprogram
   DW_AT_low_pc(0x)
   DW_AT_high_pc   (0x0008)
   DW_AT_frame_base(DW_OP_reg6 RBP)
   DW_AT_name  ("main")
   DW_AT_decl_file 
("/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/test.c")
   DW_AT_decl_line (3)
   DW_AT_type  (0x003f "int")
   DW_AT_external  (true)
   
   0x006a:   NULL
   
   




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[PATCH] D103131: support debug info for alias variable

2021-06-22 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D103131#2834744 , @dblaikie wrote:

> Huh, that surprises me - guess gdb favors checking the symbol first. I guess 
> maybe it is using something that determines that that symbol comes from the 
> file with debug info - because on a similar test case (one file without debug 
> info, defining some global variable `i`, another file with debug info with a 
> `using ns::i` in the global scope - printing `i` when stepping into the 
> second file correctly prints the `using` based alias value, but stepping into 
> the file without debug info and printing `i` complains about not knowing the 
> type of that `i`)
>
> How's lldb go?

lldb seems to be printing value , but I worry about type.

  * thread #1, name = 'a.out', stop reason = breakpoint 1.1
  frame #0: 0x00400484 a.out`main at test.c:3:12
 1int oldname = 1;
 2extern int newname __attribute__((alias("oldname")));
  -> 3int main(){}
  (lldb) p oldname
  (int) $0 = 1
  (lldb) p newname
  (void *) $1 = 0x0001


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[PATCH] D103131: support debug info for alias variable

2021-06-23 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

Here is what we get when we replace int with float.

  $lldb-11 ./a.out 
  (lldb) target create "./a.out"
  Current executable set to '/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/a.out' 
(x86_64).
  (lldb) b main
  Breakpoint 1: where = a.out`main + 4 at test.c:3:12, address = 
0x00400484
  (lldb) p oldname
  (float) $0 = 1
  (lldb) p newname
  (void *) $1 = 0x3f80


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[PATCH] D103131: support debug info for alias variable

2021-06-23 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D103131#2835909 , @dblaikie wrote:

> In D103131#2835702 , @kamleshbhalui 
> wrote:
>
>> Here is what we get when we replace int with float.
>>
>>   $lldb-11 ./a.out 
>>   (lldb) target create "./a.out"
>>   Current executable set to 
>> '/folk/kkumar/tcllvm/llvm-build-lldb-rel/bin/a.out' (x86_64).
>>   (lldb) b main
>>   Breakpoint 1: where = a.out`main + 4 at test.c:3:12, address = 
>> 0x00400484
>>   (lldb) p oldname
>>   (float) $0 = 1
>>   (lldb) p newname
>>   (void *) $1 = 0x3f80
>
> Yep, looks like it's ignoring the imported declaration in favor of the raw 
> symbol table entry.
>
> How's lldb handle GCC-style debug info (the variable declaration, without any 
> imported declaration) for the alias?

lldb's behavior is same even with GCC -style debug info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[PATCH] D108421: Mark openmp internal global dso_local

2021-08-19 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added reviewers: MaskRay, pengfei.
kamleshbhalui added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
kamleshbhalui requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Starting from clang-12 openmp started generating internal global variable with 
got relocation even when static relocation  enabled.
In clang-11 shouldAssumeDSOLocal was assuming it dso_local based on static 
relocation model.
Since shouldAssumeDSOLocal  is cleaned up now for respecting dso_local  
generated from frontend, marking openmp internal globals as dso_local.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108421

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2179,11 +2179,14 @@
 return &*Elem.second;
   }
 
-  return Elem.second = new llvm::GlobalVariable(
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
  CGM.getModule(), Ty, /*IsConstant*/ false,
  llvm::GlobalValue::CommonLinkage, 
llvm::Constant::getNullValue(Ty),
  Elem.first(), /*InsertBefore=*/nullptr,
  llvm::GlobalValue::NotThreadLocal, AddressSpace);
+  GV->setDSOLocal(true);
+  Elem.second = GV;
+  return Elem.second;
 }
 
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2179,11 +2179,14 @@
 return &*Elem.second;
   }
 
-  return Elem.second = new llvm::GlobalVariable(
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
  CGM.getModule(), Ty, /*IsConstant*/ false,
  llvm::GlobalValue::CommonLinkage, llvm::Constant::getNullValue(Ty),
  Elem.first(), /*InsertBefore=*/nullptr,
  llvm::GlobalValue::NotThreadLocal, AddressSpace);
+  GV->setDSOLocal(true);
+  Elem.second = GV;
+  return Elem.second;
 }
 
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69893: libunwind: Evaluating DWARF operation DW_OP_pick is broken

2019-11-06 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added a reviewer: phosek.
Herald added subscribers: libcxx-commits, ldionne, christof.
kamleshbhalui edited the summary of this revision.

reg is unsigned type and used here for getting array element from the end  by 
negating it.
negation of unsigned can result in large number and array access with that 
index will result in segmentation
 fault.
As a Fix we cast reg to int then negate it.
Fixes this. 
https://bugs.llvm.org/show_bug.cgi?id=43872


Repository:
  rUNW libunwind

https://reviews.llvm.org/D69893

Files:
  libunwind/src/DwarfInstructions.hpp


Index: libunwind/src/DwarfInstructions.hpp
===
--- libunwind/src/DwarfInstructions.hpp
+++ libunwind/src/DwarfInstructions.hpp
@@ -430,7 +430,7 @@
   // pick from
   reg = addressSpace.get8(p);
   p += 1;
-  value = sp[-reg];
+  value = sp[-(int)reg];
   *(++sp) = value;
   if (log)
 fprintf(stderr, "duplicate %d in stack\n", reg);


Index: libunwind/src/DwarfInstructions.hpp
===
--- libunwind/src/DwarfInstructions.hpp
+++ libunwind/src/DwarfInstructions.hpp
@@ -430,7 +430,7 @@
   // pick from
   reg = addressSpace.get8(p);
   p += 1;
-  value = sp[-reg];
+  value = sp[-(int)reg];
   *(++sp) = value;
   if (log)
 fprintf(stderr, "duplicate %d in stack\n", reg);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69893: libunwind: Evaluating DWARF operation DW_OP_pick is broken

2019-11-06 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

`I do not have a test related to libunwind ,but I do simulated this behavior in 
c and got segfault.
---

int main(){

int stack[10]={0};
int* sp=stack;
*(sp)=1;
*(++sp)=2;
*(++sp)=3;
unsigned int r=1;
int d=sp[-r];
return 0;
}
-`


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D69893



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


[PATCH] D69893: libunwind: Evaluating DWARF operation DW_OP_pick is broken

2019-11-06 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

Yes, Tested All tests passes.

Testing Time: 0.95s

  Expected Passes: 4


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D69893



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


[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-11-21 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added reviewers: rsmith, dblaikie, vsk.
kamleshbhalui added a project: debug-info.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes this assert failure. 
Which occured due to deduction of auto type of  templated variables (required 
by debuginfo) resulted into null.
https://bugs.llvm.org/show_bug.cgi?id=42710


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70537

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1434,6 +1434,8 @@
 if (isa(V))
   continue;
 
+if (isa(V))
+ continue;
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1434,6 +1434,8 @@
 if (isa(V))
   continue;
 
+if (isa(V))
+	  continue;
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-11-21 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 230444.
kamleshbhalui added a comment.

formatted the diff.


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

https://reviews.llvm.org/D70537

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1434,6 +1434,8 @@
 if (isa(V))
   continue;
 
+if (isa(V))
+  continue;
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1434,6 +1434,8 @@
 if (isa(V))
   continue;
 
+if (isa(V))
+  continue;
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69893: libunwind: Evaluating DWARF operation DW_OP_pick is broken

2019-11-21 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

@ldionne Can you please commit this for me.
I do not have commit access.


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D69893



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


[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-11-21 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 230569.
kamleshbhalui added a comment.

Added a test.


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

https://reviews.llvm.org/D70537

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/pr42710.cpp


Index: clang/test/CodeGenCXX/pr42710.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr42710.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang %s -S -emit-llvm -g -o - -std=c++17
+// expected-no-diagnostics
+
+struct TypeId
+{
+inline static int counter{};
+
+template
+inline static const auto identifier = counter++;
+
+template
+inline static const auto value = identifier;
+};
+
+int main()
+{
+return TypeId::value;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1433,6 +1433,9 @@
 if (isa(V))
   continue;
 
+if (isa(V))
+  continue;
+
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {


Index: clang/test/CodeGenCXX/pr42710.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr42710.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang %s -S -emit-llvm -g -o - -std=c++17
+// expected-no-diagnostics
+
+struct TypeId
+{
+inline static int counter{};
+
+template
+inline static const auto identifier = counter++;
+
+template
+inline static const auto value = identifier;
+};
+
+int main()
+{
+return TypeId::value;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1433,6 +1433,9 @@
 if (isa(V))
   continue;
 
+if (isa(V))
+  continue;
+
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-11-22 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 230747.
kamleshbhalui added a comment.

Thanks, @vsk for reviewing.
I have incorporated your suggestions.


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

https://reviews.llvm.org/D70537

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/pr42710.cpp


Index: clang/test/CodeGenCXX/pr42710.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr42710.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang %s -DTYPE=auto -emit-llvm -S -g -o - -std=c++17
+// expected-no-diagnostics
+// RUN: %clang %s -DTYPE=int -emit-llvm -S -g -o - -std=c++17
+// expected-no-diagnostics
+
+struct TypeId
+{
+inline static int counter{};
+
+template
+inline static const TYPE identifier = counter++;
+
+template
+inline static const TYPE value = identifier;
+};
+
+int main()
+{
+return TypeId::value;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1433,6 +1433,10 @@
 if (isa(V))
   continue;
 
+if (isa(V) &&
+V->getType()->isUndeducedType())
+  continue;
+
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {


Index: clang/test/CodeGenCXX/pr42710.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr42710.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang %s -DTYPE=auto -emit-llvm -S -g -o - -std=c++17
+// expected-no-diagnostics
+// RUN: %clang %s -DTYPE=int -emit-llvm -S -g -o - -std=c++17
+// expected-no-diagnostics
+
+struct TypeId
+{
+inline static int counter{};
+
+template
+inline static const TYPE identifier = counter++;
+
+template
+inline static const TYPE value = identifier;
+};
+
+int main()
+{
+return TypeId::value;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1433,6 +1433,10 @@
 if (isa(V))
   continue;
 
+if (isa(V) &&
+V->getType()->isUndeducedType())
+  continue;
+
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-12-12 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D70537#1765607 , @probinson wrote:

> I guess first I'm confused about why the type would be undeduced in the first 
> place, given that it is actually instantiated.
>  And if undeduced is correct, wouldn't we rather emit these with 
> DW_TAG_unspecified_type?


While emitting the debug info this is the AST (for given testcase), in which 
static variable `value` is not yet deduced.
and when it tries to unwrap the type it fails.

  |-CXXRecordDecl 0x30dc88  col:8 implicit struct TypeId
  |-VarDecl 0x30dd30  col:23 used counter 'int' static inline 
listinit
  | `-InitListExpr 0x30ddd8  'int'
  |-VarTemplateDecl 0x30df68  col:30 identifier
  | |-TemplateTypeParmDecl 0x30de18  col:25 typename depth 0 index 0 
...
  | |-VarDecl 0x30df00  col:30 identifier 'const int':'const 
int' static inline cinit
  | | `-UnaryOperator 0x30dfe0  'int' postfix '++'
  | |   `-DeclRefExpr 0x30dfc0  'int' lvalue Var 0x30dd30 'counter' 
'int'
  | `-VarTemplateSpecializationDecl 0x341f30  col:30 referenced 
identifier 'const int':'const int' static inline cinit
  |   |-TemplateArgument pack
  |   | `-TemplateArgument type 'int'
  |   `-UnaryOperator 0x30dfe0  'int' postfix '++'
  | `-DeclRefExpr 0x30dfc0  'int' lvalue Var 0x30dd30 'counter' 
'int'
  |-VarTemplateDecl 0x30e228  col:30 value
  | |-TemplateTypeParmDecl 0x30e128  col:26 referenced 
typename depth 0 index 0 ... Args
  | |-VarDecl 0x30e1c0  col:30 value 'const auto' static 
inline cinit
  | | `-UnresolvedLookupExpr 0x30e2f8  '' 
lvalue (no ADL) = 'identifier' 0x30df68
  | `-VarTemplateSpecializationDecl 0x30e698  col:30 value 
'const auto' static inline
  |   `-TemplateArgument pack
  | `-TemplateArgument type 'int'
  |-VarTemplateSpecializationDecl 0x30e698  col:30 value 'const 
auto' static inline
  | `-TemplateArgument pack
  |   `-TemplateArgument type 'int'
  `-VarTemplateSpecializationDecl 0x341f30  col:30 referenced 
identifier 'const int':'const int' static inline cinit
|-TemplateArgument pack
| `-TemplateArgument type 'int'
`-UnaryOperator 0x30dfe0  'int' postfix '++'
  `-DeclRefExpr 0x30dfc0  'int' lvalue Var 0x30dd30 'counter' 'int'
   


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

https://reviews.llvm.org/D70537



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


[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-12-13 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D70537#1769458 , @dblaikie wrote:

> I feel like there's something missing about this bug/issue - is there a good 
> explanation/understanding for why does the bug only occur with the two levels 
> of static member inline variable templates & not one? Perhaps there's some 
> existing code that works for simple cases but is insufficiently general and 
> should be modified to be so, rather than adding a new case?


Here is the situation which is occuring in the particuler case(referring added 
testcase pr42710.cpp),

while instantiating the template variable `value` it also needs the type to 
declare it 
(see at 
https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaTemplateInstantiateDecl.cpp#L4590)
 and it sees that it is undeduced type , so it starts instantiating the
initialization expression and  in order to doing so it comes to at this point
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDebugInfo.cpp#L1424
which iterates over all the  VarDecl in record and try to generate debug info.
again here template variable `value` comes , which was undeduced and fails to 
unwrap the type and finally assert fails.


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

https://reviews.llvm.org/D70537



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


[PATCH] D71508: [DebugInfo] Duplicate file names in debug info

2019-12-13 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added reviewers: probinson, dblaikie, vsk, labath.
kamleshbhalui added a project: debug-info.
Herald added subscribers: cfe-commits, aprantl.
Herald added a project: clang.

strip/remove the dot slash before creating files for debug info.
This fixes https://bugs.llvm.org/show_bug.cgi?id=44170

I am unable to add a test for this.
since it requires to pass command like this.
$clang ./t.c -g -emit-llvm -S


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71508

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -409,6 +409,10 @@
 // If the location is not valid then use main input file.
 return TheCU->getFile();
 
+  if (!llvm::sys::path::is_absolute(FileName)) {
+  FileName = llvm::sys::path::remove_leading_dotslash(FileName);
+}
+
   // Cache the results.
   auto It = DIFileCache.find(FileName.data());
   if (It != DIFileCache.end()) {


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -409,6 +409,10 @@
 // If the location is not valid then use main input file.
 return TheCU->getFile();
 
+  if (!llvm::sys::path::is_absolute(FileName)) {
+  FileName = llvm::sys::path::remove_leading_dotslash(FileName);
+}
+
   // Cache the results.
   auto It = DIFileCache.find(FileName.data());
   if (It != DIFileCache.end()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

2019-12-13 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 233919.
kamleshbhalui added a comment.

added validation check in testcase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70537

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/pr42710.cpp


Index: clang/test/CodeGenCXX/pr42710.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr42710.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++17 -emit-llvm -debug-info-kind=limited %s -o - | 
FileCheck %s --check-prefix=CHECK
+
+namespace INT {
+struct TypeId
+{
+   inline static int counter{};
+
+   template
+   inline static const int identifier = counter++;
+
+   template
+   inline static const int value = identifier;
+
+};
+
+int main()
+{
+return TypeId::value;
+}
+}
+
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "identifier", 
linkageName: "_ZN3INT6TypeId10identifierIJiEEE"
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "identifier", 
linkageName: "_ZN4AUTO6TypeId10identifierIJiEEE"
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "counter", 
linkageName: "_ZN3INT6TypeId7counterE"
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "value", 
linkageName: "_ZN3INT6TypeId5valueIJiEEE"
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "counter", 
linkageName: "_ZN4AUTO6TypeId7counterE"
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "value", 
linkageName: "_ZN4AUTO6TypeId5valueIJiEEE"
+
+namespace AUTO {
+struct TypeId
+{
+inline static int counter{};
+
+template
+inline static const auto identifier = counter++;
+
+template
+inline static const auto value = identifier;
+};
+
+int main()
+{
+return TypeId::value;
+}
+}
+
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1428,6 +1428,10 @@
 if (isa(V))
   continue;
 
+if (isa(V)
+&& V->getType()->isUndeducedType())
+  continue;
+
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {


Index: clang/test/CodeGenCXX/pr42710.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr42710.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++17 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s --check-prefix=CHECK
+
+namespace INT {
+struct TypeId
+{
+   inline static int counter{};
+
+   template
+   inline static const int identifier = counter++;
+
+   template
+   inline static const int value = identifier;
+
+};
+
+int main()
+{
+return TypeId::value;
+}
+}
+
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "identifier", linkageName: "_ZN3INT6TypeId10identifierIJiEEE"
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "identifier", linkageName: "_ZN4AUTO6TypeId10identifierIJiEEE"
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "counter", linkageName: "_ZN3INT6TypeId7counterE"
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "value", linkageName: "_ZN3INT6TypeId5valueIJiEEE"
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "counter", linkageName: "_ZN4AUTO6TypeId7counterE"
+// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "value", linkageName: "_ZN4AUTO6TypeId5valueIJiEEE"
+
+namespace AUTO {
+struct TypeId
+{
+inline static int counter{};
+
+template
+inline static const auto identifier = counter++;
+
+template
+inline static const auto value = identifier;
+};
+
+int main()
+{
+return TypeId::value;
+}
+}
+
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1428,6 +1428,10 @@
 if (isa(V))
   continue;
 
+if (isa(V)
+&& V->getType()->isUndeducedType())
+  continue;
+
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69893: libunwind: Evaluating DWARF operation DW_OP_pick is broken

2019-12-13 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

ping?
can someone commit this for me?


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D69893



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


[PATCH] D71508: [DebugInfo] Duplicate file names in debug info

2019-12-16 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D71508#1785767 , @probinson wrote:

> Do we have a similar problem if the filespec has an embedded ./ or ../ in it?


problems  occur only when filespec starts with ./ otherwise it's fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71508



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


[PATCH] D71508: [DebugInfo] Duplicate file names in debug info

2019-12-16 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D71508#1786148 , @probinson wrote:

> In D71508#1786122 , @kamleshbhalui 
> wrote:
>
> > In D71508#1785767 , @probinson 
> > wrote:
> >
> > > Do we have a similar problem if the filespec has an embedded ./ or ../ in 
> > > it?
> >
> >
> > problems  occur only when filespec starts with ./ otherwise it's fine.
>
>
> So do other kinds of paths get canonicalized elsewhere?  I'm thinking if 
> there's already a place that undoes embedded .. then it should handle leading 
> . as well.


other canonicalization happens here 
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDebugInfo.cpp#L541
and 
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDebugInfo.cpp#L441

but that does not undo any embedded . and .. anywhere,except leading ./

i.e. when we pass like
$clang .././p1.c -S -emit-llvm -g

IRGen gives single file entry like this
!1 = !DIFile(filename: ".././p1.c"

As you can see path is  not canonicalized but it atleast does not have 
duplicate file entry.

> Is a leading .. okay or a problem?

yes It's ok in the sense ,it does not create duplicate file entry in debug info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71508



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


[PATCH] D69893: libunwind: Evaluating DWARF operation DW_OP_pick is broken

2019-12-16 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D69893#1786202 , @steven_wu wrote:

> The fix LGTM. Do you have a reproducer that can be used as a test case? We 
> should really add more tests for libunwind.


I currently do not have a reproducer test case for this.


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D69893



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


[PATCH] D71508: [DebugInfo] Duplicate file names in debug info

2019-12-16 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D71508#1786804 , @dblaikie wrote:

> In D71508#1786212 , @kamleshbhalui 
> wrote:
>
> > In D71508#1786148 , @probinson 
> > wrote:
> >
> > > In D71508#1786122 , 
> > > @kamleshbhalui wrote:
> > >
> > > > In D71508#1785767 , @probinson 
> > > > wrote:
> > > >
> > > > > Do we have a similar problem if the filespec has an embedded ./ or 
> > > > > ../ in it?
> > > >
> > > >
> > > > problems  occur only when filespec starts with ./ otherwise it's fine.
> > >
> > >
> > > So do other kinds of paths get canonicalized elsewhere?  I'm thinking if 
> > > there's already a place that undoes embedded .. then it should handle 
> > > leading . as well.
> >
> >
> > other canonicalization happens here 
> >  
> > https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDebugInfo.cpp#L541
> >  and 
> >  
> > https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDebugInfo.cpp#L441
> >
> > but that does not undo any embedded . and .. anywhere,except leading ./
> >
> > i.e. when we pass like
> >  $clang .././p1.c -S -emit-llvm -g
> >
> > IRGen gives single file entry like this
> >  !1 = !DIFile(filename: ".././p1.c"
> >
> > As you can see path is  not canonicalized but it atleast does not have 
> > duplicate file entry.
>
>
> Even if that .c file is referred to by a different path - what about a 
> #include of that .c file (with some #ifdefs to avoid infinite include 
> recursion) by the absolute path, for instance? does that still not end up 
> with duplicate files with two different paths to the same file?


No, that does not happen. Because in that case we create file entry for first 
time with absolute path and later we always get the same file with 
getOrCreateFile.

The duplicate File entry only happens with the file passed by driver 
-main-file-name p1.cc which used  in creating compilation unit. 
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDebugInfo.cpp#L518

and while creating debuginfo for variable / function it refers to file by 
quering getOrCreateFile with relative path specified on commmand line and it 
sees that there is no such entry and ends up creating new file entry with this 
path hence duplication.
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDebugInfo.cpp#L406

> 
> 
>> 
>> 
>>> Is a leading .. okay or a problem?
>> 
>> yes It's ok in the sense ,it does not create duplicate file entry in debug 
>> info.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71508



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


[PATCH] D71508: [DebugInfo] Duplicate file names in debug info

2019-12-16 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D71508#1786799 , @aprantl wrote:

> Are we sure we want to canonicalize *before* applying -fdebug-prefix-map in 
> `remapDIPath()`? Honest question, the answer could be yes :-)


it canonicalizes before apply -fdebug-prefix-map in `remapDIPath()`  only when 
creating compilation unit with filename passed by driver  option -main-file-name
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDebugInfo.cpp#L615

Other than that it first apply -fdebug-prefix-map in `remapDIPath()` then try 
to canonicalize.
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDebugInfo.cpp#L441


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71508



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


[PATCH] D71619: [CLANG] Alignment specifier not applied to anonymous structure or union

2019-12-17 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added reviewers: rsmith, aaron.ballman, dblaikie.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Apply attributes on anonymous records.
This Fixes https://bugs.llvm.org/show_bug.cgi?id=43983.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71619

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/pr43983.cpp


Index: clang/test/AST/pr43983.cpp
===
--- /dev/null
+++ clang/test/AST/pr43983.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump | FileCheck %s
+
+struct B { _Alignas(64) struct { int b; };   };
+
+// CHECK: AlignedAttr {{.*}} _Alignas
+// CHECK: ConstantExpr {{.*}} 64
+// CHECK: IntegerLiteral {{.*}} 64
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5020,6 +5020,7 @@
 /*BitWidth=*/nullptr, /*Mutable=*/false,
 /*InitStyle=*/ICIS_NoInit);
 Anon->setAccess(AS);
+ProcessDeclAttributes(S,Anon,Dc);
 if (getLangOpts().CPlusPlus)
   FieldCollector->Add(cast(Anon));
   } else {


Index: clang/test/AST/pr43983.cpp
===
--- /dev/null
+++ clang/test/AST/pr43983.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump | FileCheck %s
+
+struct B { _Alignas(64) struct { int b; };   };
+
+// CHECK: AlignedAttr {{.*}} _Alignas
+// CHECK: ConstantExpr {{.*}} 64
+// CHECK: IntegerLiteral {{.*}} 64
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5020,6 +5020,7 @@
 /*BitWidth=*/nullptr, /*Mutable=*/false,
 /*InitStyle=*/ICIS_NoInit);
 Anon->setAccess(AS);
+ProcessDeclAttributes(S,Anon,Dc);
 if (getLangOpts().CPlusPlus)
   FieldCollector->Add(cast(Anon));
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71619: [CLANG] Alignment specifier not applied to anonymous structure or union

2019-12-18 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 234652.
kamleshbhalui added a comment.

added assert.


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

https://reviews.llvm.org/D71619

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/pr43983.cpp


Index: clang/test/AST/pr43983.cpp
===
--- /dev/null
+++ clang/test/AST/pr43983.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump | FileCheck %s
+
+struct B { _Alignas(64) struct { int b; };   };
+
+// CHECK: AlignedAttr {{.*}} _Alignas
+// CHECK: ConstantExpr {{.*}} 64
+// CHECK: IntegerLiteral {{.*}} 64
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5020,6 +5020,8 @@
 /*BitWidth=*/nullptr, /*Mutable=*/false,
 /*InitStyle=*/ICIS_NoInit);
 Anon->setAccess(AS);
+ProcessDeclAttributes(S, Anon, Dc);
+
 if (getLangOpts().CPlusPlus)
   FieldCollector->Add(cast(Anon));
   } else {
@@ -5033,6 +5035,7 @@
   SC = SC_None;
 }
 
+assert(DS.getAttributes().empty() && "No attribute expected");
 Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
Record->getLocation(), /*IdentifierInfo=*/nullptr,
Context.getTypeDeclType(Record), TInfo, SC);


Index: clang/test/AST/pr43983.cpp
===
--- /dev/null
+++ clang/test/AST/pr43983.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump | FileCheck %s
+
+struct B { _Alignas(64) struct { int b; };   };
+
+// CHECK: AlignedAttr {{.*}} _Alignas
+// CHECK: ConstantExpr {{.*}} 64
+// CHECK: IntegerLiteral {{.*}} 64
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5020,6 +5020,8 @@
 /*BitWidth=*/nullptr, /*Mutable=*/false,
 /*InitStyle=*/ICIS_NoInit);
 Anon->setAccess(AS);
+ProcessDeclAttributes(S, Anon, Dc);
+
 if (getLangOpts().CPlusPlus)
   FieldCollector->Add(cast(Anon));
   } else {
@@ -5033,6 +5035,7 @@
   SC = SC_None;
 }
 
+assert(DS.getAttributes().empty() && "No attribute expected");
 Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
Record->getLocation(), /*IdentifierInfo=*/nullptr,
Context.getTypeDeclType(Record), TInfo, SC);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71619: [CLANG] Alignment specifier not applied to anonymous structure or union

2019-12-19 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 234796.
kamleshbhalui added a comment.

removed c++11 from the test.
I do not have commit access, Can someone commit this for me?


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

https://reviews.llvm.org/D71619

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/pr43983.cpp


Index: clang/test/AST/pr43983.cpp
===
--- /dev/null
+++ clang/test/AST/pr43983.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -ast-dump | FileCheck %s
+
+struct B { _Alignas(64) struct { int b; };   };
+
+// CHECK: AlignedAttr {{.*}} _Alignas
+// CHECK: ConstantExpr {{.*}} 64
+// CHECK: IntegerLiteral {{.*}} 64
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5020,6 +5020,8 @@
 /*BitWidth=*/nullptr, /*Mutable=*/false,
 /*InitStyle=*/ICIS_NoInit);
 Anon->setAccess(AS);
+ProcessDeclAttributes(S, Anon, Dc);
+
 if (getLangOpts().CPlusPlus)
   FieldCollector->Add(cast(Anon));
   } else {
@@ -5033,6 +5035,7 @@
   SC = SC_None;
 }
 
+assert(DS.getAttributes().empty() && "No attribute expected");
 Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
Record->getLocation(), /*IdentifierInfo=*/nullptr,
Context.getTypeDeclType(Record), TInfo, SC);


Index: clang/test/AST/pr43983.cpp
===
--- /dev/null
+++ clang/test/AST/pr43983.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -ast-dump | FileCheck %s
+
+struct B { _Alignas(64) struct { int b; };   };
+
+// CHECK: AlignedAttr {{.*}} _Alignas
+// CHECK: ConstantExpr {{.*}} 64
+// CHECK: IntegerLiteral {{.*}} 64
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5020,6 +5020,8 @@
 /*BitWidth=*/nullptr, /*Mutable=*/false,
 /*InitStyle=*/ICIS_NoInit);
 Anon->setAccess(AS);
+ProcessDeclAttributes(S, Anon, Dc);
+
 if (getLangOpts().CPlusPlus)
   FieldCollector->Add(cast(Anon));
   } else {
@@ -5033,6 +5035,7 @@
   SC = SC_None;
 }
 
+assert(DS.getAttributes().empty() && "No attribute expected");
 Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
Record->getLocation(), /*IdentifierInfo=*/nullptr,
Context.getTypeDeclType(Record), TInfo, SC);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75805: Make malign-double effective only for x86

2020-03-07 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added a reviewer: rnk.
kamleshbhalui added a project: clang.
Herald added a subscriber: cfe-commits.

Making -malign-double effective only for x86.

Fixes.
https://bugs.llvm.org/show_bug.cgi?id=45136


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75805

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2916,7 +2916,7 @@
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, 
Diags);
-  Opts.AlignDouble = Args.hasArg(OPT_malign_double);
+  Opts.AlignDouble = T.getArch() == llvm::Triple::x86 && 
Args.hasArg(OPT_malign_double);
   Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
 ? 128
 : Args.hasArg(OPT_mlong_double_64) ? 64 : 0;


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2916,7 +2916,7 @@
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
-  Opts.AlignDouble = Args.hasArg(OPT_malign_double);
+  Opts.AlignDouble = T.getArch() == llvm::Triple::x86 && Args.hasArg(OPT_malign_double);
   Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
 ? 128
 : Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75805: Make malign-double effective only for x86

2020-03-09 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 249054.
kamleshbhalui added a reviewer: MaskRay.

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

https://reviews.llvm.org/D75805

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2916,7 +2916,8 @@
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, 
Diags);
-  Opts.AlignDouble = Args.hasArg(OPT_malign_double);
+  Opts.AlignDouble =
+  T.getArch() == llvm::Triple::x86 && Args.hasArg(OPT_malign_double);
   Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
 ? 128
 : Args.hasArg(OPT_mlong_double_64) ? 64 : 0;


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2916,7 +2916,8 @@
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
-  Opts.AlignDouble = Args.hasArg(OPT_malign_double);
+  Opts.AlignDouble =
+  T.getArch() == llvm::Triple::x86 && Args.hasArg(OPT_malign_double);
   Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
 ? 128
 : Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-03-30 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added reviewers: dblaikie, aprantl.
kamleshbhalui added a project: LLVM.
Herald added a subscriber: mstorsjo.
kamleshbhalui requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang emits duplicate file entry in object file on windows platform(when 
windows style path appended with posix style path or vice versa).
which becomes problem for some debugger(not able to put break point on the file 
which has duplicate entry).

By making sure it's native path before creating DIFile above problem goes away.

Testcase Demonstration of problem on llvm-dev:
https://lists.llvm.org/pipermail/llvm-dev/2021-March/149501.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99580

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


Index: clang/test/CodeGen/debug-info-mingw.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-mingw.c
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t/UNIQUE_DIR && mkdir -p %t/UNIQUE_DIR
+// RUN: cp %s %t/UNIQUE_DIR/debug-info-mingw.c
+// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -debug-info-kind=limited 
-main-file-name debug-info-mingw.c %t/UNIQUE_DIR/debug-info-mingw.c -emit-llvm 
-o - | FileCheck %s
+int main() {
+}
+// CHECK: !DIFile(filename: "{{.+}}\\UNIQUE_DIR\\debug-info-mingw.c",
+// UNSUPPORTED: !system-windows
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -443,6 +443,10 @@
 Optional Source) {
   StringRef Dir;
   StringRef File;
+  // Convert FileName to native path
+  SmallString<128> NativePath = FileName;
+  llvm::sys::path::native(NativePath);
+  FileName = NativePath.str();
   std::string RemappedFile = remapDIPath(FileName);
   std::string CurDir = remapDIPath(getCurrentDirname());
   SmallString<128> DirBuf;
@@ -558,7 +562,10 @@
 MainFile->getName().rsplit('.').second)
 .isPreprocessed())
   MainFileName = CGM.getModule().getName().str();
-
+// Convert MainFileName to native path
+SmallString<128> NativePath = (StringRef)MainFileName;
+llvm::sys::path::native(NativePath);
+MainFileName = (std::string)NativePath.str();
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
   }
 


Index: clang/test/CodeGen/debug-info-mingw.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-mingw.c
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t/UNIQUE_DIR && mkdir -p %t/UNIQUE_DIR
+// RUN: cp %s %t/UNIQUE_DIR/debug-info-mingw.c
+// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -debug-info-kind=limited -main-file-name debug-info-mingw.c %t/UNIQUE_DIR/debug-info-mingw.c -emit-llvm -o - | FileCheck %s
+int main() {
+}
+// CHECK: !DIFile(filename: "{{.+}}\\UNIQUE_DIR\\debug-info-mingw.c",
+// UNSUPPORTED: !system-windows
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -443,6 +443,10 @@
 Optional Source) {
   StringRef Dir;
   StringRef File;
+  // Convert FileName to native path
+  SmallString<128> NativePath = FileName;
+  llvm::sys::path::native(NativePath);
+  FileName = NativePath.str();
   std::string RemappedFile = remapDIPath(FileName);
   std::string CurDir = remapDIPath(getCurrentDirname());
   SmallString<128> DirBuf;
@@ -558,7 +562,10 @@
 MainFile->getName().rsplit('.').second)
 .isPreprocessed())
   MainFileName = CGM.getModule().getName().str();
-
+// Convert MainFileName to native path
+SmallString<128> NativePath = (StringRef)MainFileName;
+llvm::sys::path::native(NativePath);
+MainFileName = (std::string)NativePath.str();
 CSKind = computeChecksum(SM.getMainFileID(), Checksum);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-03-30 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D99580#2659858 , @amccarth wrote:

> Another possible issue is that llvm::sys::path and other functions try to map 
> Windows filesystem concepts to Posix ones. There are many cases where there 
> isn't a perfect mapping. For example: Windows has a current working directory 
> _per drive_, and so it can be hard to resolve paths like D:foo.ext, which are 
> relative to something other than the "current working directory." Details 
> like this can come into play in the immediate vicinity of the code change, so 
> I have some trepidation.

Agree with you but this problem exist with and without this patch.

> It looks like the code change is for everyone, but the new test is specific 
> to mingw.

For Linux like platform it does not create problem because input file  path is 
already in POSIX style, so having a test case will not test the change because 
even without the change it will pass.
Even on windows problem occur only when input file path specified in POSIX 
style(i.e. C:/foo/bar/test.c), if specify the path windows style(i.e. 
C:\foo\bar\test.c) then the fix not required.

>   Is that the right place for the new test?

In same directory their are many mingw related test, so added this test their, 
still if everyone strongly feels it should be in separate directory I will do 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

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


[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-03-30 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D99580#2659352 , @dblaikie wrote:

> @rnk @akhuang - I think we touched on this before maybe in some other 
> thread/patch/discussion?
>
> Ah, @probinson mentioned in the linked thread:
>
>> Is this https://bugs.llvm.org/show_bug.cgi?id=44170 which had a tentative 
>> patch at https://reviews.llvm.org/D71508 ?
>> The original complaint wasn't for Windows, but the lack of filepath 
>> canonicalization seems like a common symptom.
>
> Might be best, @kamleshbhalui, if you could check if the other (D71508 
> ) patch relates to the same issue & if so, 
> continue the discussion over there instead of forking it here.

@dblaikie It's not exactly same problem because PR44170  pops up only when 
compiling with -gdwarf-5 (on both linux and windows) although IR looks similar 
as when compiled with -gdwarf-4.
But this bug(for which current patch D99580  
created) only can be reproduced on windows and with all dwarf version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

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


[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-03-30 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 334338.
kamleshbhalui added a comment.

Marked failed tests as unsupported on windows system
Because now clang emits native path for DIFile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-preprocessed-file.i
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/CodeGenCXX/debug-info-mingw.cpp
  clang/test/CodeGenCXX/linetable-fnbegin.cpp
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/stdin-input.c
  clang/test/Modules/module-debuginfo-prefix.m
  clang/test/PCH/debug-info-pch-container-path.c

Index: clang/test/PCH/debug-info-pch-container-path.c
===
--- clang/test/PCH/debug-info-pch-container-path.c
+++ clang/test/PCH/debug-info-pch-container-path.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Frontend/stdin-input.c
===
--- clang/test/Frontend/stdin-input.c
+++ clang/test/Frontend/stdin-input.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: cat %s | %clang -emit-llvm -g -S \
 // RUN: -Xclang -main-file-name -Xclang test/foo.c -x c - -o - | FileCheck %s
 // CHECK: ; ModuleID = 'test/foo.c'
Index: clang/test/Frontend/optimization-remark-line-directive.c
===
--- clang/test/Frontend/optimization-remark-line-directive.c
+++ clang/test/Frontend/optimization-remark-line-directive.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // This file tests -Rpass diagnostics together with #line
 // directives. We cannot map #line directives back to
 // a SourceLocation.
Index: clang/test/CodeGenCXX/linetable-fnbegin.cpp
===
--- clang/test/CodeGenCXX/linetable-fnbegin.cpp
+++ clang/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
 // Test that the line table info for Foo::bar() is pointing to the
 // right header file.
Index: clang/test/CodeGenCXX/debug-info-mingw.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-mingw.cpp
@@ -0,0 +1,9 @@
+// UNSUPPORTED: !system-windows
+// RUN: rm -rf %t/UNIQUE_DIR && mkdir -p %t/UNIQUE_DIR
+// RUN: cp %s %t/UNIQUE_DIR/debug-info-mingw.cpp
+// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -debug-info-kind=limited \
+// RUN: -main-file-name debug-info-mingw.cpp %t/UNIQUE_DIR/debug-info-mingw.cpp \
+// RUN: -emit-llvm -o - | FileCheck %s
+int main() {
+}
+// CHECK: !DIFile(filename: "{{.+}}\\UNIQUE_DIR\\debug-info-mingw.cpp",
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-EVIL
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name debug-prefix-map.c | FileCheck %s
Index: clang/test/CodeGen/debug-info-preprocessed-file.i
===
--- clang/test/CodeGen/debug-info-preprocessed-file.i
+++ clang/test/CodeGen/debug-info-preprocessed-file.i
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 # 1 "/foo/bar/preprocessed-input.c"
 # 1 "" 1
 # 1 "" 3
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,6 +444,10 @@
   StringRef Dir;
   StringRef File;
   std::string RemappedFile = remapDIPath(FileName);
+  // Convert RemappedFile to native style
+  SmallString<128> NativeFileName = StringRef(RemappedFile);
+  llvm::sys::path::native(NativeFileName);
+  RemappedFile = (std::string)NativeFileName.str();
   std::string CurDir = remapDIPath(getCurrentDirname());
   SmallString<128> DirBuf;
   SmallString<128> FileBuf;
@@ -618,8 +622,13 @@
   // file was specified with an absolute path.
   if (CSKind)
  

[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-03-30 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 334356.
kamleshbhalui added a comment.

clang formatting the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/linetable-fnbegin.cpp


Index: clang/test/CodeGenCXX/linetable-fnbegin.cpp
===
--- clang/test/CodeGenCXX/linetable-fnbegin.cpp
+++ clang/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -12,7 +12,6 @@
 // We shouldn't need a lexical block for this function.
 // CHECK: [[DBG]] = !DILocation(line: 23, column: 3, scope: [[SP]])
 
-
 # 1 "./template.h" 1
 template 
 class Foo {
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -627,9 +627,9 @@
   llvm::sys::path::native(NativeMainFileName);
   MainFileName = (std::string)NativeMainFileName.str();
 
-  llvm::DIFile *CUFile = DBuilder.createFile(
-  MainFileName, remapDIPath(getCurrentDirname()), CSInfo,
-  getSource(SM, SM.getMainFileID()));
+  llvm::DIFile *CUFile =
+  DBuilder.createFile(MainFileName, remapDIPath(getCurrentDirname()),
+  CSInfo, getSource(SM, SM.getMainFileID()));
 
   StringRef Sysroot, SDK;
   if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB) {


Index: clang/test/CodeGenCXX/linetable-fnbegin.cpp
===
--- clang/test/CodeGenCXX/linetable-fnbegin.cpp
+++ clang/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -12,7 +12,6 @@
 // We shouldn't need a lexical block for this function.
 // CHECK: [[DBG]] = !DILocation(line: 23, column: 3, scope: [[SP]])
 
-
 # 1 "./template.h" 1
 template 
 class Foo {
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -627,9 +627,9 @@
   llvm::sys::path::native(NativeMainFileName);
   MainFileName = (std::string)NativeMainFileName.str();
 
-  llvm::DIFile *CUFile = DBuilder.createFile(
-  MainFileName, remapDIPath(getCurrentDirname()), CSInfo,
-  getSource(SM, SM.getMainFileID()));
+  llvm::DIFile *CUFile =
+  DBuilder.createFile(MainFileName, remapDIPath(getCurrentDirname()),
+  CSInfo, getSource(SM, SM.getMainFileID()));
 
   StringRef Sysroot, SDK;
   if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-03-30 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 334359.
kamleshbhalui added a comment.

updated patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-preprocessed-file.i
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/CodeGenCXX/debug-info-mingw.cpp
  clang/test/CodeGenCXX/linetable-fnbegin.cpp
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/stdin-input.c
  clang/test/Modules/module-debuginfo-prefix.m
  clang/test/PCH/debug-info-pch-container-path.c

Index: clang/test/PCH/debug-info-pch-container-path.c
===
--- clang/test/PCH/debug-info-pch-container-path.c
+++ clang/test/PCH/debug-info-pch-container-path.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Frontend/stdin-input.c
===
--- clang/test/Frontend/stdin-input.c
+++ clang/test/Frontend/stdin-input.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: cat %s | %clang -emit-llvm -g -S \
 // RUN: -Xclang -main-file-name -Xclang test/foo.c -x c - -o - | FileCheck %s
 // CHECK: ; ModuleID = 'test/foo.c'
Index: clang/test/Frontend/optimization-remark-line-directive.c
===
--- clang/test/Frontend/optimization-remark-line-directive.c
+++ clang/test/Frontend/optimization-remark-line-directive.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // This file tests -Rpass diagnostics together with #line
 // directives. We cannot map #line directives back to
 // a SourceLocation.
Index: clang/test/CodeGenCXX/linetable-fnbegin.cpp
===
--- clang/test/CodeGenCXX/linetable-fnbegin.cpp
+++ clang/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
 // Test that the line table info for Foo::bar() is pointing to the
 // right header file.
@@ -11,7 +12,6 @@
 // We shouldn't need a lexical block for this function.
 // CHECK: [[DBG]] = !DILocation(line: 23, column: 3, scope: [[SP]])
 
-
 # 1 "./template.h" 1
 template 
 class Foo {
Index: clang/test/CodeGenCXX/debug-info-mingw.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-mingw.cpp
@@ -0,0 +1,9 @@
+// UNSUPPORTED: !system-windows
+// RUN: rm -rf %t/UNIQUE_DIR && mkdir -p %t/UNIQUE_DIR
+// RUN: cp %s %t/UNIQUE_DIR/debug-info-mingw.cpp
+// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -debug-info-kind=limited \
+// RUN: -main-file-name debug-info-mingw.cpp %t/UNIQUE_DIR/debug-info-mingw.cpp \
+// RUN: -emit-llvm -o - | FileCheck %s
+int main() {
+}
+// CHECK: !DIFile(filename: "{{.+}}\\UNIQUE_DIR\\debug-info-mingw.cpp",
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-EVIL
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name debug-prefix-map.c | FileCheck %s
Index: clang/test/CodeGen/debug-info-preprocessed-file.i
===
--- clang/test/CodeGen/debug-info-preprocessed-file.i
+++ clang/test/CodeGen/debug-info-preprocessed-file.i
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 # 1 "/foo/bar/preprocessed-input.c"
 # 1 "" 1
 # 1 "" 3
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,6 +444,10 @@
   StringRef Dir;
   StringRef File;
   std::string RemappedFile = remapDIPath(FileName);
+  // Convert RemappedFile to native style
+  SmallString<128> NativeFileName = StringRef(RemappedFile);
+  llvm::sys::path::native(NativeFileName);
+  RemappedFile = (std::string)NativeFileName.str();
   std::string CurDir = remapDIPath(getCurrentDirname());
   SmallString<128> DirBuf;
   Small

[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-04-02 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 334952.
kamleshbhalui added a comment.

Making changes effective only for windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-preprocessed-file.i
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/CodeGenCXX/debug-info-mingw.cpp
  clang/test/CodeGenCXX/linetable-fnbegin.cpp
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/stdin-input.c
  clang/test/Modules/module-debuginfo-prefix.m
  clang/test/PCH/debug-info-pch-container-path.c

Index: clang/test/PCH/debug-info-pch-container-path.c
===
--- clang/test/PCH/debug-info-pch-container-path.c
+++ clang/test/PCH/debug-info-pch-container-path.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Frontend/stdin-input.c
===
--- clang/test/Frontend/stdin-input.c
+++ clang/test/Frontend/stdin-input.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: cat %s | %clang -emit-llvm -g -S \
 // RUN: -Xclang -main-file-name -Xclang test/foo.c -x c - -o - | FileCheck %s
 // CHECK: ; ModuleID = 'test/foo.c'
Index: clang/test/Frontend/optimization-remark-line-directive.c
===
--- clang/test/Frontend/optimization-remark-line-directive.c
+++ clang/test/Frontend/optimization-remark-line-directive.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // This file tests -Rpass diagnostics together with #line
 // directives. We cannot map #line directives back to
 // a SourceLocation.
Index: clang/test/CodeGenCXX/linetable-fnbegin.cpp
===
--- clang/test/CodeGenCXX/linetable-fnbegin.cpp
+++ clang/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
 // Test that the line table info for Foo::bar() is pointing to the
 // right header file.
@@ -11,7 +12,6 @@
 // We shouldn't need a lexical block for this function.
 // CHECK: [[DBG]] = !DILocation(line: 23, column: 3, scope: [[SP]])
 
-
 # 1 "./template.h" 1
 template 
 class Foo {
Index: clang/test/CodeGenCXX/debug-info-mingw.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-mingw.cpp
@@ -0,0 +1,9 @@
+// UNSUPPORTED: !system-windows
+// RUN: rm -rf %t/UNIQUE_DIR && mkdir -p %t/UNIQUE_DIR
+// RUN: cp %s %t/UNIQUE_DIR/debug-info-mingw.cpp
+// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -debug-info-kind=limited \
+// RUN: -main-file-name debug-info-mingw.cpp %t/UNIQUE_DIR/debug-info-mingw.cpp \
+// RUN: -emit-llvm -o - | FileCheck %s
+int main() {
+}
+// CHECK: !DIFile(filename: "{{.+}}\\UNIQUE_DIR\\debug-info-mingw.cpp",
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-EVIL
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name debug-prefix-map.c | FileCheck %s
Index: clang/test/CodeGen/debug-info-preprocessed-file.i
===
--- clang/test/CodeGen/debug-info-preprocessed-file.i
+++ clang/test/CodeGen/debug-info-preprocessed-file.i
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 # 1 "/foo/bar/preprocessed-input.c"
 # 1 "" 1
 # 1 "" 3
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,6 +444,12 @@
   StringRef Dir;
   StringRef File;
   std::string RemappedFile = remapDIPath(FileName);
+  // Convert RemappedFile to native style when Windows
+  if (CGM.getTarget().getTriple().isOSWindows()) {
+SmallString<128> NativeFileName = StringRef(RemappedFile);
+llvm::sys::path::native(NativeFileName);
+RemappedFile = (std::string)NativeFileName.st

[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-04-07 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a reviewer: rnk.
kamleshbhalui added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

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


[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-04-08 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 336057.
kamleshbhalui added a comment.

Making changes effective only for windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-preprocessed-file.i
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/CodeGenCXX/debug-info-mingw.cpp
  clang/test/CodeGenCXX/linetable-fnbegin.cpp
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/stdin-input.c
  clang/test/Modules/module-debuginfo-prefix.m
  clang/test/PCH/debug-info-pch-container-path.c

Index: clang/test/PCH/debug-info-pch-container-path.c
===
--- clang/test/PCH/debug-info-pch-container-path.c
+++ clang/test/PCH/debug-info-pch-container-path.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Frontend/stdin-input.c
===
--- clang/test/Frontend/stdin-input.c
+++ clang/test/Frontend/stdin-input.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: cat %s | %clang -emit-llvm -g -S \
 // RUN: -Xclang -main-file-name -Xclang test/foo.c -x c - -o - | FileCheck %s
 // CHECK: ; ModuleID = 'test/foo.c'
Index: clang/test/Frontend/optimization-remark-line-directive.c
===
--- clang/test/Frontend/optimization-remark-line-directive.c
+++ clang/test/Frontend/optimization-remark-line-directive.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // This file tests -Rpass diagnostics together with #line
 // directives. We cannot map #line directives back to
 // a SourceLocation.
Index: clang/test/CodeGenCXX/linetable-fnbegin.cpp
===
--- clang/test/CodeGenCXX/linetable-fnbegin.cpp
+++ clang/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
 // Test that the line table info for Foo::bar() is pointing to the
 // right header file.
@@ -11,7 +12,6 @@
 // We shouldn't need a lexical block for this function.
 // CHECK: [[DBG]] = !DILocation(line: 23, column: 3, scope: [[SP]])
 
-
 # 1 "./template.h" 1
 template 
 class Foo {
Index: clang/test/CodeGenCXX/debug-info-mingw.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-mingw.cpp
@@ -0,0 +1,9 @@
+// UNSUPPORTED: !system-windows
+// RUN: rm -rf %t/UNIQUE_DIR && mkdir -p %t/UNIQUE_DIR
+// RUN: cp %s %t/UNIQUE_DIR/debug-info-mingw.cpp
+// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -debug-info-kind=limited \
+// RUN: -main-file-name debug-info-mingw.cpp %t/UNIQUE_DIR/debug-info-mingw.cpp \
+// RUN: -emit-llvm -o - | FileCheck %s
+int main() {
+}
+// CHECK: !DIFile(filename: "{{.+}}\\UNIQUE_DIR\\debug-info-mingw.cpp",
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-EVIL
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name debug-prefix-map.c | FileCheck %s
Index: clang/test/CodeGen/debug-info-preprocessed-file.i
===
--- clang/test/CodeGen/debug-info-preprocessed-file.i
+++ clang/test/CodeGen/debug-info-preprocessed-file.i
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 # 1 "/foo/bar/preprocessed-input.c"
 # 1 "" 1
 # 1 "" 3
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,6 +444,12 @@
   StringRef Dir;
   StringRef File;
   std::string RemappedFile = remapDIPath(FileName);
+#ifdef _WIN32
+  // Convert RemappedFile to native style when Windows
+  SmallString<128> NativeFileName = StringRef(RemappedFile);
+  llvm::sys::path::native(NativeFileName);
+  RemappedFile = (std::string)NativeFileName.str();
+#endif
   std::string CurDir = remapD

[PATCH] D108421: Mark openmp internal global dso_local

2021-08-19 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 367700.
kamleshbhalui added a comment.

clang formatted


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2179,11 +2179,14 @@
 return &*Elem.second;
   }
 
-  return Elem.second = new llvm::GlobalVariable(
- CGM.getModule(), Ty, /*IsConstant*/ false,
- llvm::GlobalValue::CommonLinkage, 
llvm::Constant::getNullValue(Ty),
- Elem.first(), /*InsertBefore=*/nullptr,
- llvm::GlobalValue::NotThreadLocal, AddressSpace);
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+  CGM.getModule(), Ty, /*IsConstant*/ false,
+  llvm::GlobalValue::CommonLinkage, llvm::Constant::getNullValue(Ty),
+  Elem.first(), /*InsertBefore=*/nullptr, 
llvm::GlobalValue::NotThreadLocal,
+  AddressSpace);
+  GV->setDSOLocal(true);
+  Elem.second = GV;
+  return Elem.second;
 }
 
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2179,11 +2179,14 @@
 return &*Elem.second;
   }
 
-  return Elem.second = new llvm::GlobalVariable(
- CGM.getModule(), Ty, /*IsConstant*/ false,
- llvm::GlobalValue::CommonLinkage, llvm::Constant::getNullValue(Ty),
- Elem.first(), /*InsertBefore=*/nullptr,
- llvm::GlobalValue::NotThreadLocal, AddressSpace);
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+  CGM.getModule(), Ty, /*IsConstant*/ false,
+  llvm::GlobalValue::CommonLinkage, llvm::Constant::getNullValue(Ty),
+  Elem.first(), /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
+  AddressSpace);
+  GV->setDSOLocal(true);
+  Elem.second = GV;
+  return Elem.second;
 }
 
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108421: Mark openmp internal global dso_local

2021-08-21 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 367953.
kamleshbhalui added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

updated test and make changes local to auto generated global vars for lock.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/critical_codegen_attr.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2487,7 +2487,12 @@
 Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getNameWithSeparators({Prefix, "var"}, ".", ".");
-  return getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *GV = cast(
+  getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name));
+  if (!GV->isDSOLocal())
+GV->setDSOLocal(true);
+
+  return cast(GV);
 }
 
 GlobalVariable *
Index: clang/test/OpenMP/critical_codegen_attr.cpp
===
--- clang/test/OpenMP/critical_codegen_attr.cpp
+++ clang/test/OpenMP/critical_codegen_attr.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
Index: clang/test/OpenMP/critical_codegen.cpp
===
--- clang/test/OpenMP/critical_codegen.cpp
+++ clang/test/OpenMP/critical_codegen.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2189,7 +2189,12 @@
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getName({Prefix, "var"});
-  return getOrCreateInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *GV = cast(
+  getOrCreateInternalVariable(KmpCriticalNameTy, Name));
+  if (!GV->isDSOLocal())
+GV->setDSOLocal(true);
+
+  return cast(GV);
 }
 
 namespace {


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2487,7 +2487,12 @@
 Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getNameWithSeparators({Prefix, "var"}, ".", ".");
-  return getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *GV = cast(
+  getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name));
+  if (!GV->isDSOLocal())
+GV->setDSOLocal(true);
+
+  return cast(GV);
 }
 
 GlobalVariable *
Index: clang/test/OpenMP/critical_codegen_attr.cpp
===
--- clang/test/OpenMP/critical_codegen_attr.cpp
+++ clang/test/OpenMP/critical_codegen_attr.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[

[PATCH] D108421: Mark openmp internal global dso_local

2021-08-21 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 367954.
kamleshbhalui added a comment.

assume dso local if relocation model static


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

Files:
  llvm/lib/Target/TargetMachine.cpp


Index: llvm/lib/Target/TargetMachine.cpp
===
--- llvm/lib/Target/TargetMachine.cpp
+++ llvm/lib/Target/TargetMachine.cpp
@@ -149,6 +149,11 @@
 return GV->isStrongDefinitionForLinker();
   }
 
+  if (TT.isOSBinFormatELF()) {
+if (RM == Reloc::Static)
+  return true;
+  }
+
   // Due to the AIX linkage model, any global with default visibility is
   // considered non-local.
   if (TT.isOSBinFormatXCOFF())


Index: llvm/lib/Target/TargetMachine.cpp
===
--- llvm/lib/Target/TargetMachine.cpp
+++ llvm/lib/Target/TargetMachine.cpp
@@ -149,6 +149,11 @@
 return GV->isStrongDefinitionForLinker();
   }
 
+  if (TT.isOSBinFormatELF()) {
+if (RM == Reloc::Static)
+  return true;
+  }
+
   // Due to the AIX linkage model, any global with default visibility is
   // considered non-local.
   if (TT.isOSBinFormatXCOFF())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108421: Mark openmp internal global dso_local

2021-08-21 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D108421#2958745 , @lebedev.ri 
wrote:

> In D108421#2958742 , @kamleshbhalui 
> wrote:
>
>> assume dso local if relocation model static
>
> I think these are two separate fixes. `TargetMachine::shouldAssumeDSOLocal()` 
> change might make sense,
> but as the comment there notes, this really should be fixed in in 
> `CGOpenMPRuntime::getOrCreateInternalVariable()` itself (is that not the 
> right default?),
> and in it's every user that incorrectly unmarks said global as being 
> `dso_local.

Please see this revision https://reviews.llvm.org/differential/diff/367953/
Should I get back to this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

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


[PATCH] D108421: Mark openmp internal global dso_local

2021-08-23 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 368261.
kamleshbhalui added a comment.

updated test and make changes local to auto generated global vars for lock.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/critical_codegen_attr.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2487,7 +2487,12 @@
 Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getNameWithSeparators({Prefix, "var"}, ".", ".");
-  return getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *GV = cast(
+  getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name));
+  if (!GV->isDSOLocal())
+GV->setDSOLocal(true);
+
+  return cast(GV);
 }
 
 GlobalVariable *
Index: clang/test/OpenMP/critical_codegen_attr.cpp
===
--- clang/test/OpenMP/critical_codegen_attr.cpp
+++ clang/test/OpenMP/critical_codegen_attr.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
Index: clang/test/OpenMP/critical_codegen.cpp
===
--- clang/test/OpenMP/critical_codegen.cpp
+++ clang/test/OpenMP/critical_codegen.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2189,7 +2189,12 @@
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getName({Prefix, "var"});
-  return getOrCreateInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *GV = cast(
+  getOrCreateInternalVariable(KmpCriticalNameTy, Name));
+  if (!GV->isDSOLocal())
+GV->setDSOLocal(true);
+
+  return cast(GV);
 }
 
 namespace {


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2487,7 +2487,12 @@
 Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getNameWithSeparators({Prefix, "var"}, ".", ".");
-  return getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *GV = cast(
+  getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name));
+  if (!GV->isDSOLocal())
+GV->setDSOLocal(true);
+
+  return cast(GV);
 }
 
 GlobalVariable *
Index: clang/test/OpenMP/critical_codegen_attr.cpp
===
--- clang/test/OpenMP/critical_codegen_attr.cpp
+++ clang/test/OpenMP/critical_codegen_attr.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] zeroinitializer
+// ALL:  

[PATCH] D108421: Mark openmp internal global dso_local

2021-09-01 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

In D108421#2958848 , @MaskRay wrote:

> If you read the comment in TargetMachine::shouldAssumeDSOLocal: this is the 
> wrong direction. dso_local is assumed to be marked by the frontend.
>
> Direct accesses and GOT accesses are trade-offs. Direct accesses are not 
> always preferred. The MachO special case is an unfortunate case for their xnu 
> kernel, not a good example here.

@MaskRay I would like to know more about these trade-offs details, any 
supporting documents will do.
Considering below testcase, can you shed some light how code generated by 
llc-12 is better than llc-11 for given testcase?
https://godbolt.org/z/x9xojWb58
And FYI this testcase does not work when build as Linux Kernel Module. LKM 
loader throw error("Unknown rela relocation: 42")?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

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


[PATCH] D108421: Mark openmp internal global dso_local

2021-09-05 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 370837.
kamleshbhalui added a comment.

mark dso_local only when non-pic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/critical_codegen_attr.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2487,7 +2487,13 @@
 Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getNameWithSeparators({Prefix, "var"}, ".", ".");
-  return getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *GV = cast(
+  getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name));
+  bool IsPIE = GV->getParent()->getPIELevel() != PIELevel::Default;
+  bool IsPIC = GV->getParent()->getPICLevel() != PICLevel::NotPIC;
+  GV->setDSOLocal(!IsPIC || IsPIE);
+
+  return cast(GV);
 }
 
 GlobalVariable *
Index: clang/test/OpenMP/critical_codegen_attr.cpp
===
--- clang/test/OpenMP/critical_codegen_attr.cpp
+++ clang/test/OpenMP/critical_codegen_attr.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
Index: clang/test/OpenMP/critical_codegen.cpp
===
--- clang/test/OpenMP/critical_codegen.cpp
+++ clang/test/OpenMP/critical_codegen.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -208,6 +208,13 @@
 ModuleNameHash = (Twine(".__uniq.") +
 Twine(toString(IntHash, /* Radix = */ 10, /* Signed = */false))).str();
   }
+
+  if (uint32_t PLevel = Context.getLangOpts().PICLevel) {
+assert(PLevel < 3 && "Invalid PIC Level");
+getModule().setPICLevel(static_cast(PLevel));
+if (Context.getLangOpts().PIE)
+  getModule().setPIELevel(static_cast(PLevel));
+  }
 }
 
 CodeGenModule::~CodeGenModule() {}
@@ -745,13 +752,6 @@
 }
   }
 
-  if (uint32_t PLevel = Context.getLangOpts().PICLevel) {
-assert(PLevel < 3 && "Invalid PIC Level");
-getModule().setPICLevel(static_cast(PLevel));
-if (Context.getLangOpts().PIE)
-  getModule().setPIELevel(static_cast(PLevel));
-  }
-
   if (getCodeGenOpts().CodeModel.size() > 0) {
 unsigned CM = llvm::StringSwitch(getCodeGenOpts().CodeModel)
   .Case("tiny", llvm::CodeModel::Tiny)
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2189,7 +2189,12 @@
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getName({Prefix, "var"});
-  return getOrCreateInternalVariable(KmpCriticalNameTy, Name);
+  llvm::GlobalVariable *GV = cast(
+  getOrCreateInternalVariable(KmpCriticalNameTy, Name));
+  bool IsPIE = GV->getParent()->getPIELevel() != llvm::PIELevel::Default;
+  bool IsPIC = GV->getParent()->getPICLevel() != llvm::PICLevel::NotPIC;
+  GV->setDSOLocal(!IsPIC || IsPIE);
+  return cast(GV);
 }
 
 namespace {
_

[PATCH] D108421: Mark openmp internal global dso_local

2021-09-07 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

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


[PATCH] D108421: Mark openmp internal global dso_local

2021-09-13 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

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