]> granicus.if.org Git - llvm/commitdiff
LowerTypeTests: Compute SizeM1BitWidth in exportTypeId. NFCI.
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 20 Jan 2017 20:57:40 +0000 (20:57 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 20 Jan 2017 20:57:40 +0000 (20:57 +0000)
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

index 4f313ab429f9aa863f0af34bd51ec5576c363e2e..1e55d9fab80d9279dec18d15afef9d235fb6476c 100644 (file)
@@ -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<ConstantInt>(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;