Use more portable integer log from LLVM.

This commit is contained in:
David Nadlinger
2012-12-24 02:04:18 +01:00
parent 8094e3c21b
commit a0971b7c4b

View File

@@ -46,6 +46,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtra.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -179,7 +180,7 @@ namespace {
if (SizeLimit > 0)
{
uint64_t ElemSize = A.TD.getTypeAllocSize(Ty);
unsigned BitsLimit = static_cast<unsigned>(log2(SizeLimit / ElemSize));
unsigned BitsLimit = Log2_64(SizeLimit / ElemSize));
// LLVM's alloca ueses an i32 for the number of elements.
BitsLimit = std::min(BitsLimit, 32U);