[PATCH] D63285: [RISCV] Fix a potential issue in shouldInsertFixupForCodeAlign()
Edward Jones via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 10:28:07 PDT 2019
edward-jones created this revision.
edward-jones added reviewers: asb, lewis-revill.
Herald added subscribers: llvm-commits, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar.
Herald added a project: LLVM.
The bool result of shouldInsertExtraNopBytesForCodeAlign() is not checked but the returned nop count is unconditionally read even though it could be uninitialized.
Repository:
rL LLVM
https://reviews.llvm.org/D63285
Files:
lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
Index: lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
===================================================================
--- lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -333,11 +333,10 @@
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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63285.204575.patch
Type: text/x-patch
Size: 741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190613/974ef272/attachment.bin>
More information about the llvm-commits
mailing list