about summary refs log tree commit diff homepage
path: root/lib/Module/KModule.cpp
diff options
context:
space:
mode:
authorJulian Büning <julian.buening@rwth-aachen.de>2019-07-17 22:42:12 +0200
committerMartinNowack <martin.nowack@gmail.com>2019-10-31 15:35:05 +0000
commite32ae5ae50165593b82cffb6e946532618000933 (patch)
treeb7ad0b2122e21c92a73ea68aeaab51a3937e2a88 /lib/Module/KModule.cpp
parent2b78a26d9dbeb7823c5a3487bfa2535fb4b274bf (diff)
downloadklee-e32ae5ae50165593b82cffb6e946532618000933.tar.gz
support compilation against LLVM 9.0
Diffstat (limited to 'lib/Module/KModule.cpp')
-rw-r--r--lib/Module/KModule.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index 315942b5..cec0ea6f 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -140,10 +140,15 @@ static Function *getStubFunctionForCtorList(Module *m,
   if (arr) {
     for (unsigned i=0; i<arr->getNumOperands(); i++) {
       auto cs = cast<ConstantStruct>(arr->getOperand(i));
-      // There is a third *optional* element in global_ctor elements (``i8
-      // @data``).
+      // There is a third element in global_ctor elements (``i8 @data``).
+#if LLVM_VERSION_CODE >= LLVM_VERSION(9, 0)
+      assert(cs->getNumOperands() == 3 &&
+             "unexpected element in ctor initializer list");
+#else
+      // before LLVM 9.0, the third operand was optional
       assert((cs->getNumOperands() == 2 || cs->getNumOperands() == 3) &&
              "unexpected element in ctor initializer list");
+#endif
       auto fp = cs->getOperand(1);
       if (!fp->isNullValue()) {
         if (auto ce = dyn_cast<llvm::ConstantExpr>(fp))