* GCC 10 backports
@ 2020-10-01 19:18 Martin Liška
2020-10-02 11:15 ` Martin Liška
2020-10-07 12:03 ` Martin Liška
0 siblings, 2 replies; 10+ messages in thread
From: Martin Liška @ 2020-10-01 19:18 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 63 bytes --]
I'm going to install the following 3 tested backports.
Martin
[-- Attachment #2: 0003-gcov-fix-streaming-of-HIST_TYPE_IOR-histogram-type.patch --]
[-- Type: text/x-patch, Size: 1191 bytes --]
From 0d91a9613ca1c4b8b11d668a1b8e1a6a37c41b7a Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Fri, 25 Sep 2020 16:21:34 +0200
Subject: [PATCH 3/3] gcov: fix streaming of HIST_TYPE_IOR histogram type.
gcc/ChangeLog:
PR gcov-profile/64636
* value-prof.c (stream_out_histogram_value): Allow negative
values for HIST_TYPE_IOR.
(cherry picked from commit 1921ebcaf6467996aede69e1bbe32400d8a20fe7)
---
gcc/value-prof.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 45677be46b1..9d60b56c43a 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -332,7 +332,10 @@ stream_out_histogram_value (struct output_block *ob, histogram_value hist)
/* When user uses an unsigned type with a big value, constant converted
to gcov_type (a signed type) can be negative. */
gcov_type value = hist->hvalue.counters[i];
- if (hist->type == HIST_TYPE_TOPN_VALUES)
+ if (hist->type == HIST_TYPE_TOPN_VALUES
+ || hist->type == HIST_TYPE_IOR)
+ /* Note that the IOR counter tracks pointer values and these can have
+ sign bit set. */
;
else
gcc_assert (value >= 0);
--
2.28.0
[-- Attachment #3: 0002-switch-conversion-make-a-rapid-speed-up.patch --]
[-- Type: text/x-patch, Size: 5541 bytes --]
From 4c2be1627f6b78dff9209b979b26080f5b929d89 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 24 Sep 2020 13:34:13 +0200
Subject: [PATCH 2/3] switch conversion: make a rapid speed up
gcc/ChangeLog:
PR tree-optimization/96979
* tree-switch-conversion.c (jump_table_cluster::can_be_handled):
Make a fast bail out.
(bit_test_cluster::can_be_handled): Likewise here.
* tree-switch-conversion.h (get_range): Use wi::to_wide instead
of a folding.
gcc/testsuite/ChangeLog:
PR tree-optimization/96979
* g++.dg/tree-ssa/pr96979.C: New test.
(cherry picked from commit e46858e4eeee45d35ca4a7df1996186fe884879b)
---
gcc/testsuite/g++.dg/tree-ssa/pr96979.C | 48 +++++++++++++++++++++++++
gcc/tree-switch-conversion.c | 37 ++++++++++++++-----
gcc/tree-switch-conversion.h | 7 ++--
3 files changed, 79 insertions(+), 13 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr96979.C
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr96979.C b/gcc/testsuite/g++.dg/tree-ssa/pr96979.C
new file mode 100644
index 00000000000..ec0f57a8548
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr96979.C
@@ -0,0 +1,48 @@
+/* PR tree-optimization/96979 */
+/* { dg-do compile } */
+/* { dg-options "-std=c++17 -O2" } */
+
+using u64 = unsigned long long;
+
+constexpr inline u64
+foo (const char *str) noexcept
+{
+ u64 value = 0xcbf29ce484222325ULL;
+ for (u64 i = 0; str[i]; i++)
+ value = (value ^ u64(str[i])) * 0x100000001b3ULL;
+ return value;
+}
+
+struct V
+{
+ enum W
+ {
+#define A(n) n,
+#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7) A(n##8) A(n##9)
+#define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7) B(n##8) B(n##9)
+#define D(n) C(n##0) C(n##1) C(n##2) C(n##3) C(n##4) C(n##5) C(n##6) C(n##7) C(n##8) C(n##9)
+#define E D(foo1) D(foo2) D(foo3)
+ E
+ last
+ };
+
+ constexpr static W
+ bar (const u64 h) noexcept
+ {
+ switch (h)
+ {
+#undef A
+#define F(n) #n
+#define A(n) case foo (F(n)): return n;
+ E
+ }
+ return last;
+ }
+};
+
+int
+baz (const char *s)
+{
+ const u64 h = foo (s);
+ return V::bar (h);
+}
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index bf910dd62b5..8da1be1cd99 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1271,6 +1271,18 @@ jump_table_cluster::can_be_handled (const vec<cluster *> &clusters,
if (range == 0)
return false;
+ if (range > HOST_WIDE_INT_M1U / 100)
+ return false;
+
+ unsigned HOST_WIDE_INT lhs = 100 * range;
+ if (lhs < range)
+ return false;
+
+ /* First make quick guess as each cluster
+ can add at maximum 2 to the comparison_count. */
+ if (lhs > 2 * max_ratio * (end - start + 1))
+ return false;
+
unsigned HOST_WIDE_INT comparison_count = 0;
for (unsigned i = start; i <= end; i++)
{
@@ -1278,10 +1290,6 @@ jump_table_cluster::can_be_handled (const vec<cluster *> &clusters,
comparison_count += sc->m_range_p ? 2 : 1;
}
- unsigned HOST_WIDE_INT lhs = 100 * range;
- if (lhs < range)
- return false;
-
return lhs <= max_ratio * comparison_count;
}
@@ -1367,12 +1375,12 @@ bit_test_cluster::can_be_handled (unsigned HOST_WIDE_INT range,
{
/* Check overflow. */
if (range == 0)
- return 0;
+ return false;
if (range >= GET_MODE_BITSIZE (word_mode))
return false;
- return uniq <= 3;
+ return uniq <= m_max_case_bit_tests;
}
/* Return true when cluster starting at START and ending at END (inclusive)
@@ -1382,6 +1390,7 @@ bool
bit_test_cluster::can_be_handled (const vec<cluster *> &clusters,
unsigned start, unsigned end)
{
+ auto_vec<int, m_max_case_bit_tests> dest_bbs;
/* For algorithm correctness, bit test for a single case must return
true. We bail out in is_beneficial if it's called just for
a single case. */
@@ -1390,15 +1399,25 @@ bit_test_cluster::can_be_handled (const vec<cluster *> &clusters,
unsigned HOST_WIDE_INT range = get_range (clusters[start]->get_low (),
clusters[end]->get_high ());
- auto_bitmap dest_bbs;
+
+ /* Make a guess first. */
+ if (!can_be_handled (range, m_max_case_bit_tests))
+ return false;
for (unsigned i = start; i <= end; i++)
{
simple_cluster *sc = static_cast<simple_cluster *> (clusters[i]);
- bitmap_set_bit (dest_bbs, sc->m_case_bb->index);
+ /* m_max_case_bit_tests is very small integer, thus the operation
+ is constant. */
+ if (!dest_bbs.contains (sc->m_case_bb->index))
+ {
+ if (dest_bbs.length () >= m_max_case_bit_tests)
+ return false;
+ dest_bbs.quick_push (sc->m_case_bb->index);
+ }
}
- return can_be_handled (range, bitmap_count_bits (dest_bbs));
+ return true;
}
/* Return true when COUNT of cases of UNIQ labels is beneficial for bit test
diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h
index 9ebcf109319..dbfd9eecba2 100644
--- a/gcc/tree-switch-conversion.h
+++ b/gcc/tree-switch-conversion.h
@@ -84,11 +84,10 @@ public:
then return 0. */
static unsigned HOST_WIDE_INT get_range (tree low, tree high)
{
- tree r = fold_build2 (MINUS_EXPR, TREE_TYPE (low), high, low);
- if (!tree_fits_uhwi_p (r))
+ wide_int w = wi::to_wide (high) - wi::to_wide (low);
+ if (wi::neg_p (w, TYPE_SIGN (TREE_TYPE (low))) || !wi::fits_uhwi_p (w))
return 0;
-
- return tree_to_uhwi (r) + 1;
+ return w.to_uhwi () + 1;
}
/* Case label. */
--
2.28.0
[-- Attachment #4: 0001-gcov-fix-streaming-corruption.patch --]
[-- Type: text/x-patch, Size: 2343 bytes --]
From 4c0b4be28c6a8d8cab91ca234cdc5c410936141d Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Mon, 21 Sep 2020 16:26:10 +0200
Subject: [PATCH 1/3] gcov: fix streaming corruption
gcc/ChangeLog:
PR gcov-profile/97069
* profile.c (branch_prob): Line number must be at least 1.
gcc/testsuite/ChangeLog:
PR gcov-profile/97069
* g++.dg/gcov/pr97069.C: New test.
(cherry picked from commit 6b4e8bf88f1172ce8561f57b12fb81063b21a78f)
---
gcc/profile.c | 6 +++---
gcc/testsuite/g++.dg/gcov/pr97069.C | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/gcov/pr97069.C
diff --git a/gcc/profile.c b/gcc/profile.c
index cd754c4c66a..2e5ab0d3415 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -1367,7 +1367,7 @@ branch_prob (bool thunk)
seen_locations.add (loc);
expanded_location curr_location = expand_location (loc);
output_location (&streamed_locations, curr_location.file,
- curr_location.line, &offset, bb);
+ MAX (1, curr_location.line), &offset, bb);
}
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -1378,7 +1378,7 @@ branch_prob (bool thunk)
{
seen_locations.add (loc);
output_location (&streamed_locations, gimple_filename (stmt),
- gimple_lineno (stmt), &offset, bb);
+ MAX (1, gimple_lineno (stmt)), &offset, bb);
}
}
@@ -1393,7 +1393,7 @@ branch_prob (bool thunk)
{
expanded_location curr_location = expand_location (loc);
output_location (&streamed_locations, curr_location.file,
- curr_location.line, &offset, bb);
+ MAX (1, curr_location.line), &offset, bb);
}
if (offset)
diff --git a/gcc/testsuite/g++.dg/gcov/pr97069.C b/gcc/testsuite/g++.dg/gcov/pr97069.C
new file mode 100644
index 00000000000..040e336662a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/pr97069.C
@@ -0,0 +1,20 @@
+// PR gcov-profile/97069
+// { dg-options "--coverage" }
+// { dg-do run { target native } }
+
+# 0 "pr97069.C"
+# 0 "<built-in>"
+# 0 "<command-line>"
+# 1 "/usr/include/stdc-predef.h" 1 3 4
+# 0 "<command-line>" 2
+# 1 "pr97069.C"
+int main()
+{
+ return 0;
+}
+# 0 "pr97069.C"
+void zero_line_directive()
+{
+}
+
+// { dg-final { run-gcov pr97069.C } }
--
2.28.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: GCC 10 backports
2020-10-01 19:18 GCC 10 backports Martin Liška
@ 2020-10-02 11:15 ` Martin Liška
2020-10-07 12:03 ` Martin Liška
1 sibling, 0 replies; 10+ messages in thread
From: Martin Liška @ 2020-10-02 11:15 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 138 bytes --]
On 10/1/20 9:18 PM, Martin Liška wrote:
> I'm going to install the following 3 tested backports.
>
> Martin
... and one more.
Martin
[-- Attachment #2: 0001-GCOV-do-not-mangle-.gcno-files.patch --]
[-- Type: text/x-patch, Size: 1470 bytes --]
From f97ef0b2dfdad07db3d564b932c7b7373654b7d4 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Fri, 25 Sep 2020 10:53:26 +0200
Subject: [PATCH] GCOV: do not mangle .gcno files.
gcc/ChangeLog:
PR gcov-profile/97193
* coverage.c (coverage_init): GCDA note files should not be
mangled and should end in output directory.
(cherry picked from commit f8dcbea5d2fb17dca3a7de97f15fc49997222365)
---
gcc/coverage.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 7d82e44c152..38820bc170f 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -1200,6 +1200,8 @@ coverage_obj_finish (vec<constructor_elt, va_gc> *ctor)
void
coverage_init (const char *filename)
{
+ const char *original_filename = filename;
+ int original_len = strlen (original_filename);
#if HAVE_DOS_BASED_FILE_SYSTEM
const char *separator = "\\";
#else
@@ -1271,9 +1273,9 @@ coverage_init (const char *filename)
bbg_file_name = xstrdup (profile_note_location);
else
{
- bbg_file_name = XNEWVEC (char, len + strlen (GCOV_NOTE_SUFFIX) + 1);
- memcpy (bbg_file_name, filename, len);
- strcpy (bbg_file_name + len, GCOV_NOTE_SUFFIX);
+ bbg_file_name = XNEWVEC (char, original_len + strlen (GCOV_NOTE_SUFFIX) + 1);
+ memcpy (bbg_file_name, original_filename, original_len);
+ strcpy (bbg_file_name + original_len, GCOV_NOTE_SUFFIX);
}
if (!gcov_open (bbg_file_name, -1))
--
2.28.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: GCC 10 backports
2020-10-01 19:18 GCC 10 backports Martin Liška
2020-10-02 11:15 ` Martin Liška
@ 2020-10-07 12:03 ` Martin Liška
2020-10-15 8:43 ` Martin Liška
2020-10-16 8:51 ` Martin Liška
1 sibling, 2 replies; 10+ messages in thread
From: Martin Liška @ 2020-10-07 12:03 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 152 bytes --]
On 10/1/20 9:18 PM, Martin Liška wrote:
> I'm going to install the following 3 tested backports.
>
> Martin
One more patch that I've tested.
Martin
[-- Attachment #2: 0001-lto-fix-LTO-debug-sections-copying.patch --]
[-- Type: text/x-patch, Size: 3765 bytes --]
From d957172d0d43cdcf8dc098ae493c193d6678ecfd Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Mon, 5 Oct 2020 18:03:08 +0200
Subject: [PATCH] lto: fix LTO debug sections copying.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
readelf -S prints:
There are 81999 section headers, starting at offset 0x1f488060:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 01404f 00 81998 0 0
[ 1] .group GROUP 0000000000000000 000040 000008 04 81995 105027 4
...
[81995] .symtab SYMTAB 0000000000000000 d5d9298 2db310 18 81997 105026 8
[81996] .symtab_shndx SYMTAB SECTION INDICES 0000000000000000 d8b45a8 079dd8 04 81995 0 4
[81997] .strtab STRTAB 0000000000000000 d92e380 80460c 00 0 0 1
...
Looking at the documentation:
Table 7–15 ELF sh_link and sh_info Interpretation
sh_type - sh_link
SHT_SYMTAB - The section header index of the associated string table.
SHT_SYMTAB_SHNDX - The section header index of the associated symbol table.
As seen, sh_link of a SHT_SYMTAB always points to a .strtab and readelf
confirms that.
So we need to use reverse mapping taken from
[81996] .symtab_shndx SYMTAB SECTION INDICES 0000000000000000 d8b45a8 079dd8 04 81995 0 4
where sh_link points to 81995.
libiberty/ChangeLog:
PR lto/97290
* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
Use sh_link of a .symtab_shndx section.
(cherry picked from commit 190c04ba36d9c6c3dce41f12012aa97c6d7f22f5)
---
libiberty/simple-object-elf.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c
index 7c9d492f6a4..37e73348cb7 100644
--- a/libiberty/simple-object-elf.c
+++ b/libiberty/simple-object-elf.c
@@ -1191,7 +1191,7 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
unsigned int sh_link;
sh_link = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
shdr, sh_link, Elf_Word);
- symtab_indices_shndx[sh_link - 1] = i;
+ symtab_indices_shndx[sh_link - 1] = i - 1;
/* Always discard the extended index sections, after
copying it will not be needed. This way we don't need to
update it and deal with the ordering constraints of
@@ -1372,19 +1372,22 @@ simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
{
unsigned entsize = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
shdr, sh_entsize, Elf_Addr);
- unsigned strtab = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
- shdr, sh_link, Elf_Word);
size_t prevailing_name_idx = 0;
unsigned char *ent;
unsigned *shndx_table = NULL;
/* Read the section index table if present. */
if (symtab_indices_shndx[i - 1] != 0)
{
- unsigned char *sidxhdr = shdrs + (strtab - 1) * shdr_size;
+ unsigned char *sidxhdr = shdrs + symtab_indices_shndx[i - 1] * shdr_size;
off_t sidxoff = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
sidxhdr, sh_offset, Elf_Addr);
size_t sidxsz = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
sidxhdr, sh_size, Elf_Addr);
+ unsigned int shndx_type
+ = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
+ sidxhdr, sh_type, Elf_Word);
+ if (shndx_type != SHT_SYMTAB_SHNDX)
+ return "Wrong section type of a SYMTAB SECTION INDICES section";
shndx_table = (unsigned *)XNEWVEC (char, sidxsz);
simple_object_internal_read (sobj->descriptor,
sobj->offset + sidxoff,
--
2.28.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: GCC 10 backports
2020-10-07 12:03 ` Martin Liška
@ 2020-10-15 8:43 ` Martin Liška
2020-10-16 8:51 ` Martin Liška
1 sibling, 0 replies; 10+ messages in thread
From: Martin Liška @ 2020-10-15 8:43 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 45 bytes --]
And one more patch I've just tested.
Martin
[-- Attachment #2: 0001-IPA-fix-profile-handling-in-IRA.patch --]
[-- Type: text/x-patch, Size: 1926 bytes --]
From 13febeded26dd6e00f57b39b48520e049209651b Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Tue, 13 Oct 2020 16:44:47 +0200
Subject: [PATCH] IPA: fix profile handling in IRA
gcc/ChangeLog:
PR ipa/97295
* profile-count.c (profile_count::to_frequency): Move part of
gcc_assert to STATIC_ASSERT.
* regs.h (REG_FREQ_FROM_BB): Do not use count.to_frequency for
a function that does not have count_max initialized.
(cherry picked from commit 508e2d88a4c512e8b8685cf5ba201ad48e6bb58d)
---
gcc/profile-count.c | 4 ++--
gcc/regs.h | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/gcc/profile-count.c b/gcc/profile-count.c
index c89914ff8a0..aaefc11ff3d 100644
--- a/gcc/profile-count.c
+++ b/gcc/profile-count.c
@@ -270,8 +270,8 @@ profile_count::to_frequency (struct function *fun) const
return BB_FREQ_MAX;
if (*this == zero ())
return 0;
- gcc_assert (REG_BR_PROB_BASE == BB_FREQ_MAX
- && fun->cfg->count_max.initialized_p ());
+ STATIC_ASSERT (REG_BR_PROB_BASE == BB_FREQ_MAX);
+ gcc_assert (fun->cfg->count_max.initialized_p ());
profile_probability prob = probability_in (fun->cfg->count_max);
if (!prob.initialized_p ())
return REG_BR_PROB_BASE;
diff --git a/gcc/regs.h b/gcc/regs.h
index 1decd2c2d2a..11416c47f6f 100644
--- a/gcc/regs.h
+++ b/gcc/regs.h
@@ -128,7 +128,8 @@ extern size_t reg_info_p_size;
or profile driven feedback is available and the function is never executed,
frequency is always equivalent. Otherwise rescale the basic block
frequency. */
-#define REG_FREQ_FROM_BB(bb) (optimize_function_for_size_p (cfun) \
+#define REG_FREQ_FROM_BB(bb) ((optimize_function_for_size_p (cfun) \
+ || !cfun->cfg->count_max.initialized_p ()) \
? REG_FREQ_MAX \
: ((bb)->count.to_frequency (cfun) \
* REG_FREQ_MAX / BB_FREQ_MAX) \
--
2.28.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: GCC 10 backports
2020-10-07 12:03 ` Martin Liška
2020-10-15 8:43 ` Martin Liška
@ 2020-10-16 8:51 ` Martin Liška
2020-10-21 9:20 ` [PATCH 1/2] ASAN: Support detect_invalid_pointer_pairs=1 with detect_stack_use_after_return=1 Martin Liška
` (3 more replies)
1 sibling, 4 replies; 10+ messages in thread
From: Martin Liška @ 2020-10-16 8:51 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 231 bytes --]
On 10/7/20 2:03 PM, Martin Liška wrote:
> On 10/1/20 9:18 PM, Martin Liška wrote:
>> I'm going to install the following 3 tested backports.
>>
>> Martin
>
> One more patch that I've tested.
>
> Martin
Adding one more.
Martin
[-- Attachment #2: 0001-IPA-compare-VRP-types.patch --]
[-- Type: text/x-patch, Size: 1899 bytes --]
From afcdd7b8ff51a7df885dc3fdf38be566a4c1fdbf Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 15 Oct 2020 14:57:31 +0200
Subject: [PATCH] IPA: compare VRP types.
gcc/ChangeLog:
PR ipa/97404
* ipa-prop.c (struct ipa_vr_ggc_hash_traits):
Compare types of VRP as we can merge ranges of different types.
gcc/testsuite/ChangeLog:
PR ipa/97404
* gcc.c-torture/execute/pr97404.c: New test.
(cherry picked from commit a86623902767122c71c7229150a8b8a79cbb3673)
---
gcc/ipa-prop.c | 3 +-
gcc/testsuite/gcc.c-torture/execute/pr97404.c | 28 +++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr97404.c
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 40edee7951c..7c8aee20a88 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -122,7 +122,8 @@ struct ipa_vr_ggc_hash_traits : public ggc_cache_remove <value_range_base *>
static bool
equal (const value_range_base *a, const value_range_base *b)
{
- return a->equal_p (*b);
+ return (a->equal_p (*b)
+ && types_compatible_p (a->type (), b->type ()));
}
static void
mark_empty (value_range_base *&p)
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr97404.c b/gcc/testsuite/gcc.c-torture/execute/pr97404.c
new file mode 100644
index 00000000000..7e5ce231725
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr97404.c
@@ -0,0 +1,28 @@
+/* PR ipa/97404 */
+/* { dg-additional-options "-fno-inline" } */
+
+char a, b;
+long c;
+short d, e;
+long *f = &c;
+int g;
+char h(signed char i) { return 0; }
+static short j(short i, int k) { return i < 0 ? 0 : i >> k; }
+void l(void);
+void m(void)
+{
+ e = j(d | 9766, 11);
+ *f = e;
+}
+void l(void)
+{
+ a = 5 | g;
+ b = h(a);
+}
+int main()
+{
+ m();
+ if (c != 4)
+ __builtin_abort();
+ return 0;
+}
--
2.28.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] ASAN: Support detect_invalid_pointer_pairs=1 with detect_stack_use_after_return=1
2020-10-16 8:51 ` Martin Liška
@ 2020-10-21 9:20 ` Martin Liška
2020-10-21 9:21 ` [PATCH 2/2] libsanitizer: add test-case Martin Liška
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Martin Liška @ 2020-10-21 9:20 UTC (permalink / raw)
To: gcc-patches
Do not crash when AsanThread::GetStackVariableShadowStart does not find
a variable for a pointer on a shadow stack.
Cherry-pick from ad2be02a833e56f7fe280797280b219eb3312621.
Differential Revision: https://reviews.llvm.org/D89552
(cherry picked from commit b69f33f477b9ac38af3c39465600ae74a3554878)
---
libsanitizer/asan/asan_thread.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libsanitizer/asan/asan_thread.cpp b/libsanitizer/asan/asan_thread.cpp
index 6734d9a1668..cb374b28622 100644
--- a/libsanitizer/asan/asan_thread.cpp
+++ b/libsanitizer/asan/asan_thread.cpp
@@ -366,7 +366,9 @@ uptr AsanThread::GetStackVariableShadowStart(uptr addr) {
bottom = stack_bottom();
} else if (has_fake_stack()) {
bottom = fake_stack()->AddrIsInFakeStack(addr);
- CHECK(bottom);
+ if (bottom == 0) {
+ return 0;
+ }
} else {
return 0;
}
--
2.28.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] libsanitizer: add test-case
2020-10-16 8:51 ` Martin Liška
2020-10-21 9:20 ` [PATCH 1/2] ASAN: Support detect_invalid_pointer_pairs=1 with detect_stack_use_after_return=1 Martin Liška
@ 2020-10-21 9:21 ` Martin Liška
2020-10-29 18:21 ` [PATCH] LTO: get_section: add new argument Martin Liška
2020-12-09 20:17 ` GCC 10 backports Martin Liška
3 siblings, 0 replies; 10+ messages in thread
From: Martin Liška @ 2020-10-21 9:21 UTC (permalink / raw)
To: gcc-patches
gcc/testsuite/ChangeLog:
PR sanitizer/97414
* g++.dg/asan/pr97414.C: New test.
(cherry picked from commit 6c5b08a2ca935c5db68e79d33e5c5b752252115c)
---
gcc/testsuite/g++.dg/asan/pr97414.C | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/asan/pr97414.C
diff --git a/gcc/testsuite/g++.dg/asan/pr97414.C b/gcc/testsuite/g++.dg/asan/pr97414.C
new file mode 100644
index 00000000000..6ea03906daa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr97414.C
@@ -0,0 +1,19 @@
+/* PR sanitizer/97414 */
+/* { dg-do run } */
+/* { dg-set-target-env-var ASAN_OPTIONS "detect_invalid_pointer_pairs=1:halt_on_error=1,detect_stack_use_after_return=1" } */
+/* { dg-options "-fsanitize=address,pointer-compare,pointer-subtract" } */
+
+[[gnu::noinline]] auto pointer_diff(const int *begin, const int *end) {
+ return end - begin;
+}
+
+int main() {
+ constexpr auto size = (2048 / sizeof(int)) + 1;
+
+ auto buf = new int[size];
+ auto end = buf + size;
+ pointer_diff(end, buf);
+ delete[] buf;
+
+ return 0;
+}
--
2.28.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] LTO: get_section: add new argument
2020-10-16 8:51 ` Martin Liška
2020-10-21 9:20 ` [PATCH 1/2] ASAN: Support detect_invalid_pointer_pairs=1 with detect_stack_use_after_return=1 Martin Liška
2020-10-21 9:21 ` [PATCH 2/2] libsanitizer: add test-case Martin Liška
@ 2020-10-29 18:21 ` Martin Liška
2020-12-09 20:17 ` GCC 10 backports Martin Liška
3 siblings, 0 replies; 10+ messages in thread
From: Martin Liška @ 2020-10-29 18:21 UTC (permalink / raw)
To: gcc-patches
One more backport I've just tested:
gcc/ChangeLog:
PR lto/97508
* langhooks.c (lhd_begin_section): Call get_section with
not_existing = true.
* output.h (get_section): Add new argument.
* varasm.c (get_section): Fail when NOT_EXISTING is true
and a section already exists.
* ipa-cp.c (ipcp_write_summary): Remove.
(ipcp_read_summary): Likewise.
* ipa-fnsummary.c (ipa_fn_summary_read): Always read jump
functions summary.
(ipa_fn_summary_write): Always stream it.
(cherry picked from commit 568de14d2e74cfdd600b8995ff6ac08c98ddef48)
---
gcc/ipa-cp.c | 20 ++------------------
gcc/ipa-fnsummary.c | 6 ++----
gcc/langhooks.c | 2 +-
gcc/output.h | 3 ++-
gcc/varasm.c | 9 +++++++--
5 files changed, 14 insertions(+), 26 deletions(-)
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index c7867dbed9b..b1f0881bd70 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -5946,22 +5946,6 @@ ipcp_generate_summary (void)
ipa_analyze_node (node);
}
-/* Write ipcp summary for nodes in SET. */
-
-static void
-ipcp_write_summary (void)
-{
- ipa_prop_write_jump_functions ();
-}
-
-/* Read ipcp summary. */
-
-static void
-ipcp_read_summary (void)
-{
- ipa_prop_read_jump_functions ();
-}
-
namespace {
const pass_data pass_data_ipa_cp =
@@ -5983,8 +5967,8 @@ public:
pass_ipa_cp (gcc::context *ctxt)
: ipa_opt_pass_d (pass_data_ipa_cp, ctxt,
ipcp_generate_summary, /* generate_summary */
- ipcp_write_summary, /* write_summary */
- ipcp_read_summary, /* read_summary */
+ NULL, /* write_summary */
+ NULL, /* read_summary */
ipcp_write_transformation_summaries, /*
write_optimization_summary */
ipcp_read_transformation_summaries, /*
diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c
index 55a0b272a96..e07c9b3bba0 100644
--- a/gcc/ipa-fnsummary.c
+++ b/gcc/ipa-fnsummary.c
@@ -4346,6 +4346,7 @@ ipa_fn_summary_read (void)
struct lto_file_decl_data *file_data;
unsigned int j = 0;
+ ipa_prop_read_jump_functions ();
ipa_fn_summary_alloc ();
while ((file_data = file_data_vec[j++]))
@@ -4364,8 +4365,6 @@ ipa_fn_summary_read (void)
"ipa inline summary is missing in input file");
}
ipa_register_cgraph_hooks ();
- if (!flag_ipa_cp)
- ipa_prop_read_jump_functions ();
gcc_assert (ipa_fn_summaries);
ipa_fn_summaries->enable_insertion_hook ();
@@ -4500,8 +4499,7 @@ ipa_fn_summary_write (void)
produce_asm (ob, NULL);
destroy_output_block (ob);
- if (!flag_ipa_cp)
- ipa_prop_write_jump_functions ();
+ ipa_prop_write_jump_functions ();
}
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 5e3216da631..70a554c4447 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -777,7 +777,7 @@ lhd_begin_section (const char *name)
saved_section = text_section;
/* Create a new section and switch to it. */
- section = get_section (name, SECTION_DEBUG | SECTION_EXCLUDE, NULL);
+ section = get_section (name, SECTION_DEBUG | SECTION_EXCLUDE, NULL, true);
switch_to_section (section);
}
diff --git a/gcc/output.h b/gcc/output.h
index eb253c50329..2f2f1697fd8 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -523,7 +523,8 @@ extern GTY(()) bool in_cold_section_p;
extern section *get_unnamed_section (unsigned int, void (*) (const void *),
const void *);
-extern section *get_section (const char *, unsigned int, tree);
+extern section *get_section (const char *, unsigned int, tree,
+ bool not_existing = false);
extern section *get_named_section (tree, const char *, int);
extern section *get_variable_section (tree, bool);
extern void place_block_symbol (rtx);
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 5bf4e96a773..0e7531926f8 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -276,10 +276,12 @@ get_noswitch_section (unsigned int flags, noswitch_section_callback callback)
}
/* Return the named section structure associated with NAME. Create
- a new section with the given fields if no such structure exists. */
+ a new section with the given fields if no such structure exists.
+ When NOT_EXISTING, then fail if the section already exists. */
section *
-get_section (const char *name, unsigned int flags, tree decl)
+get_section (const char *name, unsigned int flags, tree decl,
+ bool not_existing)
{
section *sect, **slot;
@@ -296,6 +298,9 @@ get_section (const char *name, unsigned int flags, tree decl)
}
else
{
+ if (not_existing)
+ internal_error ("Section already exists: %qs", name);
+
sect = *slot;
/* It is fine if one of the sections has SECTION_NOTYPE as long as
the other has none of the contrary flags (see the logic at the end
--
2.29.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: GCC 10 backports
2020-10-16 8:51 ` Martin Liška
` (2 preceding siblings ...)
2020-10-29 18:21 ` [PATCH] LTO: get_section: add new argument Martin Liška
@ 2020-12-09 20:17 ` Martin Liška
2021-03-03 8:57 ` Martin Liška
3 siblings, 1 reply; 10+ messages in thread
From: Martin Liška @ 2020-12-09 20:17 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 333 bytes --]
On 10/16/20 10:51 AM, Martin Liška wrote:
> On 10/7/20 2:03 PM, Martin Liška wrote:
>> On 10/1/20 9:18 PM, Martin Liška wrote:
>>> I'm going to install the following 3 tested backports.
>>>
>>> Martin
>>
>> One more patch that I've tested.
>>
>> Martin
>
> Adding one more.
>
> Martin
Adding one more I've just tested.
Martin
[-- Attachment #2: 0001-options-Make-help-see-overridden-values.patch --]
[-- Type: text/x-patch, Size: 1401 bytes --]
From 5b51c5135f9c6adce273697a7a892df39d7f4b29 Mon Sep 17 00:00:00 2001
From: Kewen Lin <linkw@linux.ibm.com>
Date: Tue, 18 Aug 2020 21:37:39 -0500
Subject: [PATCH] options: Make --help= see overridden values
Options "-Q --help=params" don't show the final values after
target option overriding, instead it emits the default values
in params.opt (without any explicit param settings).
This patch makes it see overridden values.
gcc/ChangeLog:
* opts-global.c (decode_options): Call target_option_override_hook
before it prints for --help=*.
(cherry picked from commit a7bbb5b1b1eb09db8175130474e8da952f30404b)
---
gcc/opts-global.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/gcc/opts-global.c b/gcc/opts-global.c
index c658805470e..5e5c3d41dd9 100644
--- a/gcc/opts-global.c
+++ b/gcc/opts-global.c
@@ -327,8 +327,14 @@ decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
unsigned i;
const char *arg;
- FOR_EACH_VEC_ELT (help_option_arguments, i, arg)
- print_help (opts, lang_mask, arg);
+ if (!help_option_arguments.is_empty ())
+ {
+ /* Make sure --help=* sees the overridden values. */
+ target_option_override_hook ();
+
+ FOR_EACH_VEC_ELT (help_option_arguments, i, arg)
+ print_help (opts, lang_mask, arg);
+ }
}
/* Hold command-line options associated with stack limitation. */
--
2.29.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: GCC 10 backports
2020-12-09 20:17 ` GCC 10 backports Martin Liška
@ 2021-03-03 8:57 ` Martin Liška
0 siblings, 0 replies; 10+ messages in thread
From: Martin Liška @ 2021-03-03 8:57 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 44 bytes --]
One more backport I've just tested.
Martin
[-- Attachment #2: 0001-debug-fix-switch-lowering-debug-info.patch --]
[-- Type: text/x-patch, Size: 4220 bytes --]
From 1740f6453356fec7926e360b3a379ca0fa80a1da Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Fri, 5 Feb 2021 10:36:38 +0100
Subject: [PATCH] debug: fix switch lowering debug info
gcc/ChangeLog:
PR debug/98656
* tree-switch-conversion.c (jump_table_cluster::emit): Add loc
argument.
(bit_test_cluster::emit): Reuse location_t for newly created
gswitch statement.
(switch_decision_tree::try_switch_expansion): Preserve
location_t.
* tree-switch-conversion.h: Change function signatures.
(cherry picked from commit 4ede02a5f2af1205434f0e05aaaeff762b24e329)
---
gcc/tree-switch-conversion.c | 11 +++++++----
gcc/tree-switch-conversion.h | 8 ++++----
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 8da1be1cd99..2bc098d0172 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1115,7 +1115,8 @@ group_cluster::dump (FILE *f, bool details)
void
jump_table_cluster::emit (tree index_expr, tree,
- tree default_label_expr, basic_block default_bb)
+ tree default_label_expr, basic_block default_bb,
+ location_t loc)
{
unsigned HOST_WIDE_INT range = get_range (get_low (), get_high ());
unsigned HOST_WIDE_INT nondefault_range = 0;
@@ -1134,6 +1135,7 @@ jump_table_cluster::emit (tree index_expr, tree,
gswitch *s = gimple_build_switch (index_expr,
unshare_expr (default_label_expr), labels);
+ gimple_set_location (s, loc);
gimple_stmt_iterator gsi = gsi_start_bb (m_case_bb);
gsi_insert_after (&gsi, s, GSI_NEW_STMT);
@@ -1491,7 +1493,7 @@ case_bit_test::cmp (const void *p1, const void *p2)
void
bit_test_cluster::emit (tree index_expr, tree index_type,
- tree, basic_block default_bb)
+ tree, basic_block default_bb, location_t)
{
case_bit_test test[m_max_case_bit_tests] = { {} };
unsigned int i, j, k;
@@ -1858,7 +1860,8 @@ switch_decision_tree::try_switch_expansion (vec<cluster *> &clusters)
{
cluster *c = clusters[0];
c->emit (index_expr, index_type,
- gimple_switch_default_label (m_switch), m_default_bb);
+ gimple_switch_default_label (m_switch), m_default_bb,
+ gimple_location (m_switch));
redirect_edge_succ (single_succ_edge (bb), c->m_case_bb);
}
else
@@ -1870,7 +1873,7 @@ switch_decision_tree::try_switch_expansion (vec<cluster *> &clusters)
if (clusters[i]->get_type () != SIMPLE_CASE)
clusters[i]->emit (index_expr, index_type,
gimple_switch_default_label (m_switch),
- m_default_bb);
+ m_default_bb, gimple_location (m_switch));
}
fix_phi_operands_for_edges ();
diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h
index dbfd9eecba2..1ff50fafaa3 100644
--- a/gcc/tree-switch-conversion.h
+++ b/gcc/tree-switch-conversion.h
@@ -71,7 +71,7 @@ public:
virtual void dump (FILE *f, bool details = false) = 0;
/* Emit GIMPLE code to handle the cluster. */
- virtual void emit (tree, tree, tree, basic_block) = 0;
+ virtual void emit (tree, tree, tree, basic_block, location_t) = 0;
/* Return true if a cluster handles only a single case value and the
value is not a range. */
@@ -164,7 +164,7 @@ public:
fprintf (f, " ");
}
- void emit (tree, tree, tree, basic_block)
+ void emit (tree, tree, tree, basic_block, location_t)
{
gcc_unreachable ();
}
@@ -250,7 +250,7 @@ public:
}
void emit (tree index_expr, tree index_type,
- tree default_label_expr, basic_block default_bb);
+ tree default_label_expr, basic_block default_bb, location_t loc);
/* Find jump tables of given CLUSTERS, where all members of the vector
are of type simple_cluster. New clusters are returned. */
@@ -368,7 +368,7 @@ public:
There *MUST* be max_case_bit_tests or less unique case
node targets. */
void emit (tree index_expr, tree index_type,
- tree default_label_expr, basic_block default_bb);
+ tree default_label_expr, basic_block default_bb, location_t loc);
/* Find bit tests of given CLUSTERS, where all members of the vector
are of type simple_cluster. New clusters are returned. */
--
2.30.1
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-03-03 8:57 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01 19:18 GCC 10 backports Martin Liška
2020-10-02 11:15 ` Martin Liška
2020-10-07 12:03 ` Martin Liška
2020-10-15 8:43 ` Martin Liška
2020-10-16 8:51 ` Martin Liška
2020-10-21 9:20 ` [PATCH 1/2] ASAN: Support detect_invalid_pointer_pairs=1 with detect_stack_use_after_return=1 Martin Liška
2020-10-21 9:21 ` [PATCH 2/2] libsanitizer: add test-case Martin Liška
2020-10-29 18:21 ` [PATCH] LTO: get_section: add new argument Martin Liška
2020-12-09 20:17 ` GCC 10 backports Martin Liška
2021-03-03 8:57 ` Martin Liška
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).