Index: include/llvm/IR/Module.h =================================================================== --- include/llvm/IR/Module.h +++ include/llvm/IR/Module.h @@ -617,19 +617,19 @@ return global_objects().end(); } - typedef concat_iterator global_value_iterator; - typedef concat_iterator const_global_value_iterator; iterator_range global_values() { - return concat(functions(), globals(), aliases(), ifuncs()); + return concat(globals(), functions(), aliases(), ifuncs()); } iterator_range global_values() const { - return concat(functions(), globals(), aliases(), + return concat(globals(), functions(), aliases(), ifuncs()); } Index: test/LTO/Resolution/X86/globalorder.ll =================================================================== --- /dev/null +++ test/LTO/Resolution/X86/globalorder.ll @@ -0,0 +1,31 @@ +; Test the order of global variables during LTO merging. Note that +; this can change at any time, for any reason, or no reason whatsoever. +; If you are depending on this order for correctness, your code has a +; bug and should be fixed. +; +; RUN: llvm-as %s -o %t.bc +; RUN: llvm-lto2 %t.bc -O0 -save-temps -o %t.o -r %t.bc,var1,px -r %t.bc,var2,px -r %t.bc,var3,px -r %t.bc,var4,px -r %t.bc,foo,px +; RUN: llvm-dis -o - %t.o.0.0.preopt.bc | FileCheck %s +; + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; CHECK: @var1 = +@var1 = global i32 0, align 4 +; CHECK: @var2 = +@var2 = global i32 0, align 4 +; CHECK: @var3 = +@var3 = global i32* @var1, align 4 +; CHECK: @var4 = +@var4 = global i32* @var2, align 4 + +define i32 @foo() { +entry: + %0 = load i32*, i32** @var3, align 4 + %1 = load i32, i32* %0, align 4 + %2 = load i32*, i32** @var4, align 4 + %3 = load i32, i32* %2, align 4 + %add = add nsw i32 %3, %1 + ret i32 %add +} Index: test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll =================================================================== --- test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll +++ test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll @@ -19,9 +19,9 @@ ; M0: define void @f() ; M1-NOT: @f() define void @f() { - ; M0: llvm.type.test{{.*}}metadata !"1$f50b51a12bb012bebbeff978335e34cf" + ; M0: llvm.type.test{{.*}}metadata !"1$761a10bdafb4c4efc0f254ab1655930a" %p = call i1 @llvm.type.test(i8* null, metadata !0) - ; M0: llvm.type.checked.load{{.*}}metadata !"2$f50b51a12bb012bebbeff978335e34cf" + ; M0: llvm.type.checked.load{{.*}}metadata !"2$761a10bdafb4c4efc0f254ab1655930a" %q = call {i8*, i1} @llvm.type.checked.load(i8* null, i32 0, metadata !3) ret void } @@ -30,11 +30,11 @@ declare {i8*, i1} @llvm.type.checked.load(i8*, i32, metadata) !0 = distinct !{} -; M1: !0 = !{i32 0, !"1$f50b51a12bb012bebbeff978335e34cf"} +; M1: !0 = !{i32 0, !"1$761a10bdafb4c4efc0f254ab1655930a"} !1 = !{i32 0, !0} -; M1: !1 = !{i32 1, !"1$f50b51a12bb012bebbeff978335e34cf"} +; M1: !1 = !{i32 1, !"1$761a10bdafb4c4efc0f254ab1655930a"} !2 = !{i32 1, !0} !3 = distinct !{} -; M1: !2 = !{i32 0, !"2$f50b51a12bb012bebbeff978335e34cf"} +; M1: !2 = !{i32 0, !"2$761a10bdafb4c4efc0f254ab1655930a"} !4 = !{i32 0, !3}