[llvm-commits] [llvm] r152390 - in /llvm/trunk/lib/Target/Mips: MipsAnalyzeImmediate.cpp MipsAnalyzeImmediate.h
Ahmed Charles
ace2001ac at gmail.com
Thu Mar 8 22:36:46 PST 2012
Author: ace2001ac
Date: Fri Mar 9 00:36:45 2012
New Revision: 152390
URL: http://llvm.org/viewvc/llvm-project?rev=152390&view=rev
Log:
Fix undefined behavior in the Mips backend.
Modified:
llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp
llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.h
Modified: llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp?rev=152390&r1=152389&r2=152390&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp Fri Mar 9 00:36:45 2012
@@ -26,28 +26,28 @@
Iter->push_back(I);
}
-void MipsAnalyzeImmediate::GetInstSeqLsADDiu(int64_t Imm, unsigned RemSize,
+void MipsAnalyzeImmediate::GetInstSeqLsADDiu(uint64_t Imm, unsigned RemSize,
InstSeqLs &SeqLs) {
- GetInstSeqLs((Imm + 0x8000) & ~0xffff, RemSize, SeqLs);
- AddInstr(SeqLs, Inst(ADDiu, Imm & 0xffff));
+ GetInstSeqLs((Imm + 0x8000ULL) & 0xffffffffffff0000ULL, RemSize, SeqLs);
+ AddInstr(SeqLs, Inst(ADDiu, Imm & 0xffffULL));
}
-void MipsAnalyzeImmediate::GetInstSeqLsORi(int64_t Imm, unsigned RemSize,
+void MipsAnalyzeImmediate::GetInstSeqLsORi(uint64_t Imm, unsigned RemSize,
InstSeqLs &SeqLs) {
- GetInstSeqLs(Imm & ~0xffff, RemSize, SeqLs);
- AddInstr(SeqLs, Inst(ORi, Imm & 0xffff));
+ GetInstSeqLs(Imm & 0xffffffffffff0000ULL, RemSize, SeqLs);
+ AddInstr(SeqLs, Inst(ORi, Imm & 0xffffULL));
}
-void MipsAnalyzeImmediate::GetInstSeqLsSLL(int64_t Imm, unsigned RemSize,
+void MipsAnalyzeImmediate::GetInstSeqLsSLL(uint64_t Imm, unsigned RemSize,
InstSeqLs &SeqLs) {
unsigned Shamt = CountTrailingZeros_64(Imm);
GetInstSeqLs(Imm >> Shamt, RemSize - Shamt, SeqLs);
AddInstr(SeqLs, Inst(SLL, Shamt));
}
-void MipsAnalyzeImmediate::GetInstSeqLs(int64_t Imm, unsigned RemSize,
+void MipsAnalyzeImmediate::GetInstSeqLs(uint64_t Imm, unsigned RemSize,
InstSeqLs &SeqLs) {
- int64_t MaskedImm = Imm & (((uint64_t)-1) >> (64 - Size));
+ uint64_t MaskedImm = Imm & (0xffffffffffffffffULL >> (64 - Size));
// Do nothing if Imm is 0.
if (!MaskedImm)
@@ -122,7 +122,7 @@
}
const MipsAnalyzeImmediate::InstSeq
-&MipsAnalyzeImmediate::Analyze(int64_t Imm, unsigned Size,
+&MipsAnalyzeImmediate::Analyze(uint64_t Imm, unsigned Size,
bool LastInstrIsADDiu) {
this->Size = Size;
Modified: llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.h?rev=152390&r1=152389&r2=152390&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.h Fri Mar 9 00:36:45 2012
@@ -25,7 +25,7 @@
/// Analyze - Get an instrucion sequence to load immediate Imm. The last
/// instruction in the sequence must be an ADDiu if LastInstrIsADDiu is
/// true;
- const InstSeq &Analyze(int64_t Imm, unsigned Size, bool LastInstrIsADDiu);
+ const InstSeq &Analyze(uint64_t Imm, unsigned Size, bool LastInstrIsADDiu);
private:
typedef SmallVector<InstSeq, 5> InstSeqLs;
@@ -34,18 +34,18 @@
/// GetInstSeqLsADDiu - Get instrucion sequences which end with an ADDiu to
/// load immediate Imm
- void GetInstSeqLsADDiu(int64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
+ void GetInstSeqLsADDiu(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
/// GetInstSeqLsORi - Get instrucion sequences which end with an ORi to
/// load immediate Imm
- void GetInstSeqLsORi(int64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
+ void GetInstSeqLsORi(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
/// GetInstSeqLsSLL - Get instrucion sequences which end with a SLL to
/// load immediate Imm
- void GetInstSeqLsSLL(int64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
+ void GetInstSeqLsSLL(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
/// GetInstSeqLs - Get instrucion sequences to load immediate Imm.
- void GetInstSeqLs(int64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
+ void GetInstSeqLs(uint64_t Imm, unsigned RemSize, InstSeqLs &SeqLs);
/// ReplaceADDiuSLLWithLUi - Replace an ADDiu & SLL pair with a LUi.
void ReplaceADDiuSLLWithLUi(InstSeq &Seq);
More information about the llvm-commits
mailing list