[PATCH] D19687: Set PIELevel module flag

Sriraman Tallam via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 28 14:41:50 PDT 2016


tmsriram updated this revision to Diff 55493.
tmsriram added a comment.

Simplify code setting PICLevel and PIELevel module flags.


http://reviews.llvm.org/D19687

Files:
  lib/CodeGen/CodeGenModule.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -477,15 +477,13 @@
   }
 
   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");
-    }
+    assert (PLevel < 3 && "Invalid PIC Level");
+    getModule().setPICLevel(static_cast<llvm::PICLevel::Level>(PLevel));
+  }
 
-    getModule().setPICLevel(PL);
+  if (uint32_t PLevel = Context.getLangOpts().PIELevel) {
+    assert (PLevel < 3 && "Invalid PIE Level");
+    getModule().setPIELevel(static_cast<llvm::PIELevel::Level>(PLevel));
   }
 
   SimplifyPersonality();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19687.55493.patch
Type: text/x-patch
Size: 896 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160428/b7d465c6/attachment.bin>


More information about the cfe-commits mailing list