From d7767b21fb30244448df9ffcbff9a3075b2f674b Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 20 Jan 2017 20:57:40 +0000 Subject: [PATCH] LowerTypeTests: Compute SizeM1BitWidth in exportTypeId. NFCI. This avoids needing to store it in a separate field in TypeIdLowering. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292647 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/LowerTypeTests.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/Transforms/IPO/LowerTypeTests.cpp b/lib/Transforms/IPO/LowerTypeTests.cpp index 4f313ab429f..1e55d9fab80 100644 --- a/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/lib/Transforms/IPO/LowerTypeTests.cpp @@ -280,9 +280,6 @@ class LowerTypeTestsModule { /// covering members of this type identifier as a multiple of 2^AlignLog2. Constant *SizeM1; - /// ByteArray, Inline, AllOnes: range of SizeM1 expressed as a bit width. - unsigned SizeM1BitWidth; - /// ByteArray: the byte array to test the address against. Constant *TheByteArray; @@ -720,7 +717,12 @@ void LowerTypeTestsModule::exportTypeId(StringRef TypeId, TIL.TheKind == TypeTestResolution::AllOnes) { ExportGlobal("align", ConstantExpr::getIntToPtr(TIL.AlignLog2, Int8PtrTy)); ExportGlobal("size_m1", ConstantExpr::getIntToPtr(TIL.SizeM1, Int8PtrTy)); - TTRes.SizeM1BitWidth = TIL.SizeM1BitWidth; + + uint64_t BitSize = cast(TIL.SizeM1)->getZExtValue() + 1; + if (TIL.TheKind == TypeTestResolution::Inline) + TTRes.SizeM1BitWidth = (BitSize <= 32) ? 5 : 6; + else + TTRes.SizeM1BitWidth = (BitSize <= 128) ? 7 : 32; } if (TIL.TheKind == TypeTestResolution::ByteArray) { @@ -757,12 +759,10 @@ void LowerTypeTestsModule::lowerTypeTestCalls( if (BSI.isAllOnes()) { TIL.TheKind = (BSI.BitSize == 1) ? TypeTestResolution::Single : TypeTestResolution::AllOnes; - TIL.SizeM1BitWidth = (BSI.BitSize <= 128) ? 7 : 32; TIL.SizeM1 = ConstantInt::get((BSI.BitSize <= 128) ? Int8Ty : Int32Ty, BSI.BitSize - 1); } else if (BSI.BitSize <= 64) { TIL.TheKind = TypeTestResolution::Inline; - TIL.SizeM1BitWidth = (BSI.BitSize <= 32) ? 5 : 6; TIL.SizeM1 = ConstantInt::get(Int8Ty, BSI.BitSize - 1); uint64_t InlineBits = 0; for (auto Bit : BSI.Bits) @@ -774,7 +774,6 @@ void LowerTypeTestsModule::lowerTypeTestCalls( (BSI.BitSize <= 32) ? Int32Ty : Int64Ty, InlineBits); } else { TIL.TheKind = TypeTestResolution::ByteArray; - TIL.SizeM1BitWidth = (BSI.BitSize <= 128) ? 7 : 32; TIL.SizeM1 = ConstantInt::get((BSI.BitSize <= 128) ? Int8Ty : Int32Ty, BSI.BitSize - 1); ++NumByteArraysCreated; -- 2.11.0