Commit 493672e
committed
Do not call LLVMSetAlignment with 0 alignment.
A recent version of LLVM removed implicit alignments from alloca, load, and store. This means that an "align n" must be present on those instructions, although one will be automatically generated by LLVMBuildAlloca and similar instructions. As part of this, LLVM changed the behavior of LLVMSetAlignment to wrap the alignment in an Align rather than a MaybeAlign. As a result, when an alignment 0 is explicitly set, LLVM assumes it is greater than 0 and takes the log2 of it. The shortcut algorithm for log2 (e.g. 31 - leading zero bit count) results in an overflow when the alignment is 0. This causes the module verifier to fail.
Solution: Let the default alignment be calculated and don't explicitly set it when no explicit alignment is specified.1 parent b616249 commit 493672e
File tree
2 files changed
+13
-5
lines changed- Sources/LLVM
- Tests/LLVMTests
2 files changed
+13
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1057 | 1057 | | |
1058 | 1058 | | |
1059 | 1059 | | |
1060 | | - | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1061 | 1063 | | |
1062 | 1064 | | |
1063 | 1065 | | |
| |||
1077 | 1079 | | |
1078 | 1080 | | |
1079 | 1081 | | |
1080 | | - | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
1081 | 1085 | | |
1082 | 1086 | | |
1083 | 1087 | | |
| |||
1098 | 1102 | | |
1099 | 1103 | | |
1100 | 1104 | | |
1101 | | - | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1102 | 1108 | | |
1103 | 1109 | | |
1104 | 1110 | | |
| |||
1941 | 1947 | | |
1942 | 1948 | | |
1943 | 1949 | | |
1944 | | - | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
1945 | 1953 | | |
1946 | 1954 | | |
1947 | 1955 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| |||
0 commit comments