struct.ll 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
  2. ; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
  3. %struct.foo = type { [16 x i8] }
  4. @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
  5. ; struct { [16 x i8] }
  6. define void @foo(i8* %a) nounwind uwtable safestack {
  7. entry:
  8. ; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
  9. ; CHECK: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
  10. ; CHECK: store i8* %[[USST]], i8** @__safestack_unsafe_stack_ptr
  11. ; CHECK: %[[AADDR:.*]] = alloca i8*, align 8
  12. %a.addr = alloca i8*, align 8
  13. ; CHECK: %[[BUFPTR:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
  14. ; CHECK: %[[BUFPTR2:.*]] = bitcast i8* %[[BUFPTR]] to %struct.foo*
  15. %buf = alloca %struct.foo, align 1
  16. ; CHECK: store i8* {{.*}}, i8** %[[AADDR]], align 8
  17. store i8* %a, i8** %a.addr, align 8
  18. ; CHECK: %[[GEP:.*]] = getelementptr inbounds %struct.foo, %struct.foo* %[[BUFPTR2]], i32 0, i32 0, i32 0
  19. %gep = getelementptr inbounds %struct.foo, %struct.foo* %buf, i32 0, i32 0, i32 0
  20. ; CHECK: %[[A:.*]] = load i8*, i8** %[[AADDR]], align 8
  21. %a2 = load i8*, i8** %a.addr, align 8
  22. ; CHECK: call i8* @strcpy(i8* %[[GEP]], i8* %[[A]])
  23. %call = call i8* @strcpy(i8* %gep, i8* %a2)
  24. ; CHECK: store i8* %[[USP]], i8** @__safestack_unsafe_stack_ptr
  25. ret void
  26. }
  27. declare i8* @strcpy(i8*, i8*)