aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCExpr.cpp
diff options
context:
space:
mode:
authorJinyang He <hejinyang@loongson.cn>2024-01-09 15:21:41 +0800
committerGitHub <noreply@github.com>2024-01-09 15:21:41 +0800
commit7b45c549670a8e8b6fe90f4382b0699dd20707d3 (patch)
tree86c7fabd1176b99e60d210b474be36a19f923fcc /llvm/lib/MC/MCExpr.cpp
parentb57159cb19cdc06ec5733f93f0975aa6f40595cb (diff)
downloadllvm-7b45c549670a8e8b6fe90f4382b0699dd20707d3.zip
llvm-7b45c549670a8e8b6fe90f4382b0699dd20707d3.tar.gz
llvm-7b45c549670a8e8b6fe90f4382b0699dd20707d3.tar.bz2
[MC][RISCV] Check hasEmitNops before call shouldInsertExtraNopBytesForCodeAlign (#77236)
The shouldInsertExtraNopBytesForCodeAlign() need STI to check whether relax is enabled or not. It is initialized when call setEmitNops. The setEmitNops may not be called in a section which has instructions but is not executable. In this case uninitialized STI will cause problems. Thus, check hasEmitNops before call it. Fixes: https://github.com/llvm/llvm-project/pull/76552#issuecomment-1878952480
Diffstat (limited to 'llvm/lib/MC/MCExpr.cpp')
-rw-r--r--llvm/lib/MC/MCExpr.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index 9dae026..80def6dfc 100644
--- a/llvm/lib/MC/MCExpr.cpp
+++ b/llvm/lib/MC/MCExpr.cpp
@@ -708,7 +708,7 @@ static void AttemptToFoldSymbolOffsetDifference(
if (DF) {
Displacement += DF->getContents().size();
} else if (auto *AF = dyn_cast<MCAlignFragment>(FI);
- AF && Layout &&
+ AF && Layout && AF->hasEmitNops() &&
!Asm->getBackend().shouldInsertExtraNopBytesForCodeAlign(
*AF, Count)) {
Displacement += Asm->computeFragmentSize(*Layout, *AF);