[llvm] r214368 - UseListOrder: Don't give constant IDs to GlobalValues

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Jul 30 17:13:28 PDT 2014


Author: dexonsmith
Date: Wed Jul 30 19:13:28 2014
New Revision: 214368

URL: http://llvm.org/viewvc/llvm-project?rev=214368&view=rev
Log:
UseListOrder: Don't give constant IDs to GlobalValues

Since initializers of GlobalValues are being assigned IDs before
GlobalValues themselves, explicitly exclude GlobalValues from the
constant pool.  Added targeted test in `test/Bitcode/use-list-order.ll`
and added two more RUN lines in `test/Assembly`.

This is part of PR5680.

Modified:
    llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
    llvm/trunk/test/Assembler/ConstantExprFold.ll
    llvm/trunk/test/Assembler/ConstantExprFoldCast.ll
    llvm/trunk/test/Bitcode/use-list-order.ll

Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=214368&r1=214367&r2=214368&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Wed Jul 30 19:13:28 2014
@@ -80,12 +80,15 @@ static OrderMap orderModule(const Module
   // implicitly.
   for (const GlobalVariable &G : M->globals())
     if (G.hasInitializer())
-      orderValue(G.getInitializer(), OM);
+      if (!isa<GlobalValue>(G.getInitializer()))
+        orderValue(G.getInitializer(), OM);
   for (const GlobalAlias &A : M->aliases())
-    orderValue(A.getAliasee(), OM);
+    if (!isa<GlobalValue>(A.getAliasee()))
+      orderValue(A.getAliasee(), OM);
   for (const Function &F : *M)
     if (F.hasPrefixData())
-      orderValue(F.getPrefixData(), OM);
+      if (!isa<GlobalValue>(F.getPrefixData()))
+        orderValue(F.getPrefixData(), OM);
   OM.LastGlobalConstantID = OM.size();
 
   // Initializers of GlobalValues are processed in

Modified: llvm/trunk/test/Assembler/ConstantExprFold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/ConstantExprFold.ll?rev=214368&r1=214367&r2=214368&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/ConstantExprFold.ll (original)
+++ llvm/trunk/test/Assembler/ConstantExprFold.ll Wed Jul 30 19:13:28 2014
@@ -2,6 +2,7 @@
 ; situations
 
 ; RUN: llvm-as < %s | llvm-dis | not grep "("
+; RUN: verify-uselistorder %s -preserve-bc-use-list-order -num-shuffles=5
 
 @A = global i64 0
 

Modified: llvm/trunk/test/Assembler/ConstantExprFoldCast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/ConstantExprFoldCast.ll?rev=214368&r1=214367&r2=214368&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/ConstantExprFoldCast.ll (original)
+++ llvm/trunk/test/Assembler/ConstantExprFoldCast.ll Wed Jul 30 19:13:28 2014
@@ -1,6 +1,7 @@
 ; This test checks to make sure that constant exprs fold in some simple situations
 
 ; RUN: llvm-as < %s | llvm-dis | not grep cast
+; RUN: verify-uselistorder %s -preserve-bc-use-list-order -num-shuffles=5
 
 @A = global i32* bitcast (i8* null to i32*)  ; Cast null -> fold
 @B = global i32** bitcast (i32** @A to i32**)   ; Cast to same type -> fold

Modified: llvm/trunk/test/Bitcode/use-list-order.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/use-list-order.ll?rev=214368&r1=214367&r2=214368&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/use-list-order.ll (original)
+++ llvm/trunk/test/Bitcode/use-list-order.ll Wed Jul 30 19:13:28 2014
@@ -22,6 +22,19 @@
 @globalAndFunction = global i4 4
 @globalAndFunctionGlobalUser = global i4* @globalAndFunction
 
+; Check use-list order for constants used by globals that are themselves used
+; as aliases.  This confirms that this globals are recognized as GlobalValues
+; (not general constants).
+ at const.global = global i63 0
+ at const.global.ptr = global i63* @const.global
+ at const.global.2 = global i63 0
+
+; Same as above, but for aliases.
+ at const.target = global i62 1
+ at const.alias = alias i62* @const.target
+ at const.alias.ptr = alias i62* @const.alias
+ at const.alias.2 = alias i62* @const.target
+
 define i64 @f(i64 %f) {
 entry:
   %sum = add i64 %f, 0





More information about the llvm-commits mailing list