diff options
-rw-r--r-- | src/parseTools.js | 6 | ||||
-rw-r--r-- | tests/cases/ptrtoint_blockaddr.ll | 20 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 6eb95593..94989f9d 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -309,6 +309,8 @@ function parseParamTokens(params) { } } else if (segment[1].text in PARSABLE_LLVM_FUNCTIONS) { ret.push(parseLLVMFunctionCall(segment)); + } else if (segment[1].text === 'blockaddress') { + ret.push(parseBlockAddress(segment)); } else { if (segment[2] && segment[2].text == 'to') { // part of bitcast params segment = segment.slice(0, 2); @@ -334,6 +336,8 @@ function parseParamTokens(params) { function finalizeParam(param) { if (param.intertype in PARSABLE_LLVM_FUNCTIONS) { return finalizeLLVMFunctionCall(param); + } else if (param.intertype === 'blockaddress') { + return finalizeBlockAddress(param); } else if (param.intertype === 'jsvalue') { return param.ident; } else { @@ -426,7 +430,7 @@ function parseLLVMFunctionCall(segment) { params: parseParamTokens(segment[2].item.tokens) }; Types.needAnalysis[ret.type] = 0; - ret.ident = toNiceIdent(ret.params[0].ident); + ret.ident = toNiceIdent(ret.params[0].ident || 'NOIDENT'); return ret; } diff --git a/tests/cases/ptrtoint_blockaddr.ll b/tests/cases/ptrtoint_blockaddr.ll new file mode 100644 index 00000000..11e2f7bc --- /dev/null +++ b/tests/cases/ptrtoint_blockaddr.ll @@ -0,0 +1,20 @@ +@.str = private constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1] + +define linkonce_odr i32* @main() align 2 { + %199 = trunc i8 1 to i1 ; [#uses=1] + br i1 %199, label %555, label %569 + +; <label>:555 ; preds = %353 + br label %569 + ; No predecessors! + br label %569 + +; <label>:569 ; preds = %555 + %333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0] + ; this should compile ok + store i32 ptrtoint (i8* blockaddress(@main, %569) to i32), i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), align 8 + ret i32 0 +} + +declare i32 @printf(i8*) + |