gcc-changelog - Revert commits

2020-06-30 Thread Martin Liška

Hey.

Apparently git-hooks skip all verification hooks for Revert commits:
https://github.com/AdaCore/git-hooks#revert-commits

I guess it's undesirable for us as we want to generate ChangeLog entries.
Thus I recommend to disable the bail out (attached patch).

And I'm sending a patch to gcc-changelog that skips the problematic revision
2635f9e5086318f4560997d9741fdda496b9c801 so that 
gcc-changelog/git_update_version.py
succeeds.

Thoughts?
Martin
>From d75559271a84b49d996cb5f70e805d7e20c4ab7b Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Tue, 30 Jun 2020 09:26:10 +0200
Subject: [PATCH] gcc-changelog: skip problematic revision in
 git_update_version.

contrib/ChangeLog:

	* gcc-changelog/git_update_version.py: Skip a Revert commit
	we allowed on master.
---
 contrib/gcc-changelog/git_update_version.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/contrib/gcc-changelog/git_update_version.py b/contrib/gcc-changelog/git_update_version.py
index ac1b206d238..ee92607d738 100755
--- a/contrib/gcc-changelog/git_update_version.py
+++ b/contrib/gcc-changelog/git_update_version.py
@@ -34,6 +34,9 @@ def read_timestamp(path):
 
 def prepend_to_changelog_files(repo, folder, git_commit, add_to_git):
 if not git_commit.success:
+# skip a Revert revision we accepted to master
+if git_commit.hexsha == '2635f9e5086318f4560997d9741fdda496b9c801':
+return
 for error in git_commit.errors:
 print(error)
 raise AssertionError()
-- 
2.27.0

>From 6c06403c4bb8570adc3f2bc9ec3b1c437ec281af Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Tue, 30 Jun 2020 09:28:06 +0200
Subject: [PATCH] Run checks for Revert commits.

---
 hooks/updates/__init__.py | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/hooks/updates/__init__.py b/hooks/updates/__init__.py
index e47145f..14abbd1 100644
--- a/hooks/updates/__init__.py
+++ b/hooks/updates/__init__.py
@@ -231,17 +231,8 @@ class AbstractUpdate(object):
 # handled by the __no_cvs_check_user_override method.
 return
 
-# Create a list of commits that were added, but with revert
-# commits being filtered out. We have decided that revert commits
-# should not be subject to any check (QB08-047).  This allows
-# users to quickly revert a commit if need be, without having
-# to worry about bumping into any check of any kind.
+# Create a list of commits that were added.
 added = self.added_commits
-for commit in added:
-if is_revert_commit(commit.rev):
-debug('revert commit detected,'
-  ' all checks disabled for this commit: %s' % commit.rev)
-added.remove(commit)
 
 if not added:
 # There are no new commits, so nothing further to check.
-- 
2.27.0



Re: Emit a variable defined in gcc

2020-06-30 Thread Martin Liška

On 6/30/20 7:55 AM, Harshit Sharma via Gcc wrote:

Hello,
I am working on a gcc patch for asan.


Hey.

Good to hear, what kind of feature is that?


The patch is almost ready except one
thing. To make sure that the user has applied this patch before using asan
feature, I want to declare an additional variable in gcc which is reference
by our source code so that if this patch is missing, the user gets an error
compiling the code because the reference to this variable will not be
resolved.


A nice example can be emission of global variables that are used for 
-fprofile-generate:
see gcc/tree-profile.c:194-202.

Let me know if it helps?
Martin



I am still new to gcc development. So, can anyone tell me how can I make
gcc emit this variable?


Thanks,
Harshit





gcc-changelog: Support git revert commit messages

2020-06-30 Thread Martin Liška

Hello.

After a brief discussion with Jakub, I was convinced to support 'git revert' 
where
a ChangeLog is created from the commit the was reverted.

One example:

$ git gcc-verify 2635f9e5086318f4560997d9741fdda496b9c801 -p
Checking 2635f9e5086318f4560997d9741fdda496b9c801: OK
-- libstdc++-v3/ChangeLog --
2020-06-29  Ville Voutilainen  

Revert:
2020-06-28  Ville Voutilainen  

* include/bits/basic_string.h (string(_CharT*, const _Alloc&)):
Add a __nonnull__ attribute.
* testsuite/21_strings/basic_string/cons/char/nonnull.cc: New.
* testsuite/21_strings/basic_string/cons/wchar_t/nonnull.cc: Likewise.

Where original message looks like:

commit 2635f9e5086318f4560997d9741fdda496b9c801
Author: Ville Voutilainen 
AuthorDate: Tue Jun 30 01:59:34 2020 +0300
Commit: Ville Voutilainen 
CommitDate: Tue Jun 30 01:59:34 2020 +0300

