Skip to content

Commit

Permalink
Adjust to new format of BA report
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonievonMann committed Jun 3, 2024
1 parent b65e658 commit df60036
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 104 deletions.
196 changes: 98 additions & 98 deletions tests/data/test_ast_blame_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,125 +24,125 @@
functions:
_Z19calculate_somethingi:
annotations:
0=bitcasti32*resulttoi8*:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
1=loadi32,i32*x.addr,align4:
dbghash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
varahash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
2=loadi32,i32*result,align4:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
3=bitcasti32*resulttoi8*:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
add=addnswi321,42:
dbghash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
varahash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
[email protected](metadatai32*result,metadata!17,metadata!DIExpression()):
- inst: ' %x.addr = alloca i32, align 4'
dbghash: ''
varahash: ''
[email protected](metadatai32*x.addr,metadata!16,metadata!DIExpression()):
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' %result = alloca i32, align 4'
dbghash: ''
varahash: ''
[email protected](i644,i8*3)#5:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
[email protected](i644,i8*0)#5:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
result=allocai32,align4:
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' store i32 %x, i32* %x.addr, align 4'
dbghash: ''
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
reti322:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
storei32sub,i32*result,align4:
dbghash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
varahash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
storei32x,i32*x.addr,align4:
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !16, metadata !DIExpression())'
dbghash: ''
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
sub=subnswi32add,1:
dbghash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
varahash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
x.addr=allocai32,align4:
varahash: ''
- inst: ' %0 = bitcast i32* %result to i8*'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #5'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' call void @llvm.dbg.declare(metadata i32* %result, metadata !17, metadata !DIExpression())'
dbghash: ''
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: ''
- inst: ' %1 = load i32, i32* %x.addr, align 4'
dbghash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
varahash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
- inst: ' %add = add nsw i32 %1, 42'
dbghash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
varahash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
- inst: ' %sub = sub nsw i32 %add, 1'
dbghash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
varahash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
- inst: ' store i32 %sub, i32* %result, align 4'
dbghash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
varahash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
- inst: ' %2 = load i32, i32* %result, align 4'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' %3 = bitcast i32* %result to i8*'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' call void @llvm.lifetime.end.p0i8(i64 4, i8* %3) #5'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' ret i32 %2'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
main:
annotations:
call1=calli32(i8*,...)@printf(i8*noundefgetelementptrinbounds([3xi8],[3xi8]*@.str,i640,i640),i32noundefcall):
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
call=callnoundefi32@_Z19calculate_somethingi(i32noundef4):
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
reti320:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
- inst: ' %call = call noundef i32 @_Z19calculate_somethingi(i32 noundef 4)'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' %call1 = call i32 (i8*, ...) @printf(i8* noundef getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 noundef %call)'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' ret i32 0'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
...
"""

YAML_DOC_BA_AST = """---
functions:
_Z19calculate_somethingi:
annotations:
0=bitcasti32*resulttoi8*:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
1=loadi32,i32*x.addr,align4:
dbghash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
2=loadi32,i32*result,align4:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
3=bitcasti32*resulttoi8*:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
add=addnswi321,42:
dbghash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
[email protected](metadatai32*result,metadata!17,metadata!DIExpression()):
- inst: ' %x.addr = alloca i32, align 4'
dbghash: ''
varahash: ''
[email protected](metadatai32*x.addr,metadata!16,metadata!DIExpression()):
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' %result = alloca i32, align 4'
dbghash: ''
varahash: ''
[email protected](i644,i8*3)#5:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
[email protected](i644,i8*0)#5:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
result=allocai32,align4:
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' store i32 %x, i32* %x.addr, align 4'
dbghash: ''
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
reti322:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
storei32sub,i32*result,align4:
dbghash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
storei32x,i32*x.addr,align4:
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !16, metadata !DIExpression())'
dbghash: ''
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
sub=subnswi32add,1:
dbghash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
varahash: 2b9a08d1adb63d2db9283811f79ac66e373ccfe9
x.addr=allocai32,align4:
varahash: ''
- inst: ' %0 = bitcast i32* %result to i8*'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #5'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' call void @llvm.dbg.declare(metadata i32* %result, metadata !17, metadata !DIExpression())'
dbghash: ''
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: ''
- inst: ' %1 = load i32, i32* %x.addr, align 4'
dbghash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' %add = add nsw i32 %1, 42'
dbghash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' %sub = sub nsw i32 %add, 1'
dbghash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
varahash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
- inst: ' store i32 %sub, i32* %result, align 4'
dbghash: 73b69c2c4b1ab80e5e9dcf24c3280ca9f394f20f
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' %2 = load i32, i32* %result, align 4'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' %3 = bitcast i32* %result to i8*'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' call void @llvm.lifetime.end.p0i8(i64 4, i8* %3) #5'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' ret i32 %2'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
main:
annotations:
call1=calli32(i8*,...)@printf(i8*noundefgetelementptrinbounds([3xi8],[3xi8]*@.str,i640,i640),i32noundefcall):
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
call=callnoundefi32@_Z19calculate_somethingi(i32noundef4):
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
reti320:
dbghash: 2553b819d9434f3396727617438dc0d6ae39b056
varahash: 2553b819d9434f3396727617438dc0d6ae39b056
- inst: ' %call = call noundef i32 @_Z19calculate_somethingi(i32 noundef 4)'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' %call1 = call i32 (i8*, ...) @printf(i8* noundef getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 noundef %call)'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
- inst: ' ret i32 0'
dbghash: 16c99ec75c6f40538f812b22f11ce69b54e58147
varahash: 16c99ec75c6f40538f812b22f11ce69b54e58147
...
"""

Expand Down
19 changes: 13 additions & 6 deletions varats/varats/data/reports/blame_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
class BlameInstruction():
"""Collection of debug blame and VaRA blame."""

def __init__(self, dbg_hash: str, vara_computed_hash: str) -> None:
def __init__(
self, inst: str, dbg_hash: str, vara_computed_hash: str
) -> None:
self.__inst = inst
self.__dbg_hash = dbg_hash
self.__vara_computed_hash = vara_computed_hash

Expand All @@ -21,9 +24,15 @@ def create_blame_instruction(
) -> 'BlameInstruction':
"""Creates a :class`BlameInstrucion`from the corresponding yaml document
section."""
inst = str(raw_entry['inst'])
dbg_hash = str(raw_entry['dbghash'])
vara_computed_hash = str(raw_entry['varahash'])
return BlameInstruction(dbg_hash, vara_computed_hash)
return BlameInstruction(inst, dbg_hash, vara_computed_hash)

@property
def inst(self) -> str:
"""Intermediate representation of LLVM instruction."""
return self.__inst

@property
def dbg_hash(self) -> str:
Expand Down Expand Up @@ -74,11 +83,9 @@ def __init__(self, path: Path) -> None:
func_entry = raw_blame_report['functions'][func]
for raw_entry in func_entry['annotations']:
new_entry = (
BlameInstruction.create_blame_instruction(
func_entry['annotations'][raw_entry]
)
BlameInstruction.create_blame_instruction(raw_entry)
)
new_func.add_annotation(raw_entry, new_entry)
new_func.add_annotation(new_entry.inst, new_entry)
self.__functions[func] = new_func

@property
Expand Down

0 comments on commit df60036

Please sign in to comment.