constant-geps.ll 1.1 KB

12345678910111213141516171819202122232425262728
  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.deep = type { %union.anon }
  4. %union.anon = type { %struct.anon }
  5. %struct.anon = type { %struct.anon.0 }
  6. %struct.anon.0 = type { %union.anon.1 }
  7. %union.anon.1 = type { [2 x i8] }
  8. @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
  9. ; [2 x i8] nested in several layers of structs and unions
  10. ; safestack attribute
  11. ; Requires no protector.
  12. ; CHECK-LABEL: @foo(
  13. define signext i8 @foo() nounwind uwtable safestack {
  14. entry:
  15. ; CHECK-NOT: __safestack_unsafe_stack_ptr
  16. %x = alloca %struct.deep, align 1
  17. %b = getelementptr inbounds %struct.deep, %struct.deep* %x, i32 0, i32 0
  18. %c = bitcast %union.anon* %b to %struct.anon*
  19. %d = getelementptr inbounds %struct.anon, %struct.anon* %c, i32 0, i32 0
  20. %e = getelementptr inbounds %struct.anon.0, %struct.anon.0* %d, i32 0, i32 0
  21. %array = bitcast %union.anon.1* %e to [2 x i8]*
  22. %arrayidx = getelementptr inbounds [2 x i8], [2 x i8]* %array, i32 0, i64 0
  23. %0 = load i8, i8* %arrayidx, align 1
  24. ret i8 %0
  25. }