[llvm] r239590 - LowerBitSets: Give names to aliases of unnamed bitset element objects.
Peter Collingbourne
peter at pcc.me.uk
Thu Jun 11 20:25:05 PDT 2015
Author: pcc
Date: Thu Jun 11 22:25:05 2015
New Revision: 239590
URL: http://llvm.org/viewvc/llvm-project?rev=239590&view=rev
Log:
LowerBitSets: Give names to aliases of unnamed bitset element objects.
It is valid for globals to be unnamed, but aliases must have a name. To avoid
creating invalid IR, we need to assign names to any aliases we create that
point to unnamed objects that have been moved into combined globals.
Added:
llvm/trunk/test/Transforms/LowerBitSets/unnamed.ll
Modified:
llvm/trunk/lib/Transforms/IPO/LowerBitSets.cpp
Modified: llvm/trunk/lib/Transforms/IPO/LowerBitSets.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerBitSets.cpp?rev=239590&r1=239589&r2=239590&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerBitSets.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerBitSets.cpp Thu Jun 11 22:25:05 2015
@@ -556,8 +556,9 @@ void LowerBitSets::buildBitSetsFromGloba
} else {
GlobalAlias *GAlias =
GlobalAlias::create(Globals[I]->getType(), Globals[I]->getLinkage(),
- "", CombinedGlobalElemPtr, M);
- GAlias->takeName(Globals[I]);
+ "data", CombinedGlobalElemPtr, M);
+ if (Globals[I]->hasName())
+ GAlias->takeName(Globals[I]);
Globals[I]->replaceAllUsesWith(GAlias);
}
Globals[I]->eraseFromParent();
Added: llvm/trunk/test/Transforms/LowerBitSets/unnamed.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerBitSets/unnamed.ll?rev=239590&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LowerBitSets/unnamed.ll (added)
+++ llvm/trunk/test/Transforms/LowerBitSets/unnamed.ll Thu Jun 11 22:25:05 2015
@@ -0,0 +1,19 @@
+; RUN: opt -S -lowerbitsets < %s | FileCheck %s
+
+target datalayout = "e-p:32:32"
+
+; CHECK: @data ={{.*}} alias
+ at 0 = constant i32 1
+ at 1 = constant [2 x i32] [i32 2, i32 3]
+
+!0 = !{!"bitset1", i32* @0, i32 0}
+!1 = !{!"bitset1", [2 x i32]* @1, i32 4}
+
+!llvm.bitsets = !{ !0, !1 }
+
+declare i1 @llvm.bitset.test(i8* %ptr, metadata %bitset) nounwind readnone
+
+define i1 @foo(i8* %p) {
+ %x = call i1 @llvm.bitset.test(i8* %p, metadata !"bitset1")
+ ret i1 %x
+}
More information about the llvm-commits
mailing list