Revert "Add a __nonnnull__ attribute to std::string's _CharT* constructor"

This reverts commit b26fd416fb0a734d3f3e56629b6dff2e3c25dd40.


I'm sending 2 patches where the first one is about a refactoring (creation of 
GitInfo class).
And we'll also need to update git-hooks (use the GitInfo class).

And I checked that 'git gcc-verify HEAD~300..HEAD -p' still looks fine.

Martin
>From 68e15be455ebde3cbb5815f72daf14d68246d6b3 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Tue, 30 Jun 2020 10:40:47 +0200
Subject: [PATCH] Use new GitInfo wrapper class.

---
 hooks/pre_commit_checks.py | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hooks/pre_commit_checks.py b/hooks/pre_commit_checks.py
index fe51dca..fb00896 100644
--- a/hooks/pre_commit_checks.py
+++ b/hooks/pre_commit_checks.py
@@ -3,7 +3,7 @@ from pipes import quote
 import re
 from subprocess import Popen, PIPE, STDOUT
 
-from git_commit import GitCommit
+from git_commit import GitCommit, GitInfo
 from datetime import datetime
 
 from config import git_config
@@ -335,8 +335,9 @@ def verify_changelog_format(rev, raw_body):
 changed_files = git.diff('%s~..%s' % (rev, rev), name_status=True)
 
 date = datetime.utcfromtimestamp(int(committed_date))
-git_commit = GitCommit(date, rev, author, raw_body,
-   GitCommit.parse_git_name_status(changed_files))
+git_info = GitInfo(rev, date, author, raw_body,
+   GitCommit.parse_git_name_status(changed_files))
+git_commit = GitCommit(git_info)
 
 if git_commit.success:
 # OK
-- 
2.27.0

>From e91dae973b00ea36d31f890b5992e10d86e73096 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Tue, 30 Jun 2020 10:32:34 +0200
Subject: [PATCH 2/2] gcc-changelog: support 'This revert commit' prefix.

contrib/ChangeLog:

	* gcc-changelog/git_check_commit.py: Print revision
	of original_info.
	* gcc-changelog/git_commit.py: Support Revert commits.
---
 contrib/gcc-changelog/git_check_commit.py |  2 +-
 contrib/gcc-changelog/git_commit.py   | 22 --
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/contrib/gcc-changelog/git_check_commit.py b/contrib/gcc-changelog/git_check_commit.py
index ab6da05744a..935425ef813 100755
--- a/contrib/gcc-changelog/git_check_commit.py
+++ b/contrib/gcc-changelog/git_check_commit.py
@@ -37,7 +37,7 @@ retval = 0
 for git_commit in parse_git_revisions(args.git_path, args.revisions,
   not args.non_strict_mode):
 res = 'OK' if git_commit.success else 'FAILED'
-print('Checking %s: %s' % (git_commit.info.hexsha, res))
+print('Checking %s: %s' % (git_commit.original_info.hexsha, res))
 if git_commit.success:
 if args.print_changelog:
 git_commit.print_output()
diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index 9d821a8940d..4d003ccf496 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -159,6 +159,7 @@ LINE_LIMIT = 100
 TAB_WIDTH = 8
 CO_AUTHORED_BY_PREFIX = 'co-authored-by: '
 CHERRY_PICK_PREFIX = '(cherry picked from commit '
