diff options
author | Jian Cai <caij2003@gmail.com> | 2020-03-12 18:09:19 -0700 |
---|---|---|
committer | Jian Cai <caij2003@gmail.com> | 2020-03-17 14:48:05 -0700 |
commit | 6a38e0e4f518d06543bb25ad4ea6116a5f1f38cc (patch) | |
tree | 383fee2e033781658d1227d90f7e62804f07e283 /llvm/lib/MC/MCAssembler.cpp | |
parent | 7aa28995e87f6cec2e02608c978885cf01dcc65d (diff) | |
download | llvm-6a38e0e4f518d06543bb25ad4ea6116a5f1f38cc.zip llvm-6a38e0e4f518d06543bb25ad4ea6116a5f1f38cc.tar.gz llvm-6a38e0e4f518d06543bb25ad4ea6116a5f1f38cc.tar.bz2 |
[MC] Recalculate fragment offsets after relaxation
Summary:
The current relaxation implementation is not correctly adjusting the
size and offsets of fragements in one section based on changes in size
of another if the layout order of the two happened to be such that the
former was visited before the later. Therefore, we need to invalidate
the fragments in all sections after each iteration of relaxation, and
possibly further relax some of them in the next ieration. This fixes
PR#45190.
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76114
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 83f0d62..97fb13b 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -785,9 +785,15 @@ void MCAssembler::layout(MCAsmLayout &Layout) { } // Layout until everything fits. - while (layoutOnce(Layout)) + while (layoutOnce(Layout)) { if (getContext().hadError()) return; + // Size of fragments in one section can depend on the size of fragments in + // another. If any fragment has changed size, we have to re-layout (and + // as a result possibly further relax) all. + for (MCSection &Sec : *this) + Layout.invalidateFragmentsFrom(&*Sec.begin()); + } DEBUG_WITH_TYPE("mc-dump", { errs() << "assembler backend - post-relaxation\n--\n"; |