diff options
| author | Alex Bradbury <asb@lowrisc.org> | 2019-07-16 04:37:19 +0000 |
|---|---|---|
| committer | Alex Bradbury <asb@lowrisc.org> | 2019-07-16 04:37:19 +0000 |
| commit | e9ad0cf6cf79cfa5f8ce99db0f7161e110850011 (patch) | |
| tree | da6f65a6da00fdcd6616220dc359bb758709ba71 /llvm/lib/Target/RISCV/MCTargetDesc | |
| parent | ef8577ef98717c1c6a66293de3b2cc0f09e8c3ff (diff) | |
| download | bcm5719-llvm-e9ad0cf6cf79cfa5f8ce99db0f7161e110850011.tar.gz bcm5719-llvm-e9ad0cf6cf79cfa5f8ce99db0f7161e110850011.zip | |
[RISCV] Fix a potential issue in shouldInsertFixupForCodeAlign()
The bool result of shouldInsertExtraNopBytesForCodeAlign() is not checked but
the returned nop count is unconditionally read even though it could be
uninitialized.
Differential Revision: https://reviews.llvm.org/D63285
Patch by Edward Jones.
llvm-svn: 366175
Diffstat (limited to 'llvm/lib/Target/RISCV/MCTargetDesc')
| -rw-r--r-- | llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp index db25efb160f..821ac2033c9 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp @@ -329,11 +329,10 @@ bool RISCVAsmBackend::shouldInsertFixupForCodeAlign(MCAssembler &Asm, if (!STI.getFeatureBits()[RISCV::FeatureRelax]) return false; - // Calculate total Nops we need to insert. + // Calculate total Nops we need to insert. If there are none to insert + // then simply return. unsigned Count; - shouldInsertExtraNopBytesForCodeAlign(AF, Count); - // No Nop need to insert, simply return. - if (Count == 0) + if (!shouldInsertExtraNopBytesForCodeAlign(AF, Count) || (Count == 0)) return false; MCContext &Ctx = Asm.getContext(); |

