[PATCH] D148218: [BOLT][NFC] Fix UB due to left shift of negative value
Job Noorman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 13 05:21:42 PDT 2023
jobnoorman created this revision.
jobnoorman added reviewers: rafauler, maksfb, yota9, Amir.
Herald added subscribers: asb, treapster, pmatos, ayermolo, kristof.beyls.
Herald added a project: All.
jobnoorman requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The following test fails when enabling UBSan due to a left shift of a
negative value:
> runtime error: left shift of negative value -2
BOLT :: AArch64/ext-island-ref.s
This patch fixes this by using a multiplication instead of a shift.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148218
Files:
bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
Index: bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
===================================================================
--- bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
+++ bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
@@ -265,7 +265,7 @@
return true;
}
- DispImm = Inst.getOperand(I).getImm() << 2;
+ DispImm = Inst.getOperand(I).getImm() * 4;
return true;
}
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148218.513183.patch
Type: text/x-patch
Size: 430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230413/3f5da553/attachment.bin>
More information about the llvm-commits
mailing list