diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-03-06 12:30:16 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-06 12:30:16 -0800 |
commit | 9b16e851b2639b9250bd00f81c1979375fc9455a (patch) | |
tree | 9693210990b062ea0eb4c1835e1480d8aefc9bf0 | |
parent | 079b348773eb03f2b471467e5280ed387d802002 (diff) |
assert on no variable name collisions for #923
-rw-r--r-- | src/analyzer.js | 6 | ||||
-rw-r--r-- | tests/cases/emptystruct.ll | 2 | ||||
-rw-r--r-- | tests/cases/gepoverflow.ll | 2 | ||||
-rw-r--r-- | tests/cases/storestruct.ll | 8 |
4 files changed, 10 insertions, 8 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index dbbb267d..209e3140 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -290,7 +290,7 @@ function analyzer(data, sidePass) { var elements = getLegalParams([item.value], bits)[0]; var j = 0; elements.forEach(function(element) { - var tempVar = '$st$' + i + '$' + j; + var tempVar = '$st$' + (tempId++) + '$' + j; toAdd.push({ intertype: 'getelementptr', assignTo: tempVar, @@ -401,7 +401,7 @@ function analyzer(data, sidePass) { var j = 0; var toAdd = []; elements.forEach(function(element) { - var tempVar = '$st$' + i + '$' + j; + var tempVar = '$ld$' + (tempId++) + '$' + j; toAdd.push({ intertype: 'getelementptr', assignTo: tempVar, @@ -952,6 +952,7 @@ function analyzer(data, sidePass) { // Function parameters func.params.forEach(function(param) { if (param.intertype !== 'varargs') { + if (func.variables[param.ident]) warn('cannot have duplicate variable names: ' + param.ident); // toNiceIdent collisions? func.variables[param.ident] = { ident: param.ident, type: param.type, @@ -965,6 +966,7 @@ function analyzer(data, sidePass) { // Normal variables func.lines.forEach(function(item, i) { if (item.assignTo) { + if (func.variables[item.assignTo]) warn('cannot have duplicate variable names: ' + item.assignTo); // toNiceIdent collisions? var variable = func.variables[item.assignTo] = { ident: item.assignTo, type: item.type, diff --git a/tests/cases/emptystruct.ll b/tests/cases/emptystruct.ll index d4165fdd..67967e65 100644 --- a/tests/cases/emptystruct.ll +++ b/tests/cases/emptystruct.ll @@ -11,7 +11,7 @@ entry: %z = alloca %struct.s, align 4 %0 = bitcast %struct.s* %z to i8* call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 4, i32 4, i1 false) - %0 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0] + %1 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0] ret i32 0 } diff --git a/tests/cases/gepoverflow.ll b/tests/cases/gepoverflow.ll index 315e9100..d09afd87 100644 --- a/tests/cases/gepoverflow.ll +++ b/tests/cases/gepoverflow.ll @@ -26,7 +26,7 @@ entry: %3 = sub i32 %1, %baseint ; [#uses=1] %4 = sub i32 %2, %baseint ; [#uses=1] %5 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i32 %1, i32 %2) ; [#uses=0] - %5 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i32 %3, i32 %4) ; [#uses=0] + %6 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i32 %3, i32 %4) ; [#uses=0] br label %return return: ; preds = %entry diff --git a/tests/cases/storestruct.ll b/tests/cases/storestruct.ll index 15022e2f..5bd9224e 100644 --- a/tests/cases/storestruct.ll +++ b/tests/cases/storestruct.ll @@ -42,14 +42,14 @@ entry: %tmp5 = load i32* %a1, align 4, !dbg !18 ; [#uses=1] %tmp6 = load i32* %b2, align 4, !dbg !18 ; [#uses=1] - %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i32 %tmp5, i32 %tmp6), !dbg !18 ; [#uses=0] + %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i32 %tmp5, i32 %tmp6), !dbg !18 ; [#uses=0] %ptr = inttoptr i32 52 to i32* ; [#uses=1] store %struct.X { i32 ptrtoint (i32* getelementptr inbounds (i32* %ptr, i32 1, i32 0) to i32), i32 3 }, %struct.X* %y, align 4 ; store entire struct at once - %tmp5 = load i32* %a1, align 4, !dbg !18 ; [#uses=1] - %tmp6 = load i32* %b2, align 4, !dbg !18 ; [#uses=1] - %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i32 %tmp5, i32 %tmp6), !dbg !18 ; [#uses=0] + %tmp5b = load i32* %a1, align 4, !dbg !18 ; [#uses=1] + %tmp6b = load i32* %b2, align 4, !dbg !18 ; [#uses=1] + %call3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i32 %tmp5b, i32 %tmp6b), !dbg !18 ; [#uses=0] ret i32 0, !dbg !19 } |