r222227 - Add PIC-level support to Clang.
Justin Hibbits
jrh29 at alumni.cwru.edu
Mon Nov 17 22:17:20 PST 2014
Author: jhibbits
Date: Tue Nov 18 00:17:20 2014
New Revision: 222227
URL: http://llvm.org/viewvc/llvm-project?rev=222227&view=rev
Log:
Add PIC-level support to Clang.
Summary:
This distinguishes between -fpic and -fPIC now, with the additions in LLVM for
PIC level support.
Test Plan: No regressions
Reviewers: echristo, rafael
Reviewed By: rafael
Subscribers: rnk, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D5400
Added:
cfe/trunk/test/CodeGen/piclevels.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=222227&r1=222226&r2=222227&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Nov 18 00:17:20 2014
@@ -391,6 +391,18 @@ void CodeGenModule::Release() {
getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);
}
+ if (uint32_t PLevel = Context.getLangOpts().PICLevel) {
+ llvm::PICLevel::Level PL = llvm::PICLevel::Default;
+ switch (PLevel) {
+ case 0: break;
+ case 1: PL = llvm::PICLevel::Small; break;
+ case 2: PL = llvm::PICLevel::Large; break;
+ default: llvm_unreachable("Invalid PIC Level");
+ }
+
+ getModule().setPICLevel(PL);
+ }
+
SimplifyPersonality();
if (getCodeGenOpts().EmitDeclMetadata)
Added: cfe/trunk/test/CodeGen/piclevels.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/piclevels.c?rev=222227&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/piclevels.c (added)
+++ cfe/trunk/test/CodeGen/piclevels.c Tue Nov 18 00:17:20 2014
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -pic-level 2 %s -o - | FileCheck %s -check-prefix=CHECK-BIGPIC
+// RUN: %clang_cc1 -emit-llvm -pic-level 1 %s -o - | FileCheck %s -check-prefix=CHECK-SMALLPIC
+
+// CHECK-BIGPIC: !llvm.module.flags = !{{{.*}}}
+// CHECK-BIGPIC: !{{[0-9]+}} = metadata !{i32 1, metadata !"PIC Level", i32 2}
+// CHECK-SMALLPIC: !llvm.module.flags = !{{{.*}}}
+// CHECK-SMALLPIC: !{{[0-9]+}} = metadata !{i32 1, metadata !"PIC Level", i32 1}
More information about the cfe-commits
mailing list