}
break;
case 'S': { // Stack natural alignment.
- StackNaturalAlign = MaybeAlign(inBytes(getInt(Tok)));
+ uint64_t Alignment = inBytes(getInt(Tok));
+ if (Alignment != 0 && !llvm::isPowerOf2_64(Alignment))
+ report_fatal_error("Alignment is neither 0 nor a power of 2");
+ StackNaturalAlign = MaybeAlign(Alignment);
break;
}
case 'F': {
"datalayout string");
}
Tok = Tok.substr(1);
- FunctionPtrAlign = MaybeAlign(inBytes(getInt(Tok)));
+ uint64_t Alignment = inBytes(getInt(Tok));
+ if (Alignment != 0 && !llvm::isPowerOf2_64(Alignment))
+ report_fatal_error("Alignment is neither 0 nor a power of 2");
+ FunctionPtrAlign = MaybeAlign(Alignment);
break;
}
case 'P': { // Function address space.
--- /dev/null
+; Bitcode with invalid function pointer alignment.
+
+; RUN: not llvm-dis %s.bc -o - 2>&1 | FileCheck %s
+
+CHECK: LLVM ERROR: Alignment is neither 0 nor a power of 2