aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Module.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-08-18 16:28:55 -0700
committerFangrui Song <i@maskray.me>2022-08-18 16:28:55 -0700
commitc2a38887932e3a46aa3bee35f3f5568ac68282f4 (patch)
tree903747d76dd1fb4d303c7d8891893975766c0e10 /llvm/lib/IR/Module.cpp
parent37c47b2cacae99d65b4b82eb41655f0820100677 (diff)
downloadllvm-c2a38887932e3a46aa3bee35f3f5568ac68282f4.zip
llvm-c2a38887932e3a46aa3bee35f3f5568ac68282f4.tar.gz
llvm-c2a38887932e3a46aa3bee35f3f5568ac68282f4.tar.bz2
[IR] Use Min behavior for module flag "PIC Level"
Using Max for both "PIC Level" and "PIE Level" is inconsistent. PIC imposes less restriction while PIE imposes more restriction. The result generally picks the more restrictive behavior: Min for PIC. This choice matches `ld -r`: a non-pic object and a pic object merge into a result which should be treated as non-pic. To allow linking "PIC Level" using Error/Max from old bitcode files, upgrade Error/Max to Min. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D130531
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r--llvm/lib/IR/Module.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index b51ea45..5dd114c 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -596,7 +596,9 @@ PICLevel::Level Module::getPICLevel() const {
}
void Module::setPICLevel(PICLevel::Level PL) {
- addModuleFlag(ModFlagBehavior::Max, "PIC Level", PL);
+ // The merge result of a non-PIC object and a PIC object can only be reliably
+ // used as a non-PIC object, so use the Min merge behavior.
+ addModuleFlag(ModFlagBehavior::Min, "PIC Level", PL);
}
PIELevel::Level Module::getPIELevel() const {