+REVERT_PREFIX = 'This reverts commit '
 
 REVIEW_PREFIXES = ('reviewed-by: ', 'reviewed-on: ', 'signed-off-by: ',
'acked-by: ', 'tested-by: ', 'reported-by: ',
@@ -256,6 +257,7 @@ class GitInfo:
 
 class GitCommit:
 def __init__(self, info, strict=True, commit_to_info_hook=None):
+self.original_info = info
 self.info = info
 self.message = None
 self.changes = None
@@ -265,8 +267,17 @@ class GitCommit:
 self.co_authors = []
 self.top_level_prs = []
 self.cherry_pick_commit = None
+self.revert_commit = None
 self.commit_to_info_hook = commit_to_info_hook
 
+# Identify first if the commit is a Revert commit
+for line in self.info.lines:
+if line.startswith(REVERT_PREFIX):
+self.revert_commit = line[len(REVERT_PREFIX):].rstrip('.')
+break
+  

Re: gcc-changelog: Support git revert commit messages

2020-06-30 Thread Jakub Jelinek via Gcc
On Tue, Jun 30, 2020 at 10:45:27AM +0200, Martin Liška wrote:
> Hello.
> 
> After a brief discussion with Jakub, I was convinced to support 'git revert' 
> where
> a ChangeLog is created from the commit the was reverted.

Ok.

Jakub



Re: Emit a variable defined in gcc

2020-06-30 Thread Harshit Sharma via Gcc
Hey Martin,

Thanks for your reply. Actually I am trying to have a callback function
allowing gcc to fetch shadow offset from runtime code.

In order to make sure that my users have applied this patch before using
asan feature, I want to define a variable in gcc (could be an integer)
which will be referenced by the asan library in our source code. I think I
used the wrong word 'emit' in my previous post. The variable say
"__asan_gccpatch_present" needs to be defined in gcc and then referenced by
our code (just like we do with functions such as __builtin_expect).


Thanks,
Harshit

On Tue, Jun 30, 2020 at 12:34 AM Martin Liška  wrote:

> On 6/30/20 7:55 AM, Harshit Sharma via Gcc wrote:
> > Hello,
> > I am working on a gcc patch for asan.
>
> Hey.
>
> Good to hear, what kind of feature is that?
>
> > The patch is almost ready except one
> > thing. To make sure that the user has applied this patch before using
> asan
> > feature, I want to declare an additional variable in gcc which is
> reference
> > by our source code so that if this patch is missing, the user gets an
> error
> > compiling the code because the reference to this variable will not be
> > resolved.
>
> A nice example can be emission of global variables that are used for
> -fprofile-generate:
> see gcc/tree-profile.c:194-202.
>
> Let me know if it helps?
> Martin
>
> >
> > I am still new to gcc development. So, can anyone tell me how can I make
> > gcc emit this variable?
> >
> >
> > Thanks,
> > Harshit
> >
>
>


[OMPD] Library Functions

2020-06-30 Thread y2s1982 . via Gcc
Hello everyone,

For this week, I wanted to complete the OMPD library-wide functions, namely
the ompd_initialize and ompd_finalize.  I took notes from:
- https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf
,
-
https://github.com/OpenMPToolsInterface/LLVM-openmp/blob/ompd-tests/libompd/src/omp-debug.cpp
,
and
-
https://github.com/OpenMPToolsInterface/OMPD-Technical-Report/blob/master/ompd-tr.pdf
.

It currently has some small changes (see attached) and wanted to get some
feedback on it and what more I should do for these functions.

In particular, I declared a non-static, non-const variable called
gompd_callbacks that would store an independent copy of ompd_callbacks_t.
This is different from how OpenMPToolsInterface's LLVM team has done it:
they have a static const variable that simply stores the pointer value that
was passed in.  The reason for my approach was because the
OpenMPToolsInterface's document repo stated that the argument passed in
cannot be assumed to be unchanged after the function call is completed.

My hesitation is because this is not specified in the OpenMP 5.0 API
specification document.

I would appreciate any feedback.

Cheers,

Tony Sim
From cef95b0d0c63eb364faa3d510f439bbf36a82999 Mon Sep 17 00:00:00 2001
From: y2s1982 
Date: Tue, 30 Jun 2020 18:46:34 -0400
Subject: [PATCH] libompd: added more OMPD library-wide functions


2020-06-30  Tony Sim  

libgomp/ChangeLog:

	* libgompd.h : Add gompd_callbacks variable.
	* ompd-lib.c (ompd_finalize): Add new function.

---
 libgomp/libgompd.h |  4 
 libgomp/ompd-lib.c | 15 ++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/libgomp/libgompd.h b/libgomp/libgompd.h
index 9782828bff5..2aedeecaa38 100644
--- a/libgomp/libgompd.h
+++ b/libgomp/libgompd.h
@@ -29,9 +29,13 @@
 #ifndef LIBGOMPD_H
 #define LIBGOMPD_H 1
 
+#include "omp-tools.h"
+
 #define ompd_stringify(x) ompd_str2(x)
 #define ompd_str2(x) #x
 
 #define OMPD_VERSION 201811
 
+ompd_callbacks_t* gompd_callbacks;
+
 #endif /* LIBGOMPD_H */
diff --git a/libgomp/ompd-lib.c b/libgomp/ompd-lib.c
index f0ae9e85a7e..4513dadc070 100644
--- a/libgomp/ompd-lib.c
+++ b/libgomp/ompd-lib.c
@@ -28,6 +28,7 @@
 
 #include "omp-tools.h"
 #include "libgompd.h"
+#include 
 
 ompd_rc_t
 ompd_get_api_version (ompd_word_t *version)
@@ -49,13 +50,25 @@ ompd_initialize (ompd_word_t api_version, const ompd_callbacks_t *callbacks)
 {
   static int ompd_initialized = 0;
 
+  if (!callbacks)
+return ompd_rc_bad_input;
+
   if (ompd_initialized)
 return ompd_rc_error;
 
+  gompd_callbacks = malloc(sizeof(ompd_callbacks_t));
+  *gompd_callbacks  = *callbacks;
+
   (void) api_version;
-  (void) callbacks;
 
   ompd_initialized = 1;
 
   return ompd_rc_ok;
 }
+
+ompd_rc_t
+ompd_finalize(void)
+{
+  free (gompd_callbacks);
+  return ompd_rc_ok;
+}
-- 
2.27.0



Re: [OMPD] Library Functions

2020-06-30 Thread Jakub Jelinek via Gcc
On Tue, Jun 30, 2020 at 06:50:54PM -0400, y2s1982 . via Gcc wrote:
> 2020-06-30  Tony Sim  
> 
> libgomp/ChangeLog:
> 
>   * libgompd.h : Add gompd_callbacks variable.

No space before :, but generally, you should be exact on what changed.
So
* libgompd.h: Include omp-tools.h.
(gompd_callbacks): New declaration.

>   * ompd-lib.c (ompd_finalize): Add new function.

And similarly here describe the other changes too.

> +ompd_callbacks_t* gompd_callbacks;

Formatting is wrong, space should be before * and not afterwards.
And, it should be extern too, you don't want to
have a definition in all TUs that include libgompd.h.
But, I don't really see the need for indirection, why there isn't just
extern ompd_callbacks_t gompd_callbacks;
?

> +
>  #endif /* LIBGOMPD_H */
> diff --git a/libgomp/ompd-lib.c b/libgomp/ompd-lib.c
> index f0ae9e85a7e..4513dadc070 100644
> --- a/libgomp/ompd-lib.c
> +++ b/libgomp/ompd-lib.c
> @@ -28,6 +28,7 @@
>  
>  #include "omp-tools.h"
>  #include "libgompd.h"
> +#include 

And somewhere in this file
ompd_callbacks_t gompd_callbacks;

>  
>  ompd_rc_t
>  ompd_get_api_version (ompd_word_t *version)
> @@ -49,13 +50,25 @@ ompd_initialize (ompd_word_t api_version, const 
> ompd_callbacks_t *callbacks)
>  {
>static int ompd_initialized = 0;
>  
> +  if (!callbacks)
> +return ompd_rc_bad_input;
> +
>if (ompd_initialized)
>  return ompd_rc_error;
>  
> +  gompd_callbacks = malloc(sizeof(ompd_callbacks_t));

Formatting: there should be spaces before each ( here, so
malloc (sizeof (ompd_callbacks_t)).
But, as written in OMPD, it really shouldn't use malloc/free itself,
instead it should use the callbacks to allocate and free heap memory.
But if gompd_callbacks doesn't have an indirection, you can just
  gompd_callbacks = *callbacks;
and be done with it.

> +  *gompd_callbacks  = *callbacks;

Formatting: no double space before =, just one space.
> +
>(void) api_version;
> -  (void) callbacks;
>  
>ompd_initialized = 1;
>  
>return ompd_rc_ok;
>  }
> +
> +ompd_rc_t
> +ompd_finalize(void)

And space before ( again.

> +{
> +  free (gompd_callbacks);

And if gompd_callbacks isn't a pointer, no need to free anything.
Otherwise, you should use a callback to free the memory.

> +  return ompd_rc_ok;
> +}
> -- 
> 2.27.0
> 


Jakub



An problematic interaction between a call created by gimple_build_call and inlining

2020-06-30 Thread Gary Oblock via Gcc
I'm trying to generate calls to "free" on the fly at ipa time.

I've tried several things (given below) but they both fail
in expand_call_inline in tree-inline.c on this gcc_checking_assert:

  cg_edge = id->dst_node->get_edge (stmt);
  gcc_checking_assert (cg_edge);

Now, I've tried using the built in free via:

  tree fndecl_free = builtin_decl_explicit( BUILT_IN_FREE);
  // Note to_free is set between here and the call by an assign
  tree to_free =
make_temp_ssa_name( reorg_pointer_type, NULL, "malloc_to_free");
  .
  .
  gcall *free_call = gimple_build_call( fndecl_free, 1, to_free);

or building the fndecl from scrath:

  tree fntype = build_function_type ( free_return_type, param_type_list);
  tree fnname = get_identifier ( "free");
  tree fndecl_free =
build_decl ( input_location, FUNCTION_DECL, fnname, fntype);
  gcall *free_call = gimple_build_call( fndecl_free, 1, to_free);

Note, I was able to get something similar to work for "malloc" by
using the fndecl I extracted from an existing malloc call.

Your advice on how to build a fndecl that doesn't have this
problem is appreciated.

Thanks,

Gary Oblock


CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for 
the sole use of the intended recipient(s) and contains information that is 
confidential and proprietary to Ampere Computing or its subsidiaries. It is to 
be used solely for the purpose of furthering the parties' business 
relationship. Any review, copying, or distribution of this email (or any 
attachments thereto) is strictly prohibited. If you are not the intended 
recipient, please contact the sender immediately and permanently delete the 
original and any copies of this email and any attachments thereto.