diff options
| author | Teresa Johnson <tejohnson@google.com> | 2017-05-23 00:08:00 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2017-05-23 00:08:00 +0000 |
| commit | 2db1369c1f007559a350356cf49a143afc6f3c5c (patch) | |
| tree | f0ee91092bd6dd0fb0426dd05fc682b2be8879d1 /llvm/test | |
| parent | 0c7d4d7e2142d83a0dc939dba6939a6bff0715b9 (diff) | |
| download | bcm5719-llvm-2db1369c1f007559a350356cf49a143afc6f3c5c.tar.gz bcm5719-llvm-2db1369c1f007559a350356cf49a143afc6f3c5c.zip | |
Support for taking the max of module flags when linking, use for PIE/PIC
Summary:
Add Max ModFlagBehavior, which can be used to take the max of two
module flag values when merging modules. Use it for the PIE and PIC
levels.
This avoids an error when we try to import from a module built -fpic
into a module built -fPIC, for example. For both PIE and PIC levels,
this will be legal, since the code generation gets more conservative
as the level is increased. Therefore we can take the max instead of
somehow trying to block importing between modules compiled with
different levels.
Reviewers: tmsriram, pcc
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D33418
llvm-svn: 303590
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Linker/Inputs/module-flags-pic-2-b.ll | 5 | ||||
| -rw-r--r-- | llvm/test/Linker/module-flags-pic-2-a.ll | 13 | ||||
| -rw-r--r-- | llvm/test/Verifier/module-flags-1.ll | 6 |
3 files changed, 15 insertions, 9 deletions
diff --git a/llvm/test/Linker/Inputs/module-flags-pic-2-b.ll b/llvm/test/Linker/Inputs/module-flags-pic-2-b.ll index 0d78cafc6a0..f652eddb384 100644 --- a/llvm/test/Linker/Inputs/module-flags-pic-2-b.ll +++ b/llvm/test/Linker/Inputs/module-flags-pic-2-b.ll @@ -1,3 +1,4 @@ -!0 = !{ i32 1, !"PIC Level", i32 2 } +!0 = !{ i32 7, !"PIC Level", i32 2 } +!1 = !{ i32 7, !"PIE Level", i32 2 } -!llvm.module.flags = !{!0} +!llvm.module.flags = !{!0, !1} diff --git a/llvm/test/Linker/module-flags-pic-2-a.ll b/llvm/test/Linker/module-flags-pic-2-a.ll index e09af6bcd12..8898d72d510 100644 --- a/llvm/test/Linker/module-flags-pic-2-a.ll +++ b/llvm/test/Linker/module-flags-pic-2-a.ll @@ -1,10 +1,11 @@ -; RUN: not llvm-link %s %p/Inputs/module-flags-pic-2-b.ll -S -o - 2> %t -; RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s +; RUN: llvm-link %s %p/Inputs/module-flags-pic-2-b.ll -S -o - | FileCheck %s -; test linking modules with two different PIC levels +; test linking modules with two different PIC and PIE levels -!0 = !{ i32 1, !"PIC Level", i32 1 } +!0 = !{ i32 7, !"PIC Level", i32 1 } +!1 = !{ i32 7, !"PIE Level", i32 1 } -!llvm.module.flags = !{!0} +!llvm.module.flags = !{!0, !1} -; CHECK-ERRORS: ERROR: linking module flags 'PIC Level': IDs have conflicting values +; CHECK: !0 = !{i32 7, !"PIC Level", i32 2} +; CHECK: !1 = !{i32 7, !"PIE Level", i32 2} diff --git a/llvm/test/Verifier/module-flags-1.ll b/llvm/test/Verifier/module-flags-1.ll index 36bcb335ffc..ff82c284523 100644 --- a/llvm/test/Verifier/module-flags-1.ll +++ b/llvm/test/Verifier/module-flags-1.ll @@ -41,6 +41,10 @@ ; CHECK-NOT: invalid value for 'append'-type module flag (expected a metadata node) !18 = !{i32 5, !"flag-4", !{i32 57}} +; Check that any 'max' module flags are valid. +; CHECK: invalid value for 'max' module flag (expected constant integer) +!19 = !{i32 7, !"max", !"max"} + ; Check that any 'require' module flags are valid. ; CHECK: invalid requirement on flag, flag is not present in module !11 = !{i32 3, !"bar", !{!"no-such-flag", i32 52}} @@ -54,4 +58,4 @@ !llvm.module.flags = !{ !0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, - !16, !17, !18 } + !16, !17, !18, !19 } |

