summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2015-07-21 17:18:03 +0000
committerPhilip Reames <listmail@philipreames.com>2015-07-21 17:18:03 +0000
commit94babb70303e0fa7148acef9e4647d9624995c6d (patch)
tree2edaf4406010b6a9cad24225e210b2126b5e2dde
parent36512330041201e10f5429361bbd79b1afac1ea1 (diff)
downloadbcm5719-llvm-94babb70303e0fa7148acef9e4647d9624995c6d.tar.gz
bcm5719-llvm-94babb70303e0fa7148acef9e4647d9624995c6d.zip
[RewriteStatepointsForGC] Hoist some code out of a loop
llvm-svn: 242808
-rw-r--r--llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index cdeca67fd9f..5cd4a511c97 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1164,21 +1164,22 @@ static void CreateGCRelocates(ArrayRef<llvm::Value *> LiveVariables,
ArrayRef<llvm::Value *> BasePtrs,
Instruction *StatepointToken,
IRBuilder<> Builder) {
+ if (LiveVariables.empty())
+ return;
+
+ // All gc_relocate are set to i8 addrspace(1)* type. We originally generated
+ // unique declarations for each pointer type, but this proved problematic
+ // because the intrinsic mangling code is incomplete and fragile. Since
+ // we're moving towards a single unified pointer type anyways, we can just
+ // cast everything to an i8* of the right address space. A bitcast is added
+ // later to convert gc_relocate to the actual value's type.
Module *M = StatepointToken->getModule();
+ auto AS = cast<PointerType>(LiveVariables[0]->getType())->getAddressSpace();
+ Type *Types[] = {Type::getInt8PtrTy(M->getContext(), AS)};
+ Value *GCRelocateDecl =
+ Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_relocate, Types);
for (unsigned i = 0; i < LiveVariables.size(); i++) {
- // We generate a (potentially) unique declaration for every pointer type
- // combination. This results is some blow up the function declarations in
- // the IR, but removes the need for argument bitcasts which shrinks the IR
- // greatly and makes it much more readable.
- SmallVector<Type *, 1> Types; // one per 'any' type
- // All gc_relocate are set to i8 addrspace(1)* type. This could help avoid
- // cases where the actual value's type mangling is not supported by llvm. A
- // bitcast is added later to convert gc_relocate to the actual value's type.
- Types.push_back(Type::getInt8PtrTy(M->getContext(), 1));
- Value *GCRelocateDecl = Intrinsic::getDeclaration(
- M, Intrinsic::experimental_gc_relocate, Types);
-
// Generate the gc.relocate call and save the result
Value *BaseIdx =
Builder.getInt32(LiveStart + find_index(LiveVariables, BasePtrs[i]));
OpenPOWER on IntegriCloud