diff options
| author | Michael Forney <mforney@mforney.org> | 2019-11-20 00:30:25 -0800 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2019-11-20 00:30:25 -0800 |
| commit | 4b4af15f94153bc9a4fc9e546715c57ab9738671 (patch) | |
| tree | 51a06672960d11d4835dd5bbb041670e19889efd | |
| parent | b72e6b1e8aab4201bd95b0f3caa1fad5bf44c1da (diff) | |
qbe: Fix usage of compound literal outside its scope
This popped up after upgrading to gcc 9.2, so is likely caused by
some new optimization.
| -rw-r--r-- | pkg/qbe/patch/0012-copy-Fix-use-of-compound-literal-outside-its-scope.patch | 55 | ||||
| -rw-r--r-- | pkg/qbe/ver | 2 |
2 files changed, 56 insertions, 1 deletions
diff --git a/pkg/qbe/patch/0012-copy-Fix-use-of-compound-literal-outside-its-scope.patch b/pkg/qbe/patch/0012-copy-Fix-use-of-compound-literal-outside-its-scope.patch new file mode 100644 index 00000000..1639f6a7 --- /dev/null +++ b/pkg/qbe/patch/0012-copy-Fix-use-of-compound-literal-outside-its-scope.patch @@ -0,0 +1,55 @@ +From 16e9c4852eb471f9a96219ab38b6bb44a8d49ac9 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Wed, 20 Nov 2019 00:01:42 -0800 +Subject: [PATCH] copy: Fix use of compound literal outside its scope + +C99 6.5.2.5p6: +> If the compound literal occurs outside the body of a function, +> the object has static storage duration; otherwise, it has automatic +> storage duration associated with the enclosing block. + +So, we can't use the address of a compound literal here. Instead, +just set p to NULL, and make the loop conditional on p being non-NULL. +--- + copy.c | 18 ++++++++++-------- + 1 file changed, 10 insertions(+), 8 deletions(-) + +diff --git a/copy.c b/copy.c +index 3aa3b98..6fb0f98 100644 +--- a/copy.c ++++ b/copy.c +@@ -77,7 +77,7 @@ phisimpl(Phi *p, Ref r, Ref *cpy, Use ***pstk, BSet *ts, BSet *as, Fn *fn) + while (nstk) { + u = stk[--nstk]; + if (u->type == UIns && iscopy(u->u.ins, r, fn)) { +- p = &(Phi){.narg = 0}; ++ p = NULL; + t = u->u.ins->to.val; + } + else if (u->type == UPhi) { +@@ -89,13 +89,15 @@ phisimpl(Phi *p, Ref r, Ref *cpy, Use ***pstk, BSet *ts, BSet *as, Fn *fn) + if (bshas(ts, t)) + continue; + bsset(ts, t); +- for (a=0; a<p->narg; a++) { +- r1 = copyof(p->arg[a], cpy); +- if (req(r1, r)) +- continue; +- if (rtype(r1) != RTmp) +- return; +- bsset(as, r1.val); ++ if (p) { ++ for (a=0; a<p->narg; a++) { ++ r1 = copyof(p->arg[a], cpy); ++ if (req(r1, r)) ++ continue; ++ if (rtype(r1) != RTmp) ++ return; ++ bsset(as, r1.val); ++ } + } + u = fn->tmp[t].use; + u1 = &u[fn->tmp[t].nuse]; +-- +2.24.0 + diff --git a/pkg/qbe/ver b/pkg/qbe/ver index d9874649..9b4b7a83 100644 --- a/pkg/qbe/ver +++ b/pkg/qbe/ver @@ -1 +1 @@ -acc3af4733 r1 +acc3af4733 r2 |
