[llvm-dev] Clearing the BSS section

devh8h via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 28 08:55:54 PDT 2015


The declaration is the solution :
;—————
@__bss_start = extern_weak externally_initialized global i32
@__bss_end = extern_weak externally_initialized global i32
;—————

Now, the optimized code generated by opt is :
;—————
define void @clearBSS() nounwind {
entry:
  br i1 icmp eq (i32* @__bss_start, i32* @__bss_end), label %clearCompleted, label %bssLoop.preheader

bssLoop.preheader:                                ; preds = %entry
  br label %bssLoop

bssLoop:                                          ; preds = %bssLoop.preheader, %bssLoop
  %p1 = phi i32* [ %p.next, %bssLoop ], [ @__bss_start, %bssLoop.preheader ]
  store i32 0, i32* %p1, align 4
  %p.next = getelementptr inbounds i32, i32* %p1, i32 1
  %completed = icmp eq i32* %p.next, @__bss_end
  br i1 %completed, label %clearCompleted.loopexit, label %bssLoop

clearCompleted.loopexit:                          ; preds = %bssLoop
  br label %clearCompleted

clearCompleted:                                   ; preds = %clearCompleted.loopexit, %entry
  ret void
}
;—————

Thank you for the time you spent to help me solve my problem.

Pierre Molinaro

> Le 28 août 2015 à 17:35, Krzysztof Parzyszek via llvm-dev <llvm-dev at lists.llvm.org> a écrit :
> 
> On 8/28/2015 9:52 AM, devh8h via llvm-dev wrote:
>> 
>> Is there a way to prevent the optimizer to assume the two variables are distinct ? Or what is the proper way to deal with link time values ?
> 
> You can use this:
> 
> @__bss_start = extern_weak externally_initialized global i32
> @__bss_end = extern_weak externally_initialized global i32
> 
> -Krzysztof
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list