llvm.org GIT mirror llvm / a583990
This resolves a regression of BasicAA which failed to find any memory information for overloaded intrinsics (PR1600). This resolves that issue, and improves the matching scheme to use a BitVector rather than a binary search. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40872 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 12 years ago
3 changed file(s) with 42 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
2020 #include "llvm/ParameterAttributes.h"
2121 #include "llvm/GlobalVariable.h"
2222 #include "llvm/Instructions.h"
23 #include "llvm/Intrinsics.h"
2324 #include "llvm/Pass.h"
2425 #include "llvm/Target/TargetData.h"
2526 #include "llvm/ADT/SmallVector.h"
2627 #include "llvm/ADT/StringMap.h"
28 #include "llvm/ADT/BitVector.h"
2729 #include "llvm/Support/Compiler.h"
2830 #include "llvm/Support/GetElementPtrTypeIterator.h"
2931 #include "llvm/Support/ManagedStatic.h"
873875 static ManagedStatic > NoMemoryTable;
874876 static ManagedStatic > OnlyReadsMemoryTable;
875877
878 static ManagedStatic NoMemoryIntrinsics;
879 static ManagedStatic OnlyReadsMemoryIntrinsics;
880
876881
877882 AliasAnalysis::ModRefBehavior
878883 BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,
890895 OnlyReadsMemoryFns,
891896 OnlyReadsMemoryFns+
892897 sizeof(OnlyReadsMemoryFns)/sizeof(OnlyReadsMemoryFns[0]));
898
899 // Sort the table the first time through.
900 std::sort(NoMemoryTable->begin(), NoMemoryTable->end(), StringCompare());
901 std::sort(OnlyReadsMemoryTable->begin(), OnlyReadsMemoryTable->end(),
902 StringCompare());
903
904 NoMemoryIntrinsics->resize(Intrinsic::num_intrinsics);
905 OnlyReadsMemoryIntrinsics->resize(Intrinsic::num_intrinsics);
893906 #define GET_MODREF_BEHAVIOR
894907 #include "llvm/Intrinsics.gen"
895908 #undef GET_MODREF_BEHAVIOR
896909
897 // Sort the table the first time through.
898 std::sort(NoMemoryTable->begin(), NoMemoryTable->end(), StringCompare());
899 std::sort(OnlyReadsMemoryTable->begin(), OnlyReadsMemoryTable->end(),
900 StringCompare());
901910 Initialized = true;
911 }
912
913 // If this is an intrinsic, we can use lookup tables
914 if (unsigned id = F->getIntrinsicID()) {
915 if (NoMemoryIntrinsics->test(id))
916 return DoesNotAccessMemory;
917 if (OnlyReadsMemoryIntrinsics->test(id))
918 return OnlyReadsMemory;
919
920 return UnknownModRefBehavior;
902921 }
903922
904923 ValueName *Name = F->getValueName();
0 ; PR1600
1 ; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | \
2 ; RUN: grep {ret i32 0}
3 ; END.
4
5 declare i16 @llvm.cttz.i16(i16)
6
7 define i32 @test(i32* %P, i16* %Q) {
8 %A = load i16* %Q ; [#uses=1]
9 %x = load i32* %P ; [#uses=1]
10 %B = call i16 @llvm.cttz.i16( i16 %A ) ; [#uses=1]
11 %y = load i32* %P ; [#uses=1]
12 store i16 %B, i16* %Q
13 %z = sub i32 %x, %y ; [#uses=1]
14 ret i32 %z
15 }
16
298298 switch (Ints[i].ModRef) {
299299 default: break;
300300 case CodeGenIntrinsic::NoMem:
301 OS << " NoMemoryTable->push_back(\"" << Ints[i].Name << "\");\n";
301 OS << " NoMemoryIntrinsics->set(Intrinsic::" << Ints[i].EnumName << ");\n";
302302 break;
303303 case CodeGenIntrinsic::ReadArgMem:
304304 case CodeGenIntrinsic::ReadMem:
305 OS << " OnlyReadsMemoryTable->push_back(\"" << Ints[i].Name << "\");\n";
305 OS << " OnlyReadsMemoryIntrinsics->set(Intrinsic::" << Ints[i].EnumName << ");\n";
306306 break;
307307 }
308308